MODULE REFERENCE

graph

anomx.execution.work.graph

Portable work graphs; the host decides how and where each step executes.

WorkGraph

WorkGraph(steps: list[WorkStep], *, output_node: str | None = None)

A validated, deterministic DAG with explicit predecessor outputs.

The executor receives a step and its inputs. previous is the sole direct predecessor's result (or a mapping for a join), results contains every completed step keyed by ID, and original inputs remain available. Execution is sequential in topological order; dispatch and isolation belong to the host.

Signature parameters
ParameterTypeDefault
stepslist[WorkStep]required
output_nodekeyword onlystr | NoneNone

Members

executemethod
execute(executor: Callable[[WorkStep, dict[str, Any]], Any], *, inputs: Mapping[str, Any] | None = None) -> object

Execute every step once; propagate errors immediately to the host.

Signature parameters
ParameterTypeDefault
executorCallable[[WorkStep, dict[str, Any]], Any]required
inputskeyword onlyMapping[str, Any] | NoneNone

Returns object

from_dictclassmethod
from_dict(graph: Mapping[str, Any]) -> WorkGraph

Read the editor's start/code/inference/end representation.

Legacy compute, log, notification and detection nodes remain readable. Start and end are structural nodes and cannot contain executable code.

Signature parameters
ParameterTypeDefault
graphMapping[str, Any]required

Returns WorkGraph

WorkStep

WorkStep(id: str, kind: Literal['python', 'inference'], code: str, runtime: str = 'task', dependencies: tuple[str, ...] = (), label: str = '', metadata: Mapping[str, Any] = <factory: dict>)

One Python or inference step with an explicit runtime selection.

task executes on the orchestrator, default uses the work's compute target, and other strings identify host-defined resources. The host must authorize those resources. Inference remains a distinct operation so a host can later reuse model sessions without changing the graph contract.

Signature parameters
ParameterTypeDefault
idstrrequired
kindLiteral['python', 'inference']required
codestrrequired
runtimestr'task'
dependenciestuple[str, ...]()
labelstr''
metadataMapping[str, Any]<factory: dict>

Members

idattribute
kindattribute
kind: Literal['python', 'inference']
codeattribute
runtimeattribute
runtime: str = 'task'
dependenciesattribute
dependencies: tuple[str, ...] = ()
labelattribute
metadataattribute
metadata: Mapping[str, Any] = field(default_factory=dict)