exp run: fix failure when dependencies are from inside submodules (#10831)

This commit is contained in:
skshetry
2025-08-06 21:07:07 +05:45
committed by GitHub
parent 396e71f30c
commit e619b6dccd
6 changed files with 62 additions and 9 deletions
@@ -793,3 +793,18 @@ def test_custom_commit_message(tmp_dir, scm, dvc, tmp):
)
)
assert scm.resolve_commit(exp).message == "custom commit message"
@pytest.mark.parametrize("dep", ["submodule", "submodule/file"])
def test_experiments_run_with_submodule_dependencies(dvc, scm, make_tmp_dir, dep):
external_repo = make_tmp_dir("external_repo", scm=True)
external_repo.scm_gen("file", "content", commit="add file")
submodules = scm.pygit2.repo.submodules
submodules.add(os.fspath(external_repo), "submodule")
submodules.update(init=True)
scm.add_commit([".gitmodules"], message="add submodule")
dvc.stage.add(cmd="echo foo", deps=[dep], name="foo")
assert dvc.experiments.run()
+3 -3
View File
@@ -39,7 +39,7 @@ def test_scm_track_changed_files(scm_context):
scm_context.track_file("foo")
scm_context.track_changed_files()
scm_context.scm.add.assert_called_once_with({"foo"})
scm_context.scm.add.assert_called_once_with(["foo"])
def test_ignore(scm_context):
@@ -73,7 +73,7 @@ def test_scm_context_autostage_changed_files(scm_context):
assert not scm_context.files_to_track
assert not scm_context.ignored_paths
scm_context.scm.add.assert_called_once_with({"foo"})
scm_context.scm.add.assert_called_once_with(["foo"])
def test_scm_context_clears_ignores_on_error(scm_context):
@@ -141,4 +141,4 @@ def test_scm_context_decorator(scm_context, mocker):
method = mocker.MagicMock(wraps=test_method)
decorator(method, autostage=True)(repo, "arg", kw=1)
method.assert_called_once_with(repo, "arg", kw=1)
scm_context.scm.add.assert_called_once_with({"foo"})
scm_context.scm.add.assert_called_once_with(["foo"])