exp save: Include LOCK_FILE

This commit is contained in:
David de la Iglesia Castro
2023-04-03 10:33:52 +02:00
parent 649ee67e4b
commit 3a2259821b
2 changed files with 23 additions and 1 deletions
+5
View File
@@ -265,6 +265,7 @@ class BaseExecutor(ABC):
force: bool = False,
include_untracked: Optional[List[str]] = None,
) -> ExecutorResult:
from dvc.dvcfile import LOCK_FILE
from dvc.repo import Repo
exp_hash: Optional[str] = None
@@ -283,6 +284,10 @@ class BaseExecutor(ABC):
include_untracked.extend(
dvc.index._plot_sources # pylint: disable=protected-access
)
# dvc repro automatically stages dvc.lock. Running redundant `git add`
# on it causes an error when exiting the detached head context.
if LOCK_FILE in dvc.scm.untracked_files():
include_untracked.append(LOCK_FILE)
try:
stages = dvc.commit([], force=True, relink=False)
+18 -1
View File
@@ -134,5 +134,22 @@ def test_untracked_top_level_files_are_included_in_exp(tmp_dir, scm, dvc):
dvc.reproduce(stage.addressing)
exp = dvc.experiments.save()
fs = scm.get_fs(exp)
for file in ["metrics.json", "params.yaml", "plots.csv"]:
for file in ["metrics.json", "params.yaml", "plots.csv", "dvc.lock"]:
assert fs.exists(file)
def test_untracked_dvclock_is_included_in_exp(tmp_dir, scm, dvc):
stage = dvc.stage.add(
cmd="echo foo",
name="foo",
)
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
dvc.reproduce(stage.addressing)
# dvc.reproduce automatically stages `dvc.lock`
# force it to be untracked
scm.reset()
exp = dvc.experiments.save()
fs = scm.get_fs(exp)
assert fs.exists("dvc.lock")