Repository: iterative/dvc

Issue:
exp show: show names for the queued experiments
It would be great to see the name of a queued experiment. Right now if we run, for example
```
dvc exp run --queue -S model.cnn.dropout=0.25 -n named-one
```
the table below won't show it's name right away:
<img width="1262" alt="image" src="https://user-images.githubusercontent.com/6797716/119343471-2aded280-bc9f-11eb-9325-d7a4e788986f.png">
only after we run it with `dvc exp run --run-all`:
<img width="1271" alt="image" src="https://user-images.githubusercontent.com/6797716/119343665-6ed1d780-bc9f-11eb-9982-389c5a4dd55f.png">

We could live fine without names, but if for example we want to review multiple queued experiments with `dvc exp show` and look for what we forgot to add to the queue, it would be helpful to see them.

Another use case which is not supported now, AFAK, is to remove queued experiments. If I added few experiments, I may want to remove one of them before running them all. Right now I need to reset all queued experiments with `dvc exp remove --queue` and add required ones again. This removal would be convenient to do if we could reference the queued experiments by their names. If it seems like a valid use case and dvc has no such feature, I can create a feature request.


Discussion:
#5965 also has some loosely related discussion about whether the final exp name should be shown in the queue from the beginning. @pmrowla what do you think? Not sure how important this is or how difficult to implement, but it does seems like it's a strict improvement on current behavior.
If the user is specifying a name with `-n/--name` we can display it for queued experiments.

When it comes to the current autogenerated names we cannot generate them for queued experiments, as they are derived from the resulting pipeline after reproduction. So displaying autogenerated names for queued experiments will require changing how we autogenerate names.

Regarding removing queue experiments, that will happen eventually along with proper queue management in general (https://github.com/iterative/dvc/issues/5615)

---

Regarding priority, I don't think it's worth it to put much time into how `exp show` handles queued experiments right now, since eventually `exp queue` will likely have it's own UI entirely.
> If the user is specifying a name with -n/--name we can display it for queued experiments.

👍 
> Another use case which is not supported now, AFAK, is to remove queued experiments. If I added few experiments, I may want to remove one of them before running them all. Right now I need to reset all queued experiments with `dvc exp remove --queue` and add required ones again. This removal would be convenient to do if we could reference the queued experiments by their names. If it seems like a valid use case and dvc has no such feature, I can create a feature request.

@aguschin This part got lost in the discussion, but see #6157.

@pmrowla I think it would be helpful to add this to the loose ends to clean up for experiments. It's not clear if or when we will have a separate `exp queue` command, or whether that will address this problem since the queue might still also show in `exp show`. How much work do you think it is to show named experiments in the queue?

> @pmrowla How much work do you think it is to show named experiments in the queue?

@dberenbaum this is pretty much just a one liner UI change. We already have names for queued experiments internally, we just don't show them in the UI right now.

Resolving patch:
diff --git a/dvc/repo/experiments/__init__.py b/dvc/repo/experiments/__init__.py
--- a/dvc/repo/experiments/__init__.py
+++ b/dvc/repo/experiments/__init__.py
@@ -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]:
diff --git a/dvc/repo/experiments/show.py b/dvc/repo/experiments/show.py
--- a/dvc/repo/experiments/show.py
+++ b/dvc/repo/experiments/show.py
@@ -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
@@ -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,


Test patch:
diff --git a/tests/func/experiments/test_show.py b/tests/func/experiments/test_show.py
--- a/tests/func/experiments/test_show.py
+++ b/tests/func/experiments/test_show.py
@@ -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}}