Runner
Run a waldiez flow.
The flow is first converted to an ag2 flow with agents, chats, and tools. We then chown to temporary directory, import and call the flow's main(on_event) method. The on_event method is called with the event emitter, which emits events during the flow execution. The flow is run in a temporary directory, and the results are saved to the output file's directory. The uploads root directory is used to store any uploaded files during the flow execution.
WaldiezRunner ¶
WaldiezRunner(
waldiez: Waldiez,
mode: Literal["standard", "debug"] = "standard",
output_path: str | Path | None = None,
uploads_root: str | Path | None = None,
message: str | None = None,
structured_io: bool = False,
dot_env: str | Path | None = None,
**kwargs: Any
)
Bases: WaldiezBaseRunner
Factory class for creating Waldiez runners.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waldiez | Waldiez | The waldiez flow to run. | required |
mode | Literal['standard', 'debug'] | Runner mode: "standard", "debug", by default "standard" | 'standard' |
output_path | str | Path | None | Output path for results, by default None | None |
uploads_root | str | Path | None | Uploads root directory, by default None | None |
message | str | None | Optional initial message to pass (override flow's message if needed) | None |
structured_io | bool | Use structured I/O, by default False | False |
dot_env | str | Path | None | Path to a .env file for environment variables, by default None | None |
**kwargs | Any | Additional arguments for specific runner types | {} |
Source code in waldiez/runner.py
a_run async ¶
a_run(
output_path: str | Path | None = None,
uploads_root: str | Path | None = None,
structured_io: bool | None = None,
message: str | None = None,
skip_mmd: bool = False,
skip_timeline: bool = False,
skip_symlinks: bool = False,
skip_deps: bool | None = None,
dot_env: str | Path | None = None,
**kwargs: Any
) -> list[dict[str, Any]]
Run the Waldiez flow asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path | str | Path | None | The output path, by default None. | None |
uploads_root | str | Path | None | The runtime uploads root. | None |
structured_io | bool | Whether to use structured IO instead of the default 'input/print'. | None |
message | str | None | Optional initial message to pass (override flow's message if needed) | None |
skip_mmd | bool | Whether to skip generating the mermaid diagram. | False |
skip_timeline | bool | Whether to skip generating the timeline JSON. | False |
skip_symlinks | bool | Whether to skip creating symlinks for checkpoints. | False |
skip_deps | bool | Whether to skip installing dependencies. | None |
dot_env | str | Path | None | The path to the .env file, if any. | None |
**kwargs | Any | Additional keyword arguments for the a_run method. | {} |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | The results of the run. |
Raises:
| Type | Description |
|---|---|
RuntimeError | If the runner is already running, the workflow is not async or an error occurs during the run. |
StopRunningException | If the run is stopped by the user. |
Source code in waldiez/runner.py
load classmethod ¶
load(
waldiez_file: str | Path,
name: str | None = None,
description: str | None = None,
tags: list[str] | None = None,
requirements: list[str] | None = None,
output_path: str | Path | None = None,
uploads_root: str | Path | None = None,
structured_io: bool = False,
dot_env: str | Path | None = None,
**kwargs: Any
) -> WaldiezRunner
Load a waldiez flow and create a runner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waldiez_file | str | Path | Path to the waldiez flow file. | required |
name | str | None | Name of the flow, by default None | None |
description | str | None | Description of the flow, by default None | None |
tags | list[str] | None | Tags for the flow, by default None | None |
requirements | list[str] | None | Requirements for the flow, by default None | None |
output_path | str | Path | None | Output path for results, by default None | None |
uploads_root | str | Path | None | Uploads root directory, by default None | None |
structured_io | bool | Use structured I/O, by default False | False |
dot_env | str | Path | None | Path to a .env file for environment variables, by default None | None |
**kwargs | Any | Additional arguments for specific runner types | {} |
Returns:
| Type | Description |
|---|---|
WaldiezRunner | The configured runner instance |
Source code in waldiez/runner.py
run ¶
run(
output_path: str | Path | None = None,
uploads_root: str | Path | None = None,
structured_io: bool | None = None,
message: str | None = None,
skip_mmd: bool = False,
skip_timeline: bool = False,
skip_symlinks: bool = False,
skip_deps: bool | None = None,
dot_env: str | Path | None = None,
**kwargs: Any
) -> list[dict[str, Any]]
Run the Waldiez flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path | str | Path | None | The output path, by default None. | None |
uploads_root | str | Path | None | The runtime uploads root, by default None. | None |
structured_io | bool | Whether to use structured IO instead of the default 'input/print'. | None |
message | str | None | Optional initial message to pass (override flow's message if needed) | None |
skip_mmd | bool | Whether to skip generating the mermaid diagram. | False |
skip_timeline | bool | Whether to skip generating the timeline JSON. | False |
skip_symlinks | bool | Whether to skip creating symlinks for checkpoints. | False |
skip_deps | bool | None | Whether to skip installing dependencies. | None |
dot_env | str | Path | None | The path to the .env file, if any. | None |
**kwargs | Any | Additional keyword arguments for the run method. | {} |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | The results of the run. |
Raises:
| Type | Description |
|---|---|
RuntimeError | If the runner is already running, the workflow is not async, or an error occurs during the run. |
StopRunningException | If the run is stopped by the user. |
Source code in waldiez/runner.py
create_runner ¶
create_runner(
waldiez: Waldiez,
mode: Literal[
"standard", "debug", "subprocess"
] = "standard",
output_path: str | Path | None = None,
uploads_root: str | Path | None = None,
structured_io: bool = False,
dot_env: str | Path | None = None,
**kwargs: Any
) -> WaldiezBaseRunner
Create a Waldiez runner of the specified type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waldiez | Waldiez | The waldiez flow to run. | required |
mode | Literal['standard', 'debug'] | Runner mode: "standard", "debug", by default "standard" | 'standard' |
output_path | str | Path | None | Output path for results, by default None | None |
uploads_root | str | Path | None | Uploads root directory, by default None | None |
structured_io | bool | Use structured I/O, by default False | False |
dot_env | str | Path | None | Path to a .env file for environment variables, by default None | None |
**kwargs | Any | Additional arguments for specific runner types | {} |
Returns:
| Type | Description |
|---|---|
WaldiezBaseRunner | The configured runner instance |
Raises:
| Type | Description |
|---|---|
ValueError | If unknown runner mode is specified |