Skip to content

Commit

Permalink
🔄 synced local 'skyvern/' with remote 'skyvern/'
Browse files Browse the repository at this point in the history
<!-- ELLIPSIS_HIDDEN -->

> [!IMPORTANT]
> Add `complete_if_empty` parameter to `ForLoopBlock` to allow loop completion if iterable is empty, with updates in `block.py`, `yaml.py`, and `service.py`.
>
>   - **Behavior**:
>     - Add `complete_if_empty` parameter to `ForLoopBlock` in `block.py` to allow loop completion if iterable is empty.
>     - Modify `get_loop_over_parameter_values()` in `block.py` to return an empty list if `complete_if_empty` is `True` and no iterable is found.
>   - **YAML Models**:
>     - Add `complete_if_empty` to `ForLoopBlockYAML` in `yaml.py`.
>   - **Service Layer**:
>     - Update `block_yaml_to_block()` in `service.py` to handle `complete_if_empty` for `ForLoopBlock`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=Skyvern-AI%2Fskyvern-cloud&utm_source=github&utm_medium=referral)<sup> for 2a825f4ec0dd5deab5305312cdecbb370e09cab0. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
wintonzheng committed Jan 29, 2025
1 parent 2166ab1 commit a51edfc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion skyvern/forge/sdk/workflow/models/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ class ForLoopBlock(Block):
loop_blocks: list[BlockTypeVar]
loop_over: PARAMETER_TYPE | None = None
loop_variable_reference: str | None = None
complete_if_empty: bool = False

def get_all_parameters(
self,
Expand Down Expand Up @@ -849,7 +850,10 @@ def get_loop_over_parameter_values(self, workflow_run_context: WorkflowRunContex
raise NotImplementedError()

else:
raise NoIterableValueFound()
if self.complete_if_empty:
return []
else:
raise NoIterableValueFound()

if isinstance(parameter_value, list):
return parameter_value
Expand Down
1 change: 1 addition & 0 deletions skyvern/forge/sdk/workflow/models/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class ForLoopBlockYAML(BlockYAML):
loop_blocks: list["BLOCK_YAML_SUBCLASSES"]
loop_over_parameter_key: str = ""
loop_variable_reference: str | None = None
complete_if_empty: bool = False


class CodeBlockYAML(BlockYAML):
Expand Down
1 change: 1 addition & 0 deletions skyvern/forge/sdk/workflow/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,7 @@ async def block_yaml_to_block(
loop_blocks=loop_blocks,
output_parameter=output_parameter,
continue_on_failure=block_yaml.continue_on_failure,
complete_if_empty=block_yaml.complete_if_empty,
)
elif block_yaml.block_type == BlockType.CODE:
return CodeBlock(
Expand Down

0 comments on commit a51edfc

Please sign in to comment.