Skip to content

Commit

Permalink
Use butler collections and where options
Browse files Browse the repository at this point in the history
  • Loading branch information
eigerx committed Sep 13, 2024
1 parent b940c44 commit e2c5d9d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
17 changes: 9 additions & 8 deletions python/lsst/ctrl/mpexec/cli/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@
from lsst.ctrl.mpexec import Report
from lsst.ctrl.mpexec.showInfo import ShowInfo
from lsst.daf.butler.cli.opt import (
collections_option,
config_file_option,
config_option,
confirm_option,
options_file_option,
processes_option,
repo_argument,
where_option,
)
from lsst.daf.butler.cli.utils import MWCtxObj, catch_and_exit, option_section, unwrap

Expand Down Expand Up @@ -342,13 +344,8 @@ def update_graph_run(
@click.command(cls=PipetaskCommand)
@repo_argument()
@click.argument("qgraphs", nargs=-1)
@click.option(
"--collections",
default=None,
help="Collection(s) associated with said graphs/processing."
" For use in `lsst.daf.butler.registry.queryDatasets` if paring down the query would be useful.",
)
@click.option("--where", default="", help="A 'where' string to use to constrain the collections, if passed.")
@collections_option()
@where_option()
@click.option(
"--full-output-filename",
default="",
Expand Down Expand Up @@ -399,12 +396,16 @@ def report(
(default). If the terminal is overwhelmed with data_ids from failures try
the `--brief` option.
Butler `collections` and `where` options are for use in
`lsst.daf.butler.queryDatasets` if paring down the collections would be
useful. By default the collections and query will match the graphs.
REPO is the location of the butler/registry config file.
QGRAPHS is a Sequence of links to serialized Quantum Graphs which have been
executed and are to be analyzed.
"""
if force_v2 or len(qgraphs) > 1 or collections is not None:
if force_v2 or len(qgraphs) > 1 or collections:
script.report_v2(
repo, qgraphs, collections, where, full_output_filename, logs, brief, curse_failed_logs
)
Expand Down
4 changes: 3 additions & 1 deletion python/lsst/ctrl/mpexec/cli/script/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ def report_v2(
qpg.add_new_graph(butler, qgraph)
output_runs.append(qgraph.metadata["output_run"])
collections_sequence: Sequence[Any] # to appease mypy
if collections is None:
if not collections:
collections_sequence = list(reversed(output_runs))
else:
collections_sequence = collections

Check warning on line 181 in python/lsst/ctrl/mpexec/cli/script/report.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/cli/script/report.py#L181

Added line #L181 was not covered by tests
qpg.resolve_duplicates(
butler, collections=collections_sequence, where=where, curse_failed_logs=curse_failed_logs
)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_cliCmdReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,17 @@ def test_report(self):
["report", self.root, graph_uri, "--full-output-filename", test_filename, "--no-logs"],
input="no",
)

# Check that we can read from the command line
self.assertEqual(result.exit_code, 0, clickResultMsg(result))

# Check that we can open and read the file produced by make_reports
with open(test_filename) as f:
report_output_dict = yaml.load(f, Loader=SafeLoader)

with open("delete_me.yaml", "w") as f:
yaml.safe_dump(report_output_dict, f)

self.assertIsNotNone(report_output_dict["task0"])
self.assertIsNotNone(report_output_dict["task0"]["failed_quanta"])
self.assertIsInstance(report_output_dict["task0"]["n_expected"], int)
Expand Down

0 comments on commit e2c5d9d

Please sign in to comment.