AILearn AI
LearnGlossarySources
ID/EN
Learn AI — open material for learning AIEvery lesson cites its original sources.
⚙ML Development & MLOps
  1. The ML development stack
  2. The ML lifecycle & MLOps maturity
  3. Experiment tracking with MLflow
  4. Model Registry, data versioning & lineage
  5. Deployment & model serving
  6. Monitoring, data drift & concept drift
  7. CI/CD, continuous training & feature stores
Modules
  1. ◎ AI Foundations
  2. ∿ Classical Machine Learning
  3. ⌬ Neural Networks
  4. ↘ Training Results & Evaluation
  5. ▦ Deep Learning Architectures
  6. ✎ Large Language Models
  7. ◐ Image Generation
  8. ♪ Audio & Speech AI
  9. ◈ Multimodal, Video & 3D
  10. ↻ Reinforcement Learning
  11. ⚙ ML Development & MLOps
  12. ★ Advanced & Frontier Topics
Learn/ML Development & MLOps

Model Registry, data versioning & lineage

Register model versions in MLflow, promote them with aliases like `@champion` (stages are deprecated), version datasets with DVC, and connect code, data, run and model into one lineage.

Intermediate~22 min·4 references
Key terms
Model registryMLflowData versioningDVC (Data Version Control)ArtifactReproducibilityRun

Experiment tracking answers “what did I try?”. A [[model-registry]] answers “which model is in production right now, which one was before, and where did it come from?”. [[data-versioning]] answers “exactly which data was it trained on?”. Together they give lineage: from a prediction in production you can walk back to the model version, the training run, the code commit and the data snapshot.

≈
App releases and their release notes
Your phone's app store keeps every version of an app (1.0, 1.1, 2.0), labels which is current, and can roll back. The release notes say what changed. A model registry does the same for models, and DVC is like keeping the exact ingredients list for each release — without stuffing the warehouse into Git.

What must be versioned

ThingToolIdentifier
Code & configsGitcommit SHA
DataDVC (or lakeFS, Delta Lake time travel…)content hash (md5) in a .dvc / dvc.lock file
ExperimentMLflow Trackingrun_id
ModelMLflow Model Registryname + version number (+ aliases)
Environmentlock file, Docker imageimage digest

1. MLflow Model Registry

A registered model is a named entry (e.g. churn-clf). Each time you register a logged model under that name it gets an auto-incrementing version (1, 2, 3…). A version can carry tags (validation_status=approved) and aliases — mutable, named pointers such as champion or challenger that point to exactly one version. Serving code loads models:/churn-clf@champion; promoting a new model is just moving the alias, and rollback is moving it back[1][4].

python
import mlflow
from mlflow import MlflowClient

mlflow.set_tracking_uri("http://127.0.0.1:5000")

# (a) register while logging
with mlflow.start_run() as run:
    model.fit(X_train, y_train)
    info = mlflow.sklearn.log_model(
        model, name="model",                    # MLflow 2.x: artifact_path="model"
        input_example=X_train[:5],
        registered_model_name="churn-clf",      # creates version N+1
    )

# (b) or register an already-logged model afterwards
mv = mlflow.register_model(info.model_uri, "churn-clf")
print(mv.name, mv.version)

client = MlflowClient()
client.set_registered_model_alias("churn-clf", "champion", mv.version)
client.set_model_version_tag("churn-clf", mv.version, "validation_status", "approved")

# Serving / batch code never hard-codes a version number:
champion = mlflow.pyfunc.load_model("models:/churn-clf@champion")
preds = champion.predict(X_new)

# Look up which version the alias points to
print(client.get_model_version_by_alias("churn-clf", "champion").version)
Two ways to register, then promote with an alias
i
Stages are deprecated — use aliases and tags
Older tutorials use fixed stages (None → Staging → Production → Archived) and client.transition_model_version_stage(...), loading models:/churn-clf/Production. Since MLflow 2.9 model stages are deprecated (scheduled for removal in a future major release). The recommended replacements are aliases for deployment pointers (@champion, @challenger) and tags for status; environments such as dev/staging/prod are better separated with different registered models or workspaces/catalogs, not stages[1]. Aliases are more flexible: you can define as many as you need, and one version can hold several.
Old (stages)New (aliases & tags)
transition_model_version_stage(name, v, "Production")set_registered_model_alias(name, "champion", v)
models:/churn-clf/Productionmodels:/churn-clf@champion
Stage Staging as a statusTag validation_status=pending or alias @challenger
Only 4 fixed stagesAny number of custom aliases

2. Versioning data with DVC

Git is bad at large binary files. [[dvc]] (Data Version Control) keeps the real files in a cache and a remote (S3, GCS, Azure, SSH, a shared drive…), and commits only a tiny .dvc pointer file containing the file's hash to Git. Checking out an old commit and running dvc checkout/dvc pull restores exactly the data that went with it[2][3].

