Skip to content

Commit

Permalink
Attempt at adding in a pipetask report option for the QuantumProvenan…
Browse files Browse the repository at this point in the history
…ceGraph
  • Loading branch information
eigerx committed Jun 27, 2024
1 parent 67ce92e commit 8dae196
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
23 changes: 20 additions & 3 deletions python/lsst/ctrl/mpexec/cli/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ def update_graph_run(
@click.command(cls=PipetaskCommand)
@repo_argument()
@click.argument()
@click.option("--full-output-filename", default="", help="Summarize report in a yaml file")
@click.option("--collections", default=None, help="Collections to resolve duplicate datasets in.")
@click.option("--where", default="", help="where")
@click.option("--full-output-filename", default="", help="Output report as a yaml file with this name.")
@click.option("--logs/--no-logs", default=True, help="Get butler log datasets for extra information.")
@click.option(
"--show-errors",
Expand All @@ -351,6 +353,19 @@ def update_graph_run(
" quanta to the screen. Note: the default is to output a yaml file with error information"
" (data_ids and associated messages) to the current working directory instead.",
)
@click.option(
"--curse-failed-logs",
is_flag=True,
default=False,
help="If log datasets are missing in v2, mark them as cursed",
)
@click.option(
"--force-v2",
is_flag=True,
default=False,
help="Use the QuantumProvenanceGraph instead of the QuantumGraphExecutionReport, "
"even when there is only one qgraph.",
)
def report(
repo: str,
qgraphs: Sequence[str],
Expand All @@ -360,7 +375,7 @@ def report(
logs: bool = True,
show_errors: bool = False,
curse_failed_logs: bool = False,
force_v2: bool = False
force_v2: bool = False,
) -> None:
"""Write a yaml file summarizing the produced and missing expected datasets
in a quantum graph.
Expand All @@ -370,6 +385,8 @@ def report(
QGRAPH is the URL to a serialized Quantum Graph file.
"""
if force_v2 or len(qgraphs) > 1 or collections is not None:
script.report_v2(repo, qgraphs, collections, where, full_output_filename, logs, show_errors, curse_failed_logs)
script.report_v2(
repo, qgraphs, collections, where, full_output_filename, logs, show_errors, curse_failed_logs
)
else:
script.report(repo, qgraphs, full_output_filename, logs, show_errors)
19 changes: 13 additions & 6 deletions python/lsst/ctrl/mpexec/cli/script/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,20 @@ def report(
datasets.pprint_all()
else:
report.write_summary_yaml(butler, full_output_filename, do_store_logs=logs)

def report_v2(butler_config: str,


def report_v2(
butler_config: str,
qgraph_uris: Sequence[str],
collections: Sequence[str] | None,
where: str,
full_output_filename: str | None,
logs: bool = True,
show_errors: bool = False,
curse_failed_logs: bool = False,
) -> None:
) -> None:
"""Docstring
"""
butler = Butler.from_config(butler_config, writeable=False)
qpg = QuantumProvenanceGraph()
output_runs = []
Expand All @@ -136,9 +140,12 @@ def report_v2(butler_config: str,
output_runs.append(qgraph.metadata["output_run"])
if collections is None:
collections = reversed(output_runs)
qpg.resolve_duplicates(butler, collections=collections, where=where,
curse_failed_logs=curse_failed_logs)
qpg.resolve_duplicates(butler, collections=collections, where=where, curse_failed_logs=curse_failed_logs)
summary = qpg.to_summary(butler, do_store_logs=logs)
summary_dict = summary.model_dump()
if full_output_filename is not None:
with open(full_output_filename, "w") as stream:
yaml.safe_dump(summary.model_dump(), stream)
yaml.safe_dump(summary_dict, stream)
elif not full_output_filename:
quanta = Table(summary_dict["tasks"])
quanta.pprint_all()
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-41711
lsst-pex-config @ git+https://github.com/lsst/pex_config@main
sqlalchemy

0 comments on commit 8dae196

Please sign in to comment.