Sub topic 6
Artifacts, dataset versions, and model registries
Earlier chapters covered the data model for runs, parameters, and metrics. This chapter covers the files a run produces or consumes, and how trackers turn those files into versioned, traceable objects. It assumes you can train a model in Python, know the run, parameter, and metric vocabulary from the data model chapter, and have read the MLflow and Weights & Biases architecture chapters. You should also be comfortable with the idea of a server that stores metadata and a separate store that holds large files.
Three related ideas
Three terms are easy to confuse.
- An artifact is any file or directory a run writes or reads: a serialized model, a confusion-matrix image, a feature list, a sample of the training data.
- A dataset version is an identifier for the exact data a run used. It can be a content hash, a version number, or a pointer to storage plus a date.
- A model registry is a catalog of models that have been promoted from experiments. It gives each model a name, numbered versions, and labels such as "production" that deployment code can look up.
Metrics tell you which run was best. Artifacts and registries let you reproduce that run and ship its model. A tracker that logs metrics well but stores artifacts loosely leaves you with a good number and no way to rebuild what produced it.
Artifacts in MLflow
In MLflow, artifacts belong to a run. The tracking server records only the artifact location, and the files live in the artifact store you configured (local disk, S3, Azure Blob, GCS, and others). You write to them with log_artifact for one file or log_artifacts for a directory.
import json
import mlflow
mlflow.set_tracking_uri("http://127.0.0.1:5000")
mlflow.set_experiment("churn-model")
with mlflow.start_run(run_name="baseline"):
features = ["tenure", "plan", "support_calls"]
with open("features.json", "w") as f:
json.dump(features, f)
mlflow.log_artifact("features.json", artifact_path="metadata")The file lands under metadata/ in that run's artifact location. Nothing is deduplicated: if ten runs log the same 2 GB file, you store it ten times. MLflow treats an artifact as a run attachment, not as an independent versioned object.
Dataset tracking in MLflow
MLflow offers mlflow.log_input with a dataset object. It records the dataset's name, a digest (a hash of its contents), and its source against the run. The digest is the useful part: two runs with the same digest used the same data.
import mlflow
import pandas as pd
df = pd.read_csv("churn_2026-11-01.csv")
dataset = mlflow.data.from_pandas(
df, source="s3://ml-data/churn/2026-11-01.csv", name="churn", targets="churned"
)
with mlflow.start_run():
mlflow.log_input(dataset, context="training")This records the data's identity but does not copy or store it. If someone overwrites the file at that S3 path, the digest in old runs will no longer match what is there, and nothing will warn you. Treat the source path as a pointer and keep the underlying data immutable, or use a data versioning tool alongside the tracker.
The MLflow model registry
MLflow's registry sits on the tracking server and needs a database-backed backend store. A plain local file store is not enough for the registry in a shared setup, so start the server with a database:
mlflow server \
--host 127.0.0.1 --port 5000 \
--backend-store-uri sqlite:///mlflow.db \
--default-artifact-root ./mlartifactsThe registry has three layers:
- A registered model is a name, such as
churn-classifier. - A model version is a numbered snapshot (1, 2, 3) that points at a logged model in a run.
- An alias is a movable label, such as
champion, that points at one version.
import mlflow
from mlflow import MlflowClient
from sklearn.linear_model import LogisticRegression
mlflow.set_tracking_uri("http://127.0.0.1:5000")
mlflow.set_experiment("churn-model")
with mlflow.start_run() as run:
model = LogisticRegression().fit([[0], [1], [2], [3]], [0, 0, 1, 1])
mlflow.sklearn.log_model(model, "model")
result = mlflow.register_model(f"runs:/{run.info.run_id}/model", "churn-classifier")
client = MlflowClient()
client.set_registered_model_alias("churn-classifier", "champion", result.version)
loaded = mlflow.pyfunc.load_model("models:/churn-classifier@champion")Serving code loads models:/churn-classifier@champion and never mentions a run ID. To promote a new model, you move the alias to a new version, and consumers pick it up on the next load with no code change. Older MLflow versions used fixed stages (Staging, Production, Archived). Those stages are deprecated in favor of aliases and tags, so use aliases in new work.
The registered model keeps a link back to the source run, so you can walk from a production model to its parameters, metrics, and dataset digest. That lineage works only if the training run logged those things.
Artifacts in Weights & Biases
Weights & Biases (W&B) treats an artifact as a first-class, versioned object that exists independently of any single run. You create an Artifact with a name and a type, add files, and log it. A run can also declare an artifact as an input with use_artifact.
import wandb
run = wandb.init(project="churn-model", job_type="dataset-upload")
data = wandb.Artifact(
name="churn-data",
type="dataset",
description="Churn snapshot from 2026-11-01",
metadata={"rows": 48210, "snapshot": "2026-11-01"},
)
data.add_file("churn_2026-11-01.csv")
run.log_artifact(data, aliases=["latest", "nov-2026"])
run.finish()
run = wandb.init(project="churn-model", job_type="train")
used = run.use_artifact("churn-data:nov-2026")
local_dir = used.download()
run.finish()Three behaviors matter here.
- Content-based versioning. W&B hashes the artifact's contents. Logging identical content again does not create a new version. Changed content creates
v1,v2, and so on automatically. - Aliases.
latestmoves to the newest version automatically. Custom aliases likenov-2026point at a specific version, and you can reassign them. - Lineage. Because runs log and use artifacts, W&B can draw a graph of which dataset fed which training run, which produced which model. You get dataset-to-model lineage without extra bookkeeping, provided every step goes through
log_artifactanduse_artifact.
References for large data
Copying a terabyte into a tracker is rarely what you want. W&B lets you track references: the artifact stores URIs and checksums, and the bytes stay in your bucket.
data = wandb.Artifact("churn-data-ref", type="dataset")
data.add_reference("s3://ml-data/churn/2026-11-01/")Reference tracking records the object's ETag or version ID at logging time, so a later overwrite is detectable if the bucket has versioning enabled. Without bucket versioning, a reference can still point at changed data. The tracker cannot protect data it does not hold.
W&B registry
W&B also provides a registry for promoting artifacts. You link a specific artifact version into a registry collection, for example a collection of models named churn-classifier, and then assign aliases there such as production. The link does not copy the files. The registry entry is a second name for the same stored version. W&B has changed its registry product over time (an earlier "Model Registry" was replaced by a more general "Registry"), so check the current docs for exact call names before scripting against it.
How the two approaches differ
The diagram shows the shared flow. The difference is where each tool places the versioning.
| Concern | MLflow | Weights & Biases |
|---|---|---|
| Artifact ownership | Attached to one run | Independent versioned object, shared by many runs |
| Deduplication | None, each log stores a copy | Content hashing, identical content is one version |
| Dataset identity | Digest and source via `log_input` | Artifact version, optionally with references |
| Lineage | Run to registered model | Graph across datasets, runs, and models |
| Promotion labels | Aliases and tags on model versions | Aliases on artifact versions and registry links |
| Where bytes live | Your artifact store | W&B storage, or your bucket via references |
MLflow gives you simple, storage-agnostic primitives and leaves dataset versioning discipline to you. W&B gives you more built-in lineage, with the cost that the version history lives in its service (hosted or self-managed).
Edge cases and common errors
- Registry on a file store. If
register_modelfails or the registry tab is empty, check that the server uses a database backend store, not a plain directory. - Artifact store not reachable by clients. In MLflow, the client often uploads artifacts directly to the artifact store. A laptop that can reach the tracking server but has no S3 credentials will log params fine and fail on
log_model. Either grant credentials or run the server with artifact proxying (--serve-artifacts). - Mutable data behind a stable name. Both tools record pointers. If
s3://.../latest.csvchanges, a run's "dataset" is no longer what it trained on. Use dated or hash-named paths. - Promotion without evaluation. An alias is only a label. Nothing stops you from pointing
championat an unvalidated version. Put the check in your pipeline, not in the registry. - Storage growth. Per-run artifact copies in MLflow and many W&B versions both accumulate. Set retention rules and delete artifacts of runs you will never reproduce.
- Models logged but not registered. A model logged inside a run is just an artifact. Until it is registered, no alias or version number exists for deployment to use.
Choosing on artifact and registry needs
Ask these questions about your own workflow:
- Do several runs and teams share the same dataset or model files? If yes, W&B's shared, deduplicated artifacts help. In MLflow you would need to point many runs at one stored path yourself.
- Does data have to stay inside your network? Both tools support references or self-hosted storage, but check how each handles credentials.
- Do you need a deployment-facing catalog with an approval step? Both offer aliases and tags. Neither replaces a review process.
- Do you already use a data versioning tool? If so, log its commit hash or version as a tag or artifact metadata and keep the tracker's role small.
If your registry needs are modest (one team, a few models), MLflow's alias-based registry is enough. If lineage across many datasets and models is the pain point, W&B's artifact graph addresses it directly. Later chapters on lock-in cover how to keep your serving code independent of either choice.
Exercise
Your training script logs a model with MLflow, and serving code loads it using the URI runs:/abc123/model. A teammate retrains and wants to ship the new model without redeploying the service. What should you change, and what must the MLflow server have?
Show answer
Register the model under a name (for example churn-classifier) with mlflow.register_model, set an alias such as champion on the current version, and change the serving code to load models:/churn-classifier@champion. After retraining, register the new version and move the alias to it. The service picks up the new model on its next load, with no code change. The MLflow server needs a database-backed backend store (such as SQLite or PostgreSQL) for the registry to work.
Exercise
A W&B run logs the same dataset file twice, once from each of two training jobs. How many artifact versions exist afterward, and why? What happens if the second job logs a file with one changed row?
Show answer
One version exists, because W&B versions artifacts by content hash and identical content does not create a new version. The second job still records the artifact as an input or output in its lineage. With one changed row, the hash differs, so W&B creates a new version (v1) and moves the latest alias to it.