Build a scientific pipeline
Chain calculation, verification and save steps, or fan out across inputs in parallel.
A saved CLI login and a running CPU worker.
Split multi-stage workflows into Run → Check → Save jobs so that if verification or database saving fails, you never have to re-run an expensive calculation.
1. Run the 3-stage pipeline example
Run compute/platform/examples/pipeline/run_pipeline.py to execute a 3-stage chain (run → check → save):
Tip: Using the local dev stack? Add
--config .local-dev/compute/client.json.
The script prints the three job IDs, waits for the final save stage, and downloads its report:
2. How the stages connect
First, look at the three worker functions in compute/platform/examples/pipeline/jobs.py:
Next, look at how run_pipeline.py submits all three jobs up front using depends_on:
How data flows between stages:
job_context()reads staged input files (.input("number.txt")) and writes output files (.output("measurement.txt")→results/measurement.txt).depends_on=[measured.id]tells the scheduler to holdcheckuntilmeasuredsucceeds. Once submitted, your laptop can disconnect and the pipeline still finishes on the cluster.Collection()+one_result()gives the child job the parent's typed return value (parent.value) and local paths to its output files (parent.artifacts["results/measurement.txt"]).
For structured scientific outputs, use Parquet and reuse the producer's accepted artifact. See Share and stream scientific datasets for a complete file-producing pipeline, bounded readers and the distinction between full input staging and partial trajectory reads.
3. Fan out and reduce with a Flow
When you need to run the same calculation across many inputs in parallel and combine the results, use flows.prepare(...).map(...).reduce(...).then(...):
Here is the complete driver (compute/platform/examples/programs/run_flow.py):
Each stage is type-checked against the next:
preparetakesCount(count=3)and returnsItems[Number](0, 1, 2)..map(double)runsdoubleon each item in parallel (0, 2, 4)..reduce(total)receivesItems[Number]and sums them (6). Use.collect(reducer)instead if your reducer also needs parent files or failed item records..then(increment)runs a follow-up step on the reduced result (7).
4. Check status and debug failures
Inspect a Flow or any individual stage from the CLI:
If a stage fails, upstream stages keep their completed outputs. Our built-in transition state and DFT workflows use this exact pattern so ct-cli ts retry and ct-cli dft retry can resume from the failed step.