Skip to content

Commit 2ad83e0

Browse files
committed
experiments: add --hide-workspace flag to exp show
Adds a new --hide-workspace CLI flag to dvc exp show to allow hiding the workspace row from the output table. This helps users focus on committed baselines and experiments without including the current workspace state. Fixes #10741.
1 parent da55c0d commit 2ad83e0

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

dvc/commands/experiments/show.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def run(self):
150150
all_commits=self.args.all_commits,
151151
hide_queued=self.args.hide_queued,
152152
hide_failed=self.args.hide_failed,
153+
hide_workspace=self.args.hide_workspace, # flag
153154
revs=self.args.rev,
154155
num=self.args.num,
155156
sha_only=self.args.sha,
@@ -279,6 +280,12 @@ def add_parser(experiments_subparsers, parent_parser):
279280
default=False,
280281
help="Hide queued experiments in the table.",
281282
)
283+
experiments_show_parser.add_argument(
284+
"--hide-workspace",
285+
action="store_true",
286+
default=False,
287+
help="Hide workspace row in the table.",
288+
)
282289
experiments_show_parser.add_argument(
283290
"--json",
284291
action="store_true",
@@ -319,4 +326,5 @@ def add_parser(experiments_subparsers, parent_parser):
319326
action="store_true",
320327
help="Force re-collection of experiments instead of loading from exp cache.",
321328
)
329+
322330
experiments_show_parser.set_defaults(func=CmdExperimentsShow)

dvc/repo/experiments/collect.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ def collect(
274274
num: int = 1,
275275
hide_queued: bool = False,
276276
hide_failed: bool = False,
277+
hide_workspace: bool = False,
277278
sha_only: bool = False,
278279
**kwargs,
279280
) -> list["ExpState"]:
@@ -302,9 +303,18 @@ def collect(
302303
baseline_names = describe(
303304
repo.scm, baseline_revs, refs=cached_refs, logger=logger
304305
)
305-
306-
workspace_data = collect_rev(repo, "workspace", **kwargs)
307-
result: list[ExpState] = [workspace_data]
306+
result: list[ExpState] = []
307+
if not hide_workspace:
308+
workspace_data = collect_rev(repo, "workspace", **kwargs)
309+
result.append(
310+
ExpState(
311+
rev="workspace",
312+
name=baseline_names.get("workspace"),
313+
data=workspace_data.data,
314+
error=workspace_data.error,
315+
experiments=None,
316+
)
317+
)
308318
queued = collect_queued(repo, baseline_revs, **kwargs) if not hide_queued else {}
309319
active = collect_active(repo, baseline_revs, **kwargs)
310320
failed = collect_failed(repo, baseline_revs, **kwargs) if not hide_failed else {}

dvc/repo/experiments/show.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def show(
3030
num: int = 1,
3131
hide_queued: bool = False,
3232
hide_failed: bool = False,
33+
hide_workspace: bool = False,
3334
sha_only: bool = False,
3435
**kwargs,
3536
) -> list["ExpState"]:
@@ -42,6 +43,7 @@ def show(
4243
num=num,
4344
hide_queued=hide_queued,
4445
hide_failed=hide_failed,
46+
hide_workspace=hide_workspace, # flag
4547
sha_only=sha_only,
4648
**kwargs,
4749
)

tests/unit/command/test_experiments.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def test_experiments_show(dvc, scm, mocker):
8686
"--all-commits",
8787
"--hide-queued",
8888
"--hide-failed",
89+
"--hide-workspace",
8990
"--sha",
9091
"--param-deps",
9192
"-n",
@@ -109,6 +110,7 @@ def test_experiments_show(dvc, scm, mocker):
109110
all_commits=True,
110111
hide_queued=True,
111112
hide_failed=True,
113+
hide_workspace=True,
112114
num=1,
113115
revs=["foo"],
114116
sha_only=True,

0 commit comments

Comments
 (0)