5.3.4 · D3MLOps & Deployment

Worked examples — Data versioning (DVC)

2,627 words12 min readBack to topic

Before we compute anything, let's earn the two words we lean on constantly.

Figure — Data versioning (DVC)

The scenario matrix

Every DVC question is really one of these cells. The "axis" is: did the content change, and where do the bytes physically live?

Cell Trigger What DVC does New bytes stored?
A. First add new file, dvc add hash it, move to cache, write pointer yes (full file)
B. No change dvc add on identical file same hash → nothing new no
C. Byte flip 1 byte edited, dvc add new hash → new full copy yes (full file)
D. Exact duplicate two files, same content same hash → stored once no (dedup)
E. Empty / 0-byte file dvc add empty file hashes the empty content tiny (still a hash)
F. Restore, cache has it git checkout + dvc checkout pointer → cache → workdir no (copy from cache)
G. Restore, cache empty fresh clone, dvc checkout pointer → cache miss → needs dvc pull fetched from remote
H. Pipeline skip dvc repro, deps unchanged dep hashes match → skip stage no
I. Word problem storage-cost estimate count distinct hashes × size arithmetic
J. Exam twist rename vs re-content content-hash blind to name depends

The 8 worked examples below cover all ten cells (some examples hit two).


Worked examples

Figure — Data versioning (DVC)
Figure — Data versioning (DVC)

Recap

Recall One-line answer per cell

Cell A — first add stores ::: a full copy in cache; Git gets the ~100-byte pointer. Cell B — re-add unchanged file stores ::: 0 new bytes (same hash). Cell C — 1-byte edit stores ::: a full new whole-file copy (new hash, avalanche). Cell D — two identical files store ::: one blob (deduplication). Cell E — a 0-byte file gets ::: a valid MD5 and a pointer; add succeeds. Cell F — checkout with cache hit ::: copies from cache to workdir, no remote call. Cell G — checkout with empty cache ::: restores nothing; fix with dvc pull first. Cell H — dvc repro with unchanged deps ::: skips the stage (make-like). Cell I — cost = ::: (distinct hashes) × size, not (snapshots) × size. Cell J — rename vs re-content ::: rename = 0 new bytes; new content = new blob; names never enter the hash.


Connections

  • Parent: Data Versioning (DVC) — the concepts these examples exercise.
  • Content-addressable storage — why identical content collapses to one blob (Cells B, D, J).
  • Git version control — Git moves the pointer; every restore example splits into a Git leg and a DVC leg.
  • Object storage (S3/GCS) — the remote in Cells G and 8.
  • MLOps pipelines — the dvc repro skip logic of Cell H.
  • Reproducibility in ML — the payoff of binding code-hash + data-hash per commit.
  • Experiment tracking (MLflow) — pairs with DVC for metric + data pinning.