diff --git a/dvc/repo/reproduce.py b/dvc/repo/reproduce.py index 4df426bd74..95474e9320 100644 --- a/dvc/repo/reproduce.py +++ b/dvc/repo/reproduce.py @@ -64,7 +64,9 @@ def _get_stage_files(stage: "Stage") -> typing.Iterator[str]: if ( not dep.use_scm_ignore and dep.is_in_repo - and not stage.repo.dvcfs.isdvc(dep.fs_path) + and not stage.repo.dvcfs.isdvc( + stage.repo.dvcfs.from_os_path(str(dep)) + ) ): yield dep.fs_path for out in stage.outs: diff --git a/tests/unit/repo/test_reproduce.py b/tests/unit/repo/test_reproduce.py index 3e5a440f26..200521aa1b 100644 --- a/tests/unit/repo/test_reproduce.py +++ b/tests/unit/repo/test_reproduce.py @@ -1,3 +1,8 @@ +import os + +from dvc.repo.reproduce import _get_stage_files + + def test_number_reproduces(tmp_dir, dvc, mocker): reproduce_stage_mock = mocker.patch( "dvc.repo.reproduce._reproduce_stage", returns=[] @@ -22,3 +27,42 @@ def test_number_reproduces(tmp_dir, dvc, mocker): dvc.reproduce(all_pipelines=True) assert reproduce_stage_mock.call_count == 5 + + +def test_get_stage_files(tmp_dir, dvc): + tmp_dir.dvc_gen("dvc-dep", "dvc-dep") + tmp_dir.gen("other-dep", "other-dep") + + stage = dvc.stage.add( + name="stage", + cmd="foo", + deps=["dvc-dep", "other-dep"], + outs=["dvc-out"], + outs_no_cache=["other-out"], + ) + result = set(_get_stage_files(stage)) + assert result == { + stage.dvcfile.relpath, + str(tmp_dir / "other-dep"), + str(tmp_dir / "other-out"), + } + + +def test_get_stage_files_wdir(tmp_dir, dvc): + tmp_dir.gen({"dir": {"dvc-dep": "dvc-dep", "other-dep": "other-dep"}}) + dvc.add(os.path.join("dir", "dvc-dep")) + + stage = dvc.stage.add( + name="stage", + cmd="foo", + wdir="dir", + deps=["dvc-dep", "other-dep"], + outs=["dvc-out"], + outs_no_cache=["other-out"], + ) + result = set(_get_stage_files(stage)) + assert result == { + stage.dvcfile.relpath, + str(tmp_dir / "dir" / "other-dep"), + str(tmp_dir / "dir" / "other-out"), + }