exp: use exp baseline for DVC commands that compare to HEAD during exp run (#5818)

* exp: add util method for getting baseline HEAD during run

* exp: use baseline for dvc commands which compare to HEAD during exp run

* add test for new util method

* update plots diff test mock
This commit is contained in:
Peter Rowlands (변기호)
2021-04-19 14:42:58 +09:00
committed by GitHub
parent daf07451f8
commit 60ea24410e
10 changed files with 65 additions and 13 deletions
@@ -611,3 +611,16 @@ def test_checkout_targets_deps(tmp_dir, scm, dvc, exp_stage):
assert (tmp_dir / "foo").exists()
assert (tmp_dir / "foo").read_text() == "foo"
assert not (tmp_dir / "bar").exists()
@pytest.mark.parametrize("tail", ["", "~1", "^"])
def test_fix_exp_head(tmp_dir, scm, tail):
from dvc.repo.experiments.base import EXEC_BASELINE
from dvc.repo.experiments.utils import fix_exp_head
head = "HEAD" + tail
assert head == fix_exp_head(scm, head)
scm.set_ref(EXEC_BASELINE, "refs/heads/master")
assert EXEC_BASELINE + tail == fix_exp_head(scm, head)
assert "foo" + tail == fix_exp_head(scm, "foo" + tail)