Subflow
junjo.Subflow
Kind: Class
SDK version: 0.64.0
Documentation channel: Next source preview
Signature
Section titled “Signature”Subflow(graph_factory: GraphFactory[Graph], store_factory: StoreFactory[StoreT], max_iterations: int = 100, hooks: Hooks | None = None, name: str | None = None)Constructor
Section titled “Constructor”A Subflow is a workflow that:
- Executes within a parent workflow or parent subflow.
- Has its own isolated state and store.
- Can interact with its parent workflow state before and after
execution via
pre_run_actionsandpost_run_actions.
Like top-level workflows, subflows create a fresh graph and a fresh store for every execution. The child run is isolated from the parent store except for the explicit handoff points provided by the pre- and post-run hooks.
Parameters
Section titled “Parameters”| Name | Type | Description | Default |
|---|---|---|---|
name |
str | None |
An optional name for the subflow. If not provided, the class name is used. |
None |
graph_factory |
GraphFactory[Graph] |
A callable that returns a new instance of the subflow’s graph ( Graph). This factory is invoked at thebeginning of each execute call toensure a fresh, isolated graph for that execution. |
|
store_factory |
StoreFactory[StoreT] |
A callable that returns a new instance of the subflow’s store ( StoreT). This factory is invoked at thebeginning of each execute call toensure a fresh store for that execution. |
|
max_iterations |
int |
The maximum number of times any single node or nested subflow may run within one subflow execution. For RunConcurrent, Junjo counts eachchild item in the concurrent group rather than the RunConcurrent wrapper itself. Defaults to 100. |
100 |
hooks |
Hooks | None |
An optional Hooks registry forobserving lifecycle events emitted by this subflow. |
None |
Members
Section titled “Members”pre_run_actions
Section titled “pre_run_actions”pre_run_actions(parent_store: ParentStoreT, subflow_store: StoreT) -> NoneThis method is called before the subflow has run.
This is where you can pass initial state values from the parent workflow to the subflow store for this specific run.
Parameters
Section titled “Parameters”| Name | Type | Description | Default |
|---|---|---|---|
parent_store |
ParentStoreT |
The parent store to interact with. | |
subflow_store |
StoreT |
The store for this specific subflow execution. |
post_run_actions
Section titled “post_run_actions”post_run_actions(parent_store: ParentStoreT, subflow_store: StoreT) -> NoneThis method is called after the subflow has run.
This is where you can update the parent store with the results of the child workflow.
Parameters
Section titled “Parameters”| Name | Type | Description | Default |
|---|---|---|---|
parent_store |
ParentStoreT |
The parent store to update. | |
subflow_store |
StoreT |
The store for this specific subflow execution. |