diff --git a/dvc/repo/experiments/executor/base.py b/dvc/repo/experiments/executor/base.py index 5e4f4fba4..b6365f606 100644 --- a/dvc/repo/experiments/executor/base.py +++ b/dvc/repo/experiments/executor/base.py @@ -681,7 +681,7 @@ class BaseExecutor(ABC): args, kwargs = cls.unpack_repro_args(args_path) remove(args_path) # explicitly git rm/unstage the args file - dvc.scm.add([args_path]) + dvc.scm.add([args_path], force=True) else: args = [] kwargs = {} diff --git a/dvc/repo/experiments/queue/base.py b/dvc/repo/experiments/queue/base.py index 39b65e993..e3921c33e 100644 --- a/dvc/repo/experiments/queue/base.py +++ b/dvc/repo/experiments/queue/base.py @@ -520,7 +520,7 @@ class BaseStashQueue(ABC): else: extra = None BaseExecutor.pack_repro_args(self.args_file, *args, extra=extra, **kwargs) - self.scm.add(self.args_file) + self.scm.add(self.args_file, force=True) @staticmethod def _format_new_params_msg(new_params, config_path): diff --git a/tests/func/experiments/test_experiments.py b/tests/func/experiments/test_experiments.py index ae9140d56..2031772c4 100644 --- a/tests/func/experiments/test_experiments.py +++ b/tests/func/experiments/test_experiments.py @@ -335,6 +335,7 @@ def test_packed_args_exists(tmp_dir, scm, dvc, exp_stage, caplog): with caplog.at_level(logging.WARNING): dvc.experiments.run(exp_stage.addressing) assert "Temporary DVC file" in caplog.text + assert not (tmp_dir / ".dvc" / "tmp" / BaseExecutor.PACKED_ARGS_FILE).exists() def test_list(tmp_dir, scm, dvc, exp_stage): @@ -744,3 +745,29 @@ def test_copy_paths_errors(tmp_dir, scm, dvc, mocker): with pytest.raises(DvcException, match="Unable to copy"): dvc.experiments.run(stage.addressing, tmp_dir=True, copy_paths=["foo"]) + + +def test_mixed_git_dvc_out(tmp_dir, scm, dvc, exp_stage): + (tmp_dir / "dir").mkdir() + dir_metrics = os.path.join("dir", "metrics.yaml") + dvc.stage.add( + cmd=f"python copy.py params.yaml {dir_metrics}", + metrics=[dir_metrics], + params=["foo"], + name="copy-file", + deps=["copy.py"], + force=True, + ) + dvc.stage.add( + cmd=f"python copy.py {dir_metrics} metrics.yaml", + metrics_no_cache=["metrics.yaml"], + name="copy-dir-file", + deps=["dir"], + ) + scm.add(["dvc.yaml", "dvc.lock"]) + scm.commit("add dir stage") + + exp = first(dvc.experiments.run()) + assert (tmp_dir / "dir" / "metrics.yaml").exists() + git_fs = scm.get_fs(exp) + assert not git_fs.exists("dir/metrics.yaml")