Pipelines
Chain ordered work, such as data preparation, training and evaluation, into steps and run it in one go. After reading this page you can build a pipeline from Python functions or in the UI editor, and find the failed step and its log in the run history.
Two ways to build
Section titled “Two ways to build”| Item | Code (qgon.pipeline) |
UI editor |
|---|---|---|
| Steps | Python functions | Scripts in a workspace, or copies of finished runs |
| How steps connect | One function's return value goes into the next | Cards are linked on a canvas |
| Run conditions | The next step runs when a step ends | All parents succeed, always, if a parent fails, metric condition |
| Controller | The process that runs the code | The controller workspace you pick |
Either way, agents on the GPU queue run each step separately. The job that queues the steps in order and collects their results is the controller, and the pipeline stops when the controller stops. Failure-handling branches and metric conditions are available in the UI editor and in spec files.
Build in code
Section titled “Build in code”A function decorated with @qgon.pipeline.step becomes a step. A function decorated with @qgon.pipeline.pipeline sets the order in which steps are called.
import qgon
@qgon.pipeline.step(returns="data")def prepare(n: int = 1000): import numpy as np # import step modules inside the function return np.arange(n)
@qgon.pipeline.step(returns="score")def train(data, lr: float = 0.1): return float(data.mean() * lr)
@qgon.pipeline.pipeline(name="demo-pipeline", project="Sandbox")def flow(n: int = 1000, lr: float = 0.1): return train(prepare(n), lr)
print(flow(n=100, lr=0.5)) # waits until the end, then returns the last valueprint(flow.last_run.id, flow.last_run.status)Calling the pipeline function starts a run and returns the last step's value. The run appears in the run history of Build › Pipelines, and flow.last_run gives its id and status.
Only the body of a step function is taken out and run on its own. Variables and helper functions outside it do not come along, so import the modules a step needs inside the function. Return values named with returns go to the next step and are also saved as artifacts. To log metrics inside a step, get the run with qgon.init() inside the step function and call log_metrics. The record lands on that step's run.
| Decorator | Argument | Meaning |
|---|---|---|
step |
returns |
Name of the return value. A list of names if it returns several. |
step |
queue |
Queue for this step. If empty, the pipeline's default queue |
step |
cache |
If True, reuses the previous result when the code and inputs are the same. |
step |
packages |
Packages to install for the step. Detected automatically if empty. |
step |
retries |
How many times to retry after a failure |
pipeline |
name · project |
Name shown in the UI (3 characters or more) and project |
pipeline |
queue |
Default queue for steps. Defaults to gpu. |
pipeline |
abort_on_failure |
If True, stops the remaining steps when one step fails. |
See the qgon.pipeline reference for every argument.
Test without the queue
Section titled “Test without the queue”You can try the pipeline inside this process before sending it to the GPU queue. Call one of these before calling the pipeline function.
qgon.pipeline.debug() # run steps as plain functions, no step jobs# qgon.pipeline.run_locally() # create step jobs but run them here in order, skipping the queueprint(flow(n=10, lr=0.5))Use debug() to check quickly that data flows between steps. run_locally() only skips the queue, so it also catches problems that appear when a step runs on its own, such as an import left outside the function.
The controller process
Section titled “The controller process”For a pipeline built in code, the process that ran the code is the controller. It must stay alive until the end, so start long pipelines with tmux or nohup. Such runs have no controller record on a queue, so the Run again button in the UI is off. To run one again, call the pipeline function again in code.
Build in the UI
Section titled “Build in the UI”Build › Pipelines has two views, Pipeline list and Run history. Press New pipeline to open the editor.
-
At the top, set the pipeline name, the controller workspace, the default queue and the default environment. The default environment is the saved environment of the controller workspace that script steps use.
-
In Add a step on the left, pick Script step or Copy a finished run. For a copy, find a finished run and click it to place it on the canvas.
-
Drag the dot on the right of a card onto the dot on the left of the next card. Links point from parent to child, and a child starts after its parents end. You can branch and merge, but links that would make a loop are refused.
-
Click a card and set its values in Step settings on the right.
-
Press Save or Save & run. You can save while the controller workspace is off.
You can also edit with the keyboard. Tab to a card, press Enter to select it and move it with the arrow keys. Link steps from Parent steps in the step settings. A deleted card or link can be restored right after you delete it.
Script steps
Section titled “Script steps”A script step runs an entry file (a .py file or a -m module) in a code folder of the controller workspace. Each time the pipeline starts, it packages the code folder as it is at that moment. If you change the code and run again, the new code runs.
Parameters in the step settings go to the script as --name=value and are recorded on the run as Args/name. The script must accept that name with argparse. Fixed arguments go one per field, in the order written, before the parameters. You also set the step kind, environment, datasets, target queue and time limit in minutes.
Copy-a-run steps
Section titled “Copy-a-run steps”A copy-a-run step clones a finished run with its code and environment and runs it with the parameters you changed. Parameters with an empty new value keep the original value.
Run conditions
Section titled “Run conditions”Run condition in the step settings decides whether this step runs, based on its parents' results.
| Run condition | This step runs when |
|---|---|
| All parents succeed (default) | Every parent succeeded. If any parent failed or was skipped, this step is skipped. |
| If (parent) fails | Only that parent failed. This is a failure-handling branch, and that parent's failure does not count as a pipeline failure. |
| If a metric of (parent)… | The last value of the parent's metric meets the condition, e.g. val/acc ≥ 0.9 |
| Always (after the parents end) | The parents ended, whatever the result |
Children of a skipped step are skipped too, unless their condition is Always. Metric names use the graph/series form. If the training code logged with run.log_metrics({"acc": acc}, step=ep, prefix="val"), pick val/acc. Links with a condition are drawn as dashed lines on the canvas.
Reference an earlier output
Section titled “Reference an earlier output”A parameter value can contain an earlier step's output. It is replaced with the real value at run time, and the referenced step becomes a parent automatically. References work only in parameters, not in fixed arguments.
| Reference | Replaced with |
|---|---|
${prep.id} |
Run id of step prep |
${prep.artifacts.data.url} |
Address of artifact data saved by step prep |
${train.models.output.-1.url} |
Address of the last output model file saved by step train |
Put the Step id from the step settings in place of prep or train. A step id starts with a lowercase letter and uses only lowercase letters, digits and _.
Controller workspace and parallel branches
Section titled “Controller workspace and parallel branches”The controller workspace must be on and must have finished Set up access. The controller runs inside that workspace under your account, so keep the workspace on until the pipeline ends. The controller log goes under ~/.qgon/pipe/ in that workspace. Each person can have two pipelines started from the UI in progress at a time by default.
Branches run in parallel, up to the number of agents on the same queue.
Manage the list
Section titled “Manage the list”Pipeline list shows each saved pipeline's name, controller workspace, number of steps, last run, last change and creator, with Run, Edit, Duplicate and Delete.
- The creator, members of that workspace and administrators can see it.
- The creator and administrators can edit or delete it. Deleting keeps the run history.
- Members of that workspace run it under their own account.
Run from a spec file
Section titled “Run from a spec file”qgon pipeline --spec starts a pipeline from a JSON spec and acts as the controller until it ends. The UI editor runs the same command inside the controller workspace. The spec below runs the evaluation step only when val/acc is 0.9 or higher after training, and runs a cleanup step if training fails.
{ "name": "train then evaluate", "defaults": {"queue": "gpu"}, "steps": [ {"id": "train", "base_task": "<training run id>", "params": {"General/lr": "0.003"}}, {"id": "evaluate", "base_task": "<evaluation run id>", "params": {"Args/model_url": "${train.models.output.-1.url}"}, "condition": {"type": "metric", "step": "train", "metric": "val/acc", "op": ">=", "value": 0.9}}, {"id": "cleanup", "base_task": "<cleanup run id>", "parents": ["train"], "condition": {"type": "on_failure", "step": "train"}} ]}qgon pipeline --spec pipe-spec.jsonA base_task step clones a finished run. Write params keys as section/name (General/… for values logged with run.params, Args/… for argparse arguments). The condition type is one of all_success, on_failure, metric or always, and the step of on_failure or metric must be a parent of this step. Run qgon pipeline -h for the full spec format.
Exit codes are 0 for completed, 1 for failed, 130 for stopped and 2 for could not start. With --json, the command writes one JSON line to standard output when it starts and another when it ends.
Read the run history
Section titled “Read the run history”Pick a run in Run history of Build › Pipelines. The step graph, the cause of failure and the step log appear on one page.

The list on the left shows each pipeline's runs by number, status, duration and time. The header has the run name, status and who ran it. Hover over Run info (ⓘ) to see where the controller ran. Press Parameters to see the parameters this run used.
If a step failed, Cause of failure at the top shows that step's name and the last error line of its log. Press Step log to jump to that step's log.
The step graph links steps from left to right and colors each one as completed, running, failed, queued, cached or skipped. A cached step reused the result of an earlier run because its code and inputs were the same. Click a step to see its status, duration, the agent that ran it and its recent log. For the full log, settings and metrics, open Step experiment details or Open in Log tab in the experiments page.
Run again runs the whole pipeline again from the start. Steps with cache on reuse earlier results when their code and inputs are the same. Running again from a specific step is not available.
- A run started from a saved pipeline runs again with the current workspace code (the same as Run in the list).
- A run built in code whose controller ran on a queue runs again with the same settings.
- For a run whose controller ran directly in a workspace process, the button is off.
Runs started from the UI also have Stop and Edit & run. Stopping also stops running steps. Edit & run loads this run into the editor so you can change it and start a new run.
In Build › Experiments a pipeline is folded into one controller row. Expand it to see the steps.