Skip to content

Commit

Permalink
Print table of produced and missing datasets to the command-line
Browse files Browse the repository at this point in the history
  • Loading branch information
eigerx committed Mar 14, 2024
1 parent 1ce94f1 commit 7e9983a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
6 changes: 2 additions & 4 deletions python/lsst/ctrl/mpexec/cli/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,14 @@ def update_graph_run(
@click.command(cls=PipetaskCommand)
@repo_argument()
@ctrlMpExecOpts.qgraph_argument()
@click.argument("output_yaml", type=click.Path(exists=False))
@click.option("--output-yaml", default='', help="Summarize report in a yaml file (pass its name here).")
@click.option("--logs/--no-logs", default=True, help="Get butler log datasets for extra information.")
def report(repo: str, qgraph: str, output_yaml: str, logs: bool = True) -> None:
def report(repo: str, qgraph: str, output_yaml: str='', logs: bool = True) -> None:
"""Write a yaml file summarizing the produced and missing expected datasets
in a quantum graph.
REPO is the location of the butler/registry config file.
QGRAPH is the URL to a serialized Quantum Graph file.
OUTPUT_YAML is the URL to store the summary report.
"""
script.report(repo, qgraph, output_yaml, logs)
23 changes: 21 additions & 2 deletions python/lsst/ctrl/mpexec/cli/script/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
from lsst.daf.butler import Butler
from lsst.pipe.base import QuantumGraph
from lsst.pipe.base.execution_reports import QuantumGraphExecutionReport
from astropy.table import Table


def report(butler_config: str, qgraph_uri: str, output_yaml: str, logs: bool = True) -> None:
def report(butler_config: str, qgraph_uri: str, output_yaml: str | None, logs: bool = True) -> None:
"""Write a yaml file summarizing the produced and missing expected datasets
in a quantum graph.
Expand All @@ -54,4 +55,22 @@ def report(butler_config: str, qgraph_uri: str, output_yaml: str, logs: bool = T
butler = Butler.from_config(butler_config, writeable=False)
qgraph = QuantumGraph.loadUri(qgraph_uri)
report = QuantumGraphExecutionReport.make_reports(butler, qgraph)
report.write_summary_yaml(butler, output_yaml, do_store_logs=logs)
if not output_yaml:
# this is the option to print to the command-line
summary_dict = report.to_summary_dict(butler, logs, human_readable=True)
quanta = Table()
datasets = Table()
dataset_table_rows = []
data_products = []
for task in summary_dict.keys():
for data_product in summary_dict[task]["outputs"]:
print(summary_dict[task]["outputs"][data_product])
dataset_table_rows.append(summary_dict[task]["outputs"][data_product])
data_products.append(data_product)
datasets = Table(dataset_table_rows)
datasets.add_column(data_products, index=0, name="DatasetType")
print(datasets)
# something about failed quanta outside the smaller loop
#print(Table(summary_dict[task]["outputs"]))
else:
report.write_summary_yaml(butler, output_yaml, do_store_logs=logs)

0 comments on commit 7e9983a

Please sign in to comment.