mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
exp run: git add param files that will be modified.
Only if they are currently untracked and `--temp` or `--queue` is passed. Closes #7842
This commit is contained in:
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@locked
|
||||
def run( # noqa: C901
|
||||
def run( # noqa: C901, PLR0912
|
||||
repo,
|
||||
targets: Optional[Iterable[str]] = None,
|
||||
params: Optional[Iterable[str]] = None,
|
||||
@@ -36,6 +36,18 @@ def run( # noqa: C901
|
||||
from dvc.utils.hydra import to_hydra_overrides
|
||||
|
||||
path_overrides = to_path_overrides(params)
|
||||
|
||||
if tmp_dir or queue:
|
||||
untracked = repo.scm.untracked_files()
|
||||
for path in path_overrides:
|
||||
if path in untracked:
|
||||
logger.debug(
|
||||
"'%s' is currently untracked but will be modified by DVC. "
|
||||
"Adding it to git.",
|
||||
path,
|
||||
)
|
||||
repo.scm.add([path])
|
||||
|
||||
hydra_sweep = any(
|
||||
x.is_sweep_override()
|
||||
for param_file in path_overrides
|
||||
|
||||
@@ -92,3 +92,19 @@ def test_queue_remove_done(
|
||||
assert set(celery_queue.clear(success=True)) == set(success_tasks[:2])
|
||||
|
||||
assert celery_queue.status() == []
|
||||
|
||||
|
||||
def test_queue_doesnt_remove_untracked_params_file(tmp_dir, dvc, scm):
|
||||
"""Regression test for https://github.com/iterative/dvc/issues/7842"""
|
||||
tmp_dir.gen("params.yaml", "foo: 1")
|
||||
stage = dvc.run(cmd="echo ${foo}", params=["foo"], name="echo-foo")
|
||||
scm.add(
|
||||
[
|
||||
"dvc.yaml",
|
||||
"dvc.lock",
|
||||
".gitignore",
|
||||
]
|
||||
)
|
||||
scm.commit("init")
|
||||
dvc.experiments.run(stage.addressing, params=["foo=2"], queue=True)
|
||||
assert (tmp_dir / "params.yaml").exists()
|
||||
|
||||
Reference in New Issue
Block a user