Reproduction and cache
Quick answer
Reproduction rebuilds a pipeline when its declared dependencies change. The output cache retains content objects, while a run cache associates a previous computation signature with its outputs. Examples use standard-library Python; native DVC commands are not executed. ByteMind execution is unverified.
Identify a stale dependency
old={"data":"abc","code":"xyz"}; new={"data":"def","code":"xyz"}print(old!=new)Expected output (locally tested): True. A changed signature invalidates the prior computation.
How it works
dvc status inspects changes and dvc repro executes required stages in dependency order or restores compatible cached outputs. DVC run-cache behavior depends on flags and stage configuration. dvc checkout restores tracked data from available cache; dvc pull can fetch remote data and restore workspace files. These are not interchangeable operations. Use a clean working copy, inspect status and review commands; repro may delete stage outputs before running. The local teaching engine fingerprints canonical JSON input bytes, selected params and its source, checks cached objects before reuse, and writes outputs from fixed Python functions. It distinguishes SKIP for intact current outputs, RESTORE for a known signature with verified objects, and RUN for new signatures. If an upstream input changes but output bytes do not, downstream stages may remain valid. Undeclared environment changes, nondeterminism and external services break reproducibility assumptions; record runtime and seed and do not assume cache equality proves correctness.
Verify cached bytes before reuse
from hashlib import sha256b=b"model-v1"; key=sha256(b).hexdigest()print(sha256(b).hexdigest()==key,sha256(b"corrupt").hexdigest()==key)Expected output (locally tested): True False. A corrupted object must not be silently reused.
Common mistakes
Never assume cache existence proves integrity, or that changing an upstream file requires every downstream command to execute when output bytes are unchanged.
Practice and next steps
Run the local milestone twice, modify raw training bytes, then revert them. Explain why reuse can avoid computation while restoring the correct version.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Reproduction and cache — knowledge check
Apply reproduction and cache to small examples and debugging scenarios.
What does the run cache associate?
What does dvc repro do?
When can a downstream stage skip?
How should a corrupted object be handled?
Does a cached run prove reproducibility everywhere?