-
Notifications
You must be signed in to change notification settings - Fork 1.3k
repro: check for hash mismatch between deleted dependencies and upstream outputs. #9533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
efiop
merged 1 commit into
main
from
9530-allow-missing-skips-stages-even-if-deps-have-changed
Jun 13, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Empty file.
File renamed without changes.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| from dvc.utils.fs import remove | ||
|
|
||
|
|
||
| def test_repro_allow_missing(tmp_dir, dvc): | ||
| tmp_dir.gen("fixed", "fixed") | ||
| dvc.stage.add(name="create-foo", cmd="echo foo > foo", deps=["fixed"], outs=["foo"]) | ||
| dvc.stage.add(name="copy-foo", cmd="cp foo bar", deps=["foo"], outs=["bar"]) | ||
| (create_foo, copy_foo) = dvc.reproduce() | ||
|
|
||
| remove("foo") | ||
| remove(create_foo.outs[0].cache_path) | ||
| remove(dvc.stage_cache.cache_dir) | ||
|
|
||
| ret = dvc.reproduce(allow_missing=True) | ||
| # both stages are skipped | ||
| assert not ret | ||
|
|
||
|
|
||
| def test_repro_allow_missing_and_pull(tmp_dir, dvc, mocker, local_remote): | ||
| tmp_dir.gen("fixed", "fixed") | ||
| dvc.stage.add(name="create-foo", cmd="echo foo > foo", deps=["fixed"], outs=["foo"]) | ||
| dvc.stage.add(name="copy-foo", cmd="cp foo bar", deps=["foo"], outs=["bar"]) | ||
| (create_foo,) = dvc.reproduce("create-foo") | ||
|
|
||
| dvc.push() | ||
|
|
||
| remove("foo") | ||
| remove(create_foo.outs[0].cache_path) | ||
| remove(dvc.stage_cache.cache_dir) | ||
|
|
||
| ret = dvc.reproduce(pull=True, allow_missing=True) | ||
| # create-foo is skipped ; copy-foo pulls missing dep | ||
| assert len(ret) == 1 | ||
|
|
||
|
|
||
| def test_repro_allow_missing_upstream_stage_modified( | ||
| tmp_dir, dvc, mocker, local_remote | ||
| ): | ||
| """https://github.com/iterative/dvc/issues/9530""" | ||
| tmp_dir.gen("params.yaml", "param: 1") | ||
| dvc.stage.add( | ||
| name="create-foo", cmd="echo ${param} > foo", params=["param"], outs=["foo"] | ||
| ) | ||
| dvc.stage.add(name="copy-foo", cmd="cp foo bar", deps=["foo"], outs=["bar"]) | ||
| dvc.reproduce() | ||
|
|
||
| dvc.push() | ||
|
|
||
| tmp_dir.gen("params.yaml", "param: 2") | ||
| (create_foo,) = dvc.reproduce("create-foo") | ||
| dvc.push() | ||
| remove("foo") | ||
| remove(create_foo.outs[0].cache_path) | ||
|
|
||
| ret = dvc.reproduce(pull=True, allow_missing=True) | ||
| # create-foo is skipped ; copy-foo pulls modified dep | ||
| assert len(ret) == 1 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import os | ||
|
|
||
| from dvc.stage.cache import RunCacheNotSupported | ||
| from dvc.utils.fs import remove | ||
|
|
||
|
|
||
| def test_repro_pulls_mising_data_source(tmp_dir, dvc, mocker, local_remote): | ||
| (foo,) = tmp_dir.dvc_gen("foo", "foo") | ||
|
|
||
| dvc.push() | ||
|
|
||
| dvc.stage.add(name="copy-foo", cmd="cp foo bar", deps=["foo"], outs=["bar"]) | ||
| remove("foo") | ||
| remove(foo.outs[0].cache_path) | ||
|
|
||
| assert dvc.reproduce(pull=True) | ||
|
|
||
|
|
||
| def test_repro_pulls_mising_import(tmp_dir, dvc, mocker, erepo_dir, local_remote): | ||
| with erepo_dir.chdir(): | ||
| erepo_dir.dvc_gen("foo", "foo", commit="first") | ||
|
|
||
| foo_import = dvc.imp(os.fspath(erepo_dir), "foo") | ||
|
|
||
| dvc.push() | ||
|
|
||
| dvc.stage.add(name="copy-foo", cmd="cp foo bar", deps=["foo"], outs=["bar"]) | ||
| remove("foo") | ||
| remove(foo_import.outs[0].cache_path) | ||
|
|
||
| assert dvc.reproduce(pull=True) | ||
|
|
||
|
|
||
| def test_repro_pulls_continue_without_run_cache(tmp_dir, dvc, mocker, local_remote): | ||
| (foo,) = tmp_dir.dvc_gen("foo", "foo") | ||
|
|
||
| dvc.push() | ||
| mocker.patch.object( | ||
| dvc.stage_cache, "pull", side_effect=RunCacheNotSupported("foo") | ||
| ) | ||
| dvc.stage.add(name="copy-foo", cmd="cp foo bar", deps=["foo"], outs=["bar"]) | ||
| remove("foo") | ||
| remove(foo.outs[0].cache_path) | ||
|
|
||
| assert dvc.reproduce(pull=True) | ||
|
|
||
|
|
||
| def test_repro_skip_pull_if_no_run_cache_is_passed(tmp_dir, dvc, mocker, local_remote): | ||
| (foo,) = tmp_dir.dvc_gen("foo", "foo") | ||
|
|
||
| dvc.push() | ||
| spy_pull = mocker.spy(dvc.stage_cache, "pull") | ||
| dvc.stage.add(name="copy-foo", cmd="cp foo bar", deps=["foo"], outs=["bar"]) | ||
| remove("foo") | ||
| remove(foo.outs[0].cache_path) | ||
|
|
||
| assert dvc.reproduce(pull=True, run_cache=False) | ||
| assert not spy_pull.called |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not pretty but I don't see any alternative