Skip to content

Commit

Permalink
Tests for pipetask aggregate-reports
Browse files Browse the repository at this point in the history
  • Loading branch information
eigerx committed Oct 15, 2024
1 parent 6d9944d commit 735294a
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 298 deletions.
13 changes: 12 additions & 1 deletion python/lsst/ctrl/mpexec/cli/cmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,15 @@
]


from .commands import aggregate_reports, build, cleanup, pre_exec_init_qbb, purge, qgraph, report, run, run_qbb, update_graph_run
from .commands import (
aggregate_reports,
build,
cleanup,
pre_exec_init_qbb,
purge,
qgraph,
report,
run,
run_qbb,
update_graph_run,
)
9 changes: 4 additions & 5 deletions python/lsst/ctrl/mpexec/cli/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import sys
from collections.abc import Iterator, Sequence, Iterable
from collections.abc import Iterable, Iterator, Sequence
from contextlib import contextmanager
from functools import partial
from tempfile import NamedTemporaryFile
Expand Down Expand Up @@ -417,6 +417,7 @@ def report(
assert len(qgraphs) == 1, "Cannot make a report without a quantum graph."
script.report(repo, qgraphs[0], full_output_filename, logs, brief)


@click.command(cls=PipetaskCommand)
@click.argument("filenames", nargs=-1)
@click.option(
Expand All @@ -432,17 +433,15 @@ def report(
" also printed to the screen when using the --full-output-filename option.",
)
def aggregate_reports(
filenames: Iterable[str],
full_output_filename: str | None,
brief: bool = False
filenames: Iterable[str], full_output_filename: str | None, brief: bool = False
) -> None:
"""Aggregate pipetask report output on disjoint data-id groups into one
Summary over common tasks and datasets. Intended for use when the same
pipeline has been run over all groups (i.e., to aggregate all reports
for a given step). This functionality is only compatible with reports
from the `QuantumProvenanceGraph`, so the reports must be run over multiple
groups or with the `--force-v2` option.
Save the report as a file (`--full-output-filename`) or print it to stdout
(default). If the terminal is overwhelmed with data_ids from failures try
the `--brief` option.
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ctrl/mpexec/cli/script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .pre_exec_init_qbb import pre_exec_init_qbb
from .purge import PurgeResult, purge
from .qgraph import qgraph
from .report import report, report_v2, aggregate_reports
from .report import aggregate_reports, report, report_v2
from .run import run
from .run_qbb import run_qbb
from .update_graph_run import update_graph_run
12 changes: 7 additions & 5 deletions python/lsst/ctrl/mpexec/cli/script/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pprint
import time
from collections.abc import Sequence, Iterable
from collections.abc import Iterable, Sequence
from typing import Any

from astropy.table import Table
Expand Down Expand Up @@ -196,12 +195,15 @@ def report_v2(
print_summary(summary, full_output_filename, brief)


def aggregate_reports(filenames: Iterable[str], full_output_filename: str | None, brief: bool = False) -> None:
def aggregate_reports(
filenames: Iterable[str], full_output_filename: str | None, brief: bool = False
) -> None:
"""Docstring.
open a bunch of json files, call model_validate_json, call aggregrate, print summary
open a bunch of json files, call model_validate_json, call aggregrate,
print summary
"""
summaries : Iterable[Summary] = []
summaries: Iterable[Summary] = []
for filename in filenames:
with open(filename) as f:
model = Summary.model_validate_json(f.read())
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ networkx
lsst-resources @ git+https://github.com/lsst/resources@main
lsst-daf-butler @ git+https://github.com/lsst/daf_butler@main
lsst-utils @ git+https://github.com/lsst/utils@main
lsst-pipe-base @ git+https://github.com/lsst/pipe_base@main
lsst-pipe-base @ git+https://github.com/lsst/pipe_base@tickets/DM-41605
lsst-pex-config @ git+https://github.com/lsst/pex_config@main
sqlalchemy
Loading

0 comments on commit 735294a

Please sign in to comment.