mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-12-05 15:28:28 +01:00
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.
28 lines
864 B
Python
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}
|