Skip to content

Commit

Permalink
Show name of experiments in the queue (iterative#6382)
Browse files Browse the repository at this point in the history
* Show name of stashed experiments

* Add tests for it

* Reorder the stash and commit rev name
  • Loading branch information
karajan1001 authored Aug 6, 2021
1 parent 6c33fbb commit 3d604a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 5 additions & 1 deletion dvc/repo/experiments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,11 @@ def get_exact_name(self, rev: str):
exclude = f"{EXEC_NAMESPACE}/*"
ref = self.scm.describe(rev, base=EXPS_NAMESPACE, exclude=exclude)
if ref:
return ExpRefInfo.from_ref(ref).name
name = ExpRefInfo.from_ref(ref).name
if name:
return name
if rev in self.stash_revs:
return self.stash_revs[rev].name
return None

def get_running_exps(self) -> Dict[str, int]:
Expand Down
6 changes: 2 additions & 4 deletions dvc/repo/experiments/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ def _collect_experiment_commit(
if name:
break
if not name:
if stash:
pass
else:
name = repo.experiments.get_exact_name(rev)
name = repo.experiments.get_exact_name(rev)
if name:
name = name.rsplit("/")[-1]
res["name"] = name
Expand Down Expand Up @@ -187,6 +184,7 @@ def show(
experiment = _collect_experiment_commit(
repo,
stash_rev,
sha_only=sha_only,
stash=stash_rev not in running,
param_deps=param_deps,
running=running,
Expand Down
5 changes: 4 additions & 1 deletion tests/func/experiments/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ def test_show_experiment(tmp_dir, scm, dvc, exp_stage, workspace):
def test_show_queued(tmp_dir, scm, dvc, exp_stage):
baseline_rev = scm.get_rev()

dvc.experiments.run(exp_stage.addressing, params=["foo=2"], queue=True)
dvc.experiments.run(
exp_stage.addressing, params=["foo=2"], queue=True, name="test_name"
)
exp_rev = dvc.experiments.scm.resolve_rev(f"{EXPS_STASH}@{{0}}")

results = dvc.experiments.show()[baseline_rev]
assert len(results) == 2
exp = results[exp_rev]["data"]
assert exp["name"] == "test_name"
assert exp["queued"]
assert exp["params"]["params.yaml"] == {"data": {"foo": 2}}

Expand Down

0 comments on commit 3d604a8

Please sign in to comment.