bash
git init && dvc init                  # creates .dvc/ ; commit it
dvc add data/raw/churn.csv              # -> data/raw/churn.csv.dvc (hash) + adds file to .gitignore
git add data/raw/churn.csv.dvc data/raw/.gitignore
git commit -m "Track raw churn data v1"

dvc remote add -d storage s3://my-bucket/dvc-store   # -d = default remote
git commit -am "Configure DVC remote"
dvc push                                # upload data to the remote

# a teammate / CI machine:
git clone <repo> && cd <repo>
dvc pull                                # download the exact data for this commit

# new data version
cp new_export.csv data/raw/churn.csv
dvc add data/raw/churn.csv && git commit -am "Data v2" && dvc push

DVC can also describe the pipeline in dvc.yaml as stages with dependencies (deps), outputs (outs), params and metrics. dvc repro re-runs only the stages whose inputs changed, and dvc.lock records the hashes of everything — a lightweight, Git-friendly lineage record.

yaml
stages:
  prepare:
    cmd: python src/data.py data/raw/churn.csv data/processed
    deps:
      - src/data.py
      - data/raw/churn.csv
    outs:
      - data/processed
  train:
    cmd: python src/train.py
    deps:
      - src/train.py
      - data/processed
    params:
      - train.lr
      - train.n_estimators
    outs:
      - models/model.pkl
    metrics:
      - metrics.json:
          cache: false
dvc.yaml — a two-stage pipeline

3. Lineage: tie it all together

  • Log the git commit and the DVC data hash as MLflow tags on every training run.
  • Register the model from that run — the model version keeps a link to its run_id.
  • Log the model version (or alias resolution) with every prediction in production logs.
  • Result: prediction → model version → run → commit + data hash → reproducible training.
python
import subprocess, yaml, mlflow

commit = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
data_md5 = yaml.safe_load(open("data/raw/churn.csv.dvc"))["outs"][0]["md5"]

with mlflow.start_run():
    mlflow.set_tags({"git_commit": commit, "data_md5": data_md5})
    ...  # train, log metrics, log_model(registered_model_name="churn-clf")
knobalias promotion policy (champion / challenger)
What it is
The rule that decides when the @champion alias moves to a new version (manual approval, automatic after passing tests, after an A/B test…).
↑ If you increase it
More automation = faster, more frequent updates, but a weak quality gate can promote a bad model.
↓ If you decrease it
More manual review = safer, but models go stale and people become the bottleneck.
Typical values
Automatic @challenger, human or A/B-gated move to @champion.
knobregister_model(await_registration_for=…)
What it is
Seconds mlflow.register_model waits for the new version to become READY before returning.
↑ If you increase it
Safer in scripts that immediately set an alias or load the version; the call may block longer.
↓ If you decrease it
0 returns immediately — the version may still be PENDING_REGISTRATION on some backends.
Typical values
Default 300 s.
knobDVC cache.type (reflink / hardlink / symlink / copy)
What it is
How DVC places files from its cache into your workspace.
↑ If you increase it
Links (reflink/hardlink/symlink) avoid duplicating huge datasets on disk and make checkouts instant; hard/symlinks must not be edited in place (DVC protects them).
↓ If you decrease it
copy is the most compatible and safe to edit, but doubles disk usage and is slow for big data.
Typical values
Default reflink,copy; switch to links for multi-GB datasets.
!
Versioning pitfalls
• Serving code that loads models:/churn-clf/3 — a hard-coded version means every release needs a code change; use an alias. • Using stages in new projects — they are deprecated. • dvc add without dvc push → teammates' dvc pull fails. • Editing a dataset in place without re-running dvc add → Git and data silently disagree. • Registering models without the training run link, signature or data hash → no lineage when something goes wrong.
▸Go deeper: model cards and governance

Beyond versions, mature teams attach documentation to each registered model: intended use, training data summary, evaluation results per slice, known limitations and ethical considerations — the “model card” idea (Mitchell et al., 2019). Registries in managed platforms (e.g. Databricks Unity Catalog, SageMaker, Vertex AI) add access control and audit logs. The core pattern is always the same: immutable versions + movable pointers + metadata linking back to code and data.

Quiz

1.
A new model version passes all checks. What is the recommended way (MLflow ≥ 2.9) to make the serving service use it?
2.
What does dvc add data/raw/churn.csv commit to Git?
3.
A teammate clones the repo and gets “missing cache files” from dvc pull. Most likely cause?
4.
Which set of identifiers gives full lineage for a production prediction?
5.
In a dvc.yaml pipeline, you only edit src/train.py. What does dvc repro do?
Score: 0/5

References

  1. [1]
    MLflow Model Registry
    DocsMLflowmlflow.org
    Aliases, tags, and the deprecation of stages.
  2. [2]
    DVC — Get Started: Data Versioning
    DocsIterative / DVCdoc.dvc.org
  3. [3]
    DVC documentation
    DocsIterative / DVCdoc.dvc.org
  4. [4]
    mlflow.client — MlflowClient API
    DocsMLflowmlflow.org
← Previous
Experiment tracking with MLflow
Next →
Deployment & model serving