Files
dvc/tests/unit/repo/experiments/test_show.py
T
karajan1001 929de7c651 Solve the crash on getting name of applied experiment branch
fix: #8526
1. The current `get_names` will crash if an experiment branch had
   already been given a new branch name to it.

1. Solve the crash when we getting the name of a newly fixed experiment
   branch.
2. Add a new unit test to it.
2022-11-10 13:18:45 +08:00

28 lines
864 B
Python

from funcy import first
from scmrepo.git import Git
from dvc.repo.experiments.show import get_names
def test_get_show_branch(tmp_dir, scm: "Git", dvc, exp_stage):
new_branch = "new"
baseline = scm.get_rev()
base_branch = scm.active_branch()
results = dvc.experiments.run(exp_stage.addressing, params=["foo=2"])
exp_a = first(results)
dvc.experiments.branch(exp_a, new_branch)
scm.checkout(new_branch, force=True)
result = {
"workspace": {"baseline": {"data": {}}},
exp_a: {"baseline": {"data": {}}},
baseline: {"baseline": {"data": {}}, exp_a: {"data": {}}},
}
get_names(dvc, result)
assert result[exp_a]["baseline"]["data"] == {"name": new_branch}
assert result[baseline]["baseline"]["data"] == {"name": base_branch}
assert result[baseline][exp_a]["data"] == {"name": new_branch}