Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions dvc/repo/experiments/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ def _collect_experiment_commit(
for refspec in ["refs/tags", "refs/heads"]:
name = repo.scm.describe(rev, base=refspec)
if name:
name = name.replace(f"{refspec}/", "")
break
if not name:
name = repo.experiments.get_exact_name(rev)
name = name or repo.experiments.get_exact_name(rev)
if name:
name = name.rsplit("/")[-1]
Copy link
Contributor Author

@daavoo daavoo Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was not really needed after the introduction of repo.experiments.get_exact_name(rev) but it was left here, causing the unnecessary truncation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no test case for it

res["name"] = name

return res
Expand All @@ -117,7 +116,7 @@ def _collect_experiment_branch(
baseline,
onerror: Optional[Callable] = None,
running=None,
**kwargs
**kwargs,
):
from dvc.scm import resolve_rev

Expand All @@ -132,7 +131,7 @@ def _collect_experiment_branch(
onerror=onerror,
status=status,
running=running,
**kwargs
**kwargs,
)
if len(revs) > 1:
exp = {"checkpoint_tip": exp_rev}
Expand Down
15 changes: 15 additions & 0 deletions tests/func/experiments/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ def test_show_no_commits(tmp_dir):
assert Repo.init().experiments.show() == {}


@pytest.mark.vscode
def test_show_branch_and_tag_name(tmp_dir, scm, dvc, exp_stage):
with tmp_dir.branch("new/branch", new=True):
tmp_dir.scm_gen("branch", "branch", "commit")
branch_rev = scm.get_rev()

result = dvc.experiments.show(all_branches=True)
assert result[branch_rev]["baseline"]["data"]["name"] == "new/branch"

scm.tag("new/tag")
tag_rev = scm.get_rev()
result = dvc.experiments.show(all_tags=True)
assert result[tag_rev]["baseline"]["data"]["name"] == "new/tag"


@pytest.mark.vscode
def test_show_simple(tmp_dir, scm, dvc, exp_stage):
assert dvc.experiments.show()["workspace"] == {
Expand Down