feat(cli): support multiple --keep and --drop arguments in exp show (#10857)

* feat(cli/exp-show): support multiple --keep and --drop arguments

Closes #10851.

* set upper bound for pytest-rerunfailures to <16.0

v16.0 started breaking in CI.
See https://github.com/pytest-dev/pytest-rerunfailures/issues/303.
This commit is contained in:
skshetry
2025-08-29 21:13:15 +05:45
committed by GitHub
parent 4f4c5b1d01
commit a8bda305cd
2 changed files with 13 additions and 9 deletions
+12 -8
View File
@@ -1,6 +1,6 @@
import argparse import argparse
import re import re
from collections.abc import Iterable from collections.abc import Collection, Iterable
from datetime import date, datetime from datetime import date, datetime
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@@ -59,17 +59,16 @@ def baseline_styler(typ):
def show_experiments( def show_experiments(
td: "TabularData", td: "TabularData",
headers: dict[str, Iterable[str]], headers: dict[str, Iterable[str]],
keep=None, keep: Collection[str] = (),
drop=None, drop: Collection[str] = (),
pager=True, pager=True,
csv=False, csv=False,
markdown=False, markdown=False,
**kwargs, **kwargs,
): ):
if keep: if keep:
for col in td.keys(): # noqa: SIM118 keep_re = re.compile("|".join(keep))
if re.match(keep, col): td.protect(*(col for col in td.keys() if keep_re.match(col))) # noqa: SIM118
td.protect(col)
for col in ("State", "Executor"): for col in ("State", "Executor"):
if td.is_empty(col): if td.is_empty(col):
@@ -110,8 +109,9 @@ def show_experiments(
td.drop_duplicates("cols", ignore_empty=False) td.drop_duplicates("cols", ignore_empty=False)
cols_to_drop = set() cols_to_drop = set()
if drop is not None: if drop:
cols_to_drop = {col for col in td.keys() if re.match(drop, col)} # noqa: SIM118 drop_re = re.compile("|".join(drop))
cols_to_drop = {col for col in td.keys() if drop_re.match(col)} # noqa: SIM118
td.drop(*cols_to_drop) td.drop(*cols_to_drop)
td.render( td.render(
@@ -237,11 +237,15 @@ def add_parser(experiments_subparsers, parent_parser):
) )
experiments_show_parser.add_argument( experiments_show_parser.add_argument(
"--drop", "--drop",
action="append",
default=[],
help="Remove the columns matching the specified regex pattern.", help="Remove the columns matching the specified regex pattern.",
metavar="<regex_pattern>", metavar="<regex_pattern>",
) )
experiments_show_parser.add_argument( experiments_show_parser.add_argument(
"--keep", "--keep",
action="append",
default=[],
help="Preserve the columns matching the specified regex pattern.", help="Preserve the columns matching the specified regex pattern.",
metavar="<regex_pattern>", metavar="<regex_pattern>",
) )
+1 -1
View File
@@ -111,7 +111,7 @@ tests = [
"dvc-ssh", "dvc-ssh",
"filelock", "filelock",
"pytest>=7,<9", "pytest>=7,<9",
"pytest-rerunfailures", "pytest-rerunfailures<16.0",
"pytest-cov>=4.1.0", "pytest-cov>=4.1.0",
"pytest-docker>=1,<4", "pytest-docker>=1,<4",
"pytest-mock", "pytest-mock",