Skip to main content

StageFlow

Pipelines described in JSON, executed in Python — and debuggable node by node.

tests PyPI Python docs license

Documentation · Tutorial · Документация на русском

A pipeline is a graph of nodes in JSON. The work happens in stages — Python classes you write. Between them travels one immutable frame of variables, and everything the graph does with that frame is visible in the JSON: branching, retries, error handling, concurrency, nested graphs.

Because the pipeline is data, it can be stored, diffed, generated, validated before it runs — and drawn:

A pipeline open in the StageFlow editor

That is the editor: a separate static page that draws and debugs a graph while this core executes it.

Install

pip install stageflow-framework

Python 3.11+.

A pipeline in 30 seconds

import asyncio

from stageflow import BaseStage, Pipeline, Session, register_stage


@register_stage("HelloStage")
class HelloStage(BaseStage):
    """
    description: "Greets whoever the pipeline points at"
    arguments:
      name: string
    outputs:
      greeting: string
    """

    async def run(self):
        name = self.get_arguments().get("name", "world")
        self.set_outputs({"greeting": f"Hello, {name}!"})


pipeline = Pipeline.from_dict({
    "nodes": [
        {"id": "start", "type": "entry",
         "variables": {"user_name": "Alice"}, "next": "hello"},
        {"id": "hello", "type": "stage", "stage": "HelloStage",
         "arguments": {"vars": {"name": "user_name"}},
         "outputs": {"greeting": "greeting"}, "next": "finish"},
        {"id": "finish", "type": "terminal",
         "result": {"status": "ok"}, "artifacts": ["greeting"]},
    ],
})
pipeline.validate()

result = asyncio.run(Session(id="demo", pipeline=pipeline).run())
print(result.result)     # {'status': 'ok'}
print(result.artifacts)  # {'greeting': 'Hello, Alice!'}

The docstring is the stage's specification. validate() checks the graph against it, so a wrong argument name is an error before anything runs.

What the graph can do

Nine node types entry, stage, condition, switch, parallel, try, map, subpipeline, terminal
One immutable frame variables travel along the path; a write produces a new frame, so branches never collide
CEL expressions in conditions, in switch cases, and in any argument or output through the .$ suffix
Errors as roads retry on a node, try/except over a region of the graph derived from its shape
Real concurrency parallel branches with their own frames and explicit merge rules
Loops over data map runs a region of the graph once per element, sequentially or at once
Nested graphs a subpipeline starts with a fresh frame and returns artifacts
A policy per tenant the stages and node types one session may use — a subset of the registry, not a subset of the process
Budgets that hold counters and gauges for time, steps, tokens, fan-out and depth; a ceiling a try block cannot catch
Gradual typing declare the variables that matter; checked at validation and on every write
Step debugging stop between nodes, read and edit the frame, replay the event stream

Documentation

The tutorial builds one working pipeline step by step, with screenshots from the editor. The reference covers the rest:

Quick start · Node types · Data model · Expressions · Errors · Policy · Limits · Variable typing · Session control · Step debugging

One page per node type: entry · stage · condition · switch · parallel · try · map · subpipeline · terminal

Sources are in docs/ (*.md English, *.ru.md Russian) and publish themselves on every push to main.

The rest of the project

Repository What it is
stageflow this one: the core that runs the pipelines
stageflow-ui the editor: a static page that draws and debugs a graph
stageflow-example a working backend for the editor: a support bot in four pipelines

Development

pip install -e ".[dev]"
python -m unittest discover -s tests

Pipelines can be tested declaratively:

from stageflow.testing import PipelineTestSpec, run_pipeline_test

Releases are tag-driven: the tag has to match project.version in pyproject.toml, and the workflow publishes to PyPI.

License

MIT — see LICENSE.

Release files for stageflow-framework 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stageflow-framework 0.12.0
File Size Uploaded
stageflow_framework-0.12.0.tar.gz 89.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stageflow-framework 0.12.0
File Interpreter ABI Platform
stageflow_framework-0.12.0-py3-none-any.whl Python 3 none any Details

Total release size: 156.3 kB

Release files / stageflow_framework-0.12.0.tar.gz

Download URL stageflow_framework-0.12.0.tar.gz
Size 89.9 kB
Tags Source
SHA-256 checksum
How to use checksums
693c6e80800686809f8406a13cfd9a7f95d74bbf6b154219468ee1a1965a09c4
BLAKE2b-256 checksum
How to use checksums
e2e5debc37333a707e52d2f7f94cb149e1a89797eb8296ac06911038d0f57b54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release files / stageflow_framework-0.12.0-py3-none-any.whl

Download URL stageflow_framework-0.12.0-py3-none-any.whl
Size 66.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59d0bc908c63aa84fb39d302af573f5a109e3dffd84d8efd75adfa86df719b18
BLAKE2b-256 checksum
How to use checksums
6951550eb8f389cac6041ee1c05d690a8ddb7e613174662c239a92c0b8c36d72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.13.0

2 release files

This release

0.12.0 This release

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page