Skip to content

Commit

Permalink
Add --eval-filter
Browse files Browse the repository at this point in the history
Fixes: #239
  • Loading branch information
asmacdo committed Feb 7, 2025
1 parent c575c80 commit a104d8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/con_duct/suite/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
MINIMUM_SCHEMA_VERSION: str = "0.2.0"


def load_duct_runs(info_files: List[str]) -> List[Dict[str, Any]]:
def load_duct_runs(info_files: List[str], args) -> List[Dict[str, Any]]:
loaded: List[Dict[str, Any]] = []
for info_file in info_files:
with open(info_file) as file:
Expand All @@ -63,6 +63,10 @@ def load_duct_runs(info_files: List[str]) -> List[Dict[str, Any]]:
# this["prefix"] is the path at execution time, could have moved
this["prefix"] = info_file.split("info.json")[0]
if Version(this["schema_version"]) >= Version(MINIMUM_SCHEMA_VERSION):
if args.eval_filter and not eval(
args.eval_filter, _flatten_dict(this)
):
continue
loaded.append(this)
else:
# TODO lower log level once --log-level is respected
Expand Down Expand Up @@ -148,7 +152,7 @@ def ls(args: argparse.Namespace) -> int:
args.paths = [p for p in glob.glob(pattern)]

info_files = [path for path in args.paths if path.endswith("info.json")]
run_data_raw = load_duct_runs(info_files)
run_data_raw = load_duct_runs(info_files, args)
formatter = SummaryFormatter(enable_colors=args.colors)
output_rows = process_run_data(run_data_raw, args.fields, formatter)

Expand Down
4 changes: 4 additions & 0 deletions src/con_duct/suite/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def main(argv: Optional[List[str]] = None) -> None:
help="Path to duct report files, only `info.json` would be considered. "
"If not provided, the program will glob for files that match DUCT_OUTPUT_PREFIX.",
)
parser_ls.add_argument(
"-e",
"--eval-filter",
)
parser_ls.set_defaults(func=ls)

args = parser.parse_args(argv)
Expand Down

0 comments on commit a104d8b

Please sign in to comment.