Sub topic 18
Versioning Data and Models Next to the Environment
Assume you can use Git, read a lock file, and run a training job from the command line. This chapter adds data and model versioning to environment reproducibility.
A Python lock file records packages. A container records the operating-system layer and system libraries. Neither records the exact training data or model artifacts. A run can therefore use the same code and environment but produce a different result because the data changed.
What to version
Treat every training input and output as an artifact with an immutable version. An immutable artifact cannot change after publication. If the content changes, it receives a new version.
| Artifact | Record with the run |
|---|---|
| Training and validation data | Dataset version and content checksum |
| Model checkpoint | Model version, parent checkpoint, and checksum |
| Labels or feature definitions | Code revision and schema version |
| Environment | Git revision, lock-file revision, and image digest |
A checksum is a short value calculated from file contents. It lets you detect a changed file even when its filename is unchanged. Store large data and checkpoints in an artifact store, not usually in Git. Git should contain the small manifest that identifies them.
Keep a run manifest
Create one manifest for each training run. It should connect the source revision, environment, data, configuration, and output model. For example:
run_id: fraud-2026-11-30-001
git_commit: 7d91e2a
environment:
lock_file: requirements.lock
lock_sha256: 4c8b...e12a
image: registry.example.com/fraud-train@sha256:abc123...789
data:
training:
uri: s3://ml-data/fraud/v3
sha256: 91af...204c
validation:
uri: s3://ml-data/fraud-validation/v2
sha256: 0b27...8aa1
model:
output_uri: s3://ml-models/fraud/2026-11-30-001
parent: noneThe manifest is useful only if the referenced artifacts are retained and access-controlled. A URI without a stable version is not enough. A mutable path such as s3://ml-data/fraud/latest can silently point to different bytes later.
Follow the lineage
Lineage means recording how an output was made from inputs. During training, save the manifest beside the checkpoint and register both in the model registry or artifact store. When promoting a model, copy or reference the exact manifest rather than creating a new “production” label with no history.
Exercise
Why is a container image digest alone insufficient to reproduce a training run?
Show answer
It fixes the environment, but it does not identify the exact data, configuration, code revision, or model inputs used by the run.