mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
exp save: Include LOCK_FILE
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user