fix(repro): record dependency hashes before running the stage command (#11058)#11062
Open
ChetanyaRathi wants to merge 2 commits into
Open
fix(repro): record dependency hashes before running the stage command (#11058)#11062ChetanyaRathi wants to merge 2 commits into
ChetanyaRathi wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11062 +/- ##
==========================================
+ Coverage 90.68% 90.98% +0.30%
==========================================
Files 504 505 +1
Lines 39795 41164 +1369
Branches 3141 3268 +127
==========================================
+ Hits 36087 37454 +1367
- Misses 3042 3071 +29
+ Partials 666 639 -27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…-run modifications (treeverse#11058)
c777e1d to
f162eb3
Compare
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11058.
Problem
dvc reprocomputes dependency hashes after the stage command finishes.If a dependency is modified while the command is running,
dvc.lockrecordsthe post-run hash, so the outputs get linked to the wrong version of the
inputs and the stage is incorrectly reported as unchanged (and skipped) on
the next run.
Fix
Snapshot dependency hashes before the command runs (in
_run_stage) anduse them when writing
dvc.lock. If a dependency changed during execution,the pre-run hash is kept and a warning is logged; because the recorded hash
then differs from the mutated workspace file, the stage is correctly reported
as changed on the next run and re-executed.
run()andsave()are unchanged — the logic lives in_run_stageandsave_deps, keyed byid(dep)so it is robust across regular deps and params.Note: dependencies are hashed twice per run (once for the snapshot, once in
the post-run
save). This is negligible for typical code/config deps and waskept for a small, obviously-correct diff. Happy to reuse the snapshot in the
post-run save instead if preferred.
Test
Added
test_repro_records_pre_run_dep_hashintests/func/repro/test_repro.py,which uses a self-mutating command to deterministically simulate a mid-run
dependency change and asserts the stage is reported as changed and re-runs.