Final project: a pipeline from data to scored orders

DevOps, Hands On45 minutesFreeSteps checked 23 November 2026By Cloud Hands On

In this task you'll run the whole flow as one pipeline: drift check, train with a gate, compare, promote and score.

The final project joins every piece into one pipeline that stops at the first failed stage: check new data for drift, train a challenger with a quality gate, compare it with the champion on recent holdout data, promote only if it's better, then batch score today's orders with whatever is champion.

This is the shape of real MLOps pipelines, whether they run as a script, a GitHub workflow or an Azure ML pipeline: small stages, each with a clear pass or fail, every model traceable to its data and settings, and a person able to roll back with one alias move.

Example. SS Kaiser runs this pipeline every Sunday night. Most weeks it keeps the champion; twice this year it promoted a retrained model after a change in couriers, and once the gate stopped a model trained on a broken export.

Before you start

You need: Python 3.10 or newer, and about 500 MB of disk for MLflow and scikit-learn. No cloud account. Time: 45 minutes.

Where to look

  1. mlops folder
  2. pipeline.py
  3. MLflow UI
  4. Models
  5. predictions.csv

Steps

  1. Save pipeline.py from Commands in the mlops folder, next to the other scripts.
  2. Run it on the new month: python pipeline.py data/orders_new.csv data/holdout_new.csv data/next_month.csv. Read each stage: drift found, gate passed, the comparison, then scoring.Drift (exit code 2) is treated as a reason to carry on and retrain, not a failure.
  3. In pipeline.py, add "--min-auc", "0.99" to the train stage's command and run again: the pipeline stops at train and gate, and nothing is registered or scored.
  4. Put the gate back. In the MLflow UI, follow @champion to its version, its run, its parameters and its data_sha256 tag.That chain is what you show an auditor or a worried manager.
  5. Roll back @champion to the previous version, run batch_score.py, and see the version column change.

Commands

# pipeline.py: the final project. Runs every stage in order and stops at the first one that fails, like a CI pipeline.
#   python pipeline.py data/orders_new.csv data/holdout_new.csv data/next_month.csv
# Stages: check for drift -> train with a quality gate -> register as challenger -> compare and maybe promote -> batch score.
import subprocess, sys

new_train, holdout, to_score = (sys.argv[1:4] + ["data/orders.csv", "data/holdout.csv", "data/today.csv"][len(sys.argv) - 1:])[:3]
STAGES = [
    ("drift check", [sys.executable, "drift.py", "data/orders.csv", to_score], {0, 2}),   # 2 = drift: a reason to retrain, not a failure
    ("train and gate", [sys.executable, "train.py", "--data", new_train, "--register"], {0}),
    ("compare and promote", [sys.executable, "promote.py", "--holdout", holdout], {0}),
    ("batch score", [sys.executable, "batch_score.py", to_score, "predictions.csv"], {0}),
]
for name, cmd, ok in STAGES:
    print(f"\n=== {name}", flush=True)
    code = subprocess.run(cmd).returncode
    if code not in ok:
        print(f"PIPELINE STOPPED at '{name}' (exit code {code}). Later stages did not run.")
        sys.exit(1)
print("\nPIPELINE PASSED: the champion scored today's orders.")

# Run the whole flow on the new month
python pipeline.py data/orders_new.csv data/holdout_new.csv data/next_month.csv

Watch out for

Cost
Free.
Security
In a shared setting, only the pipeline's identity should be able to move @champion; people approve, the pipeline acts.
Common mistakes
A pipeline that carries on after a failed stage, and models nobody can trace back to their data.

Clean up

Delete the mlops folder, including .venv, mlflow.db and mlruns, when you've finished the section.

Words to know

Pipeline
Stages run in order, stopping at the first failure.
Stage
One step with a clear pass or fail result.
Champion and challenger
The model in use, and a new one that must beat it.
Rollback
Moving @champion back to the previous version.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going