Skip to main content
Branches let a node start a side pipeline when it finishes, without changing where the main path goes next. Use them for work that should happen because a node ran, such as logging a result or writing rows to a table.

Adding a Branch

Create a branch with add_branch(). The destination runs after the source completes; the main path continues along its regular edges as if the branch were not there:
A branch needs no join and no end node. It stops at the first node with no outgoing edges.

Multi-Step Branches

The branch target can lead to further nodes through ordinary edges. Together they form a pipeline that runs to its last step:
If a step returns {"success": False}, the steps after it do not run.

Reading the Previous Node

Every node can declare an upstream parameter. It holds the name and output of the node that ran just before it, so a pipeline step can read what it was given:
upstream is available on the main path too, and nodes that do not declare it are unaffected.

Conditions

Pass a condition to decide at run time whether the branch runs. It receives the source node’s output and the graph state and may be sync or async:

Detached Branches

By default the main path waits for a branch to finish before moving on. Pass wait=False to let it continue immediately:
execute() still waits for every detached branch before it returns, so nothing is left running when a run is reported complete.

Errors

An exception inside a branch never reaches the main path. It is logged and recorded on the graph:
branch_errors is cleared at the start of each execute().

Branches on Routers and Loops

A branch can hang off any node, including a node inside a router loop. The loop is unaffected because a branch is not one of the node’s successors:

Next Steps