Skip to content

Subflow

junjo.Subflow

Kind: Class

SDK version: 0.64.0

Documentation channel: Next source preview

Subflow(graph_factory: GraphFactory[Graph], store_factory: StoreFactory[StoreT], max_iterations: int = 100, hooks: Hooks | None = None, name: str | None = None)

View source

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_actions and post_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.

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 the
beginning of each execute call to
ensure 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 the
beginning of each execute call to
ensure 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 each
child item in the concurrent group rather than the
RunConcurrent wrapper itself. Defaults to 100.
100
hooks Hooks | None An optional Hooks registry for
observing lifecycle events emitted by this subflow.
None

pre_run_actions(parent_store: ParentStoreT, subflow_store: StoreT) -> None

View source

This 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.

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(parent_store: ParentStoreT, subflow_store: StoreT) -> None

View source

This method is called after the subflow has run.

This is where you can update the parent store with the results of the child workflow.

Name Type Description Default
parent_store ParentStoreT The parent store to update.
subflow_store StoreT The store for this specific subflow execution.