Skip to main content

Workflow composition, failure handlers, and nodes

In flytekit, you compose workflows with the @workflow decorator (workflow.py:933). When a task is added, it creates a Node (node.py); ordinary calls return Promise objects (promise.py), while create_node() yields a Node whose .outputs is distinct from a task-call promise.

Pass on_failure to handle failures; the handler must accept every workflow input and only optional extras. Per-node overrides use Node.with_overrides() (node.py), which updates metadata, resources, and cache settings.

@workflow(on_failure=handler)
def wf(x: int) -> int:
n = create_node(task)
return n.outputs["o"]

Node.outputs (node.py) raises if the node was not from create_node. Promise (promise.py) wraps unresolved references and supports comparison expressions (ComparisonExpression) and conjunctions (ConjunctionExpression).