A logged model isn’t a released model. The registry gives models versions and stages — Staging, Production, Archived — with an approval gate before anything ships.
Why: experiment runs are a messy history of everything you tried; the registry is the curated shortlist of models you actually promote — it adds versioning and lifecycle stages on top of a run’s artifact. When: register a model when it is a candidate for release, not for every run. Where: the registry is the single source of truth for "what is in production."
EXPERIMENT RUNS MODEL REGISTRY
every run you tried curated, versioned candidates
raw history lifecycle stages:
no lifecycle None -> Staging -> Production -> Archived
approval gate before Production
Register the good ones; the registry is what serving reads from.Why: registering promotes a run’s model artifact into a named, versioned entry in the registry — each new registration under the same name becomes version 2, 3, and so on. When: register the best run from a sweep, or register automatically at the end of a passing pipeline. Where: the name is how everything downstream (serving, CI) references the model, independent of which run produced it.
import mlflow
# Register the model from a specific run under a shared name:
result = mlflow.register_model(
model_uri=f"runs:/{best_run_id}/model",
name="churn-classifier",
)
print("registered version:", result.version) # 1, then 2, 3, ... on re-registerWhy: a registered model moves through stages — Staging for validation, Production for live traffic, Archived for retirement — and gating promotion to Production behind an approval is what prevents an untested model from shipping. When: transition to Staging automatically, to Production only after validation and sign-off. Where: archive retired versions rather than deleting them, so rollback is always possible.
from mlflow import MlflowClient
client = MlflowClient()
# Promote a validated version to Production (with an approval gate in your process):
client.transition_model_version_stage(
name="churn-classifier",
version=3,
stage="Production",
archive_existing_versions=True, # the old Production version -> Archived
)
# Archived, not deleted -> instant rollback if the new version misbehaves.