Fix exp checkout queued and cleanup (#4914)

This commit is contained in:
Sami Jawhar
2020-11-20 09:16:12 +09:00
committed by GitHub
parent 153c374c02
commit 92b17e3a89
2 changed files with 23 additions and 6 deletions
+4 -1
View File
@@ -847,7 +847,7 @@ class Experiments:
self._scm_checkout(rev)
branch = self._get_branch_containing(rev)
m = self.BRANCH_RE.match(branch)
m = self.BRANCH_RE.match(branch) if branch else None
if m and m.group("checkpoint"):
kwargs.update({"allow_missing": True, "quiet": True})
@@ -874,6 +874,9 @@ class Experiments:
remove(tmp)
if dirty:
self._unstash_workspace()
args_file = os.path.join(self.repo.tmp_dir, self.PACKED_ARGS_FILE)
if os.path.exists(args_file):
remove(args_file)
if need_checkout:
dvc_checkout(self.repo, **kwargs)
+19 -5
View File
@@ -111,20 +111,34 @@ def test_modify_params(tmp_dir, scm, dvc, mocker, changes, expected):
).read_text().strip() == expected
def test_checkout(tmp_dir, scm, dvc, exp_stage):
results = dvc.experiments.run(exp_stage.addressing, params=["foo=2"])
@pytest.mark.parametrize("queue", [True, False])
def test_checkout(tmp_dir, scm, dvc, exp_stage, queue):
metrics_original = (tmp_dir / "metrics.yaml").read_text().strip()
results = dvc.experiments.run(
exp_stage.addressing, params=["foo=2"], queue=queue
)
exp_a = first(results)
results = dvc.experiments.run(exp_stage.addressing, params=["foo=3"])
results = dvc.experiments.run(
exp_stage.addressing, params=["foo=3"], queue=queue
)
exp_b = first(results)
dvc.experiments.checkout(exp_a)
assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 2"
assert (tmp_dir / "metrics.yaml").read_text().strip() == "foo: 2"
assert (
(tmp_dir / "metrics.yaml").read_text().strip() == metrics_original
if queue
else "foo: 2"
)
dvc.experiments.checkout(exp_b)
assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 3"
assert (tmp_dir / "metrics.yaml").read_text().strip() == "foo: 3"
assert (
(tmp_dir / "metrics.yaml").read_text().strip() == metrics_original
if queue
else "foo: 3"
)
def test_get_baseline(tmp_dir, scm, dvc, exp_stage):