Composable Pipelines
A pipeline is built by a function, so it distributes like one. A Hub module can export a builder that returns a live Pipeline (for downstream code to inspect and rewire) or a builder wrapped as a single Flow stage (to drop inside a larger graph). Both surfaces come from the same registered pipeline.
Prove the mechanics locally first — this runs in the core checkout:
1. Register a pipeline with an explicit surface
Section titled “1. Register a pipeline with an explicit surface”register_pipeline records a builder under a name and declares the external ports downstream code is allowed to touch. Name internal flows with .named(...) so those ports have stable ids.
2. Extend a live pipeline
Section titled “2. Extend a live pipeline”Call the builder to get a real Pipeline, then reach in by id and rewire it. This is what a downstream consumer does after hub.use-ing the builder:
3. Reuse the whole pipeline as one Flow stage
Section titled “3. Reuse the whole pipeline as one Flow stage”build_pipeline_flow(name) returns the registered pipeline as a Flow you can name, rate, and wire like any other node:
Nesting boundary:
stage.step(...)in isolation is local and in-process.- The wrapper is not itself the backend artifact.
- Inside a larger
Pipeline, Retriever lowers the wrapper into flat IR, so the multiprocessing and dora backends execute the inner nodes directly.
Distributing a builder over Hub
Section titled “Distributing a builder over Hub”Export the two builders from your module’s manifest (Publishing):
Then a consumer reuses either surface exactly as above — a live graph to extend, or a stage to nest:
Surface grammar
Section titled “Surface grammar”Explicit ports are flow_id.port. Selectors resolve by exact flow/node id first, then fall back to a unique flow class name. Prefer stable .named(...) handles and declare them in input_ports=[...] / output_ports=[...] so the public surface does not drift with internal renames.
Pipeline.visualize(...) and IR.visualize(...) keep wrapped-pipeline context: a nested build_pipeline_flow(...) stage renders as a grouped box around its lowered inner flows, with the pipeline name and surfaced port bindings. Render the tutorial graph with pixi run docs-tutorial-composable-html.
For applied composition, see the first GoldenRetriever proof and the GoldenRetriever examples.
