Engine
dagpipe.engine
Summary
Execution engine responsible for running pipelines and graphs.
The Engine executes Node objects and propagates immutable State instances
through either a linear sequence or a directed acyclic graph (Graph).
It orchestrates execution order, branching, and state propagation.
Guarantees
- Deterministic execution and consistent state lineage.
- Orchestrates execution without modifying
Graph,Node, orStateobjects.
Classes
Engine
Execution engine responsible for running pipeline logic.
Notes
Responsibilities:
1 2 3 4 5 6 7 | |
Guarantees:
1 2 3 4 5 | |
Attributes
nodes
property
Return nodes managed by this engine.
Returns:
| Type | Description |
|---|---|
tuple[Node, ...]
|
tuple[Node, ...]: Ordered sequence in linear mode or all nodes in graph mode. |
Functions
__repr__
Return the canonical string representation of the object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Representation that uniquely identifies the object and its configuration. |
run
Execute the pipeline starting from a root State.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root |
State
|
Initial execution state. |
required |
Returns:
| Type | Description |
|---|---|
list[State]
|
list[State]: Terminal execution states produced by the pipeline. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
RuntimeError
|
If the engine execution mode is invalid. |
Notes
Responsibilities:
1 2 | |
run_async
async
Execute the pipeline starting from root, dispatching sync vs async nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root |
State
|
Initial execution state. |
required |
Returns:
| Type | Description |
|---|---|
list[State]
|
list[State]: Terminal execution states produced by the pipeline. |
Notes
Each node is executed with Node.run when synchronous and
AsyncNode.run_async when asynchronous. Linear and graph topologies
are both supported.
run_steps
Execute the pipeline step-by-step, yielding one StepResult per step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root |
State
|
Initial execution state. |
required |
resume_from |
int
|
Skip steps at index < |
None
|
on_step |
StepHook
|
Callback |
None
|
Yields:
| Name | Type | Description |
|---|---|---|
StepResult |
StepResult
|
One per executed node/step, carrying the produced states. |
Notes
This is a synchronous, generator-based checkpoint interface compatible
with the imperative resume-by-step behaviour of the legacy
orchestrator. Use run_steps_async for async nodes.
run_steps_async
async
Async variant of run_steps supporting AsyncNode execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root |
State
|
Initial execution state. |
required |
resume_from |
int
|
Skip steps at index < |
None
|
on_step |
AsyncStepHook
|
Async callback |
None
|
Yields:
| Name | Type | Description |
|---|---|---|
StepResult |
AsyncIterator[StepResult]
|
One per executed node/step. |
ProgressMessage
Lightweight progress payload emitted by engine step hooks.
Mirrors the imperative ProgressMessage used by the legacy orchestrator so
callers can surface counts/lines/errors without coupling the engine to pydantic.
StepResult
A single checkpointed step within an async/resumable engine run.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
Ordinal index of the step. |
node_id |
str
|
Identifier of the node associated with this step. |
states |
Tuple[State, ...]
|
States produced by running this step. |
completed |
bool
|
Whether this step succeeded (vs. paused/interrupted). |