Skip to content

Commit

Permalink
Rename bool logs to do_store_logs for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
eigerx committed Oct 31, 2023
1 parent a82ce1c commit a1677f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions python/lsst/pipe/base/execution_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ def inspect_quantum(
else:
dataset_type_report.handle_produced_dataset(output_ref, status_graph)

def to_summary_dict(self, butler: Butler, logs: bool = True) -> dict[str, Any]:
def to_summary_dict(self, butler: Butler, do_store_logs: bool = True) -> dict[str, Any]:
"""Summarize the results of the TaskExecutionReport in a dictionary.
Parameters
----------
butler : `lsst.daf.butler.Butler`
The Butler used for this report.
logs : `bool`
do_store_logs : `bool`
Store the logs in the summary dictionary.
Returns
Expand All @@ -257,7 +257,7 @@ def to_summary_dict(self, butler: Butler, logs: bool = True) -> dict[str, Any]:
failed_quanta = {}
for node_id, log_ref in self.failed.items():
quantum_info: dict[str, Any] = {"data_id": log_ref.dataId.byName()}
if logs:
if do_store_logs:
try:
log = butler.get(log_ref)
except LookupError:
Expand Down Expand Up @@ -307,15 +307,15 @@ class QuantumGraphExecutionReport:
"""A dictionary of TaskExecutionReports by task label (`dict`).
"""

def to_summary_dict(self, butler: Butler, logs: bool = True) -> dict[str, Any]:
def to_summary_dict(self, butler: Butler, do_store_logs: bool = True) -> dict[str, Any]:
"""Summarize the results of the `QuantumGraphExecutionReport` in a
dictionary.
Parameters
----------
butler : `lsst.daf.butler.Butler`
The Butler used for this report.
logs : `bool`
do_store_logs : `bool`
Store the logs in the summary dictionary.
Returns
Expand All @@ -324,9 +324,12 @@ def to_summary_dict(self, butler: Butler, logs: bool = True) -> dict[str, Any]:
A dictionary containing a summary of a `TaskExecutionReport` for
each task in the quantum graph.
"""
return {task: report.to_summary_dict(butler, logs=logs) for task, report in self.tasks.items()}
return {
task: report.to_summary_dict(butler, do_store_logs=do_store_logs)
for task, report in self.tasks.items()
}

def write_summary_yaml(self, butler: Butler, filename: str, logs: bool = True) -> None:
def write_summary_yaml(self, butler: Butler, filename: str, do_store_logs: bool = True) -> None:
"""Take the dictionary from
`QuantumGraphExecutionReport.to_summary_dict` and store its contents in
a yaml file.
Expand All @@ -337,11 +340,11 @@ def write_summary_yaml(self, butler: Butler, filename: str, logs: bool = True) -
The Butler used for this report.
filename : `str`
The name to be used for the summary yaml file.
logs : `bool`
do_store_logs : `bool`
Store the logs in the summary dictionary.
"""
with open(filename, "w") as stream:
yaml.safe_dump(self.to_summary_dict(butler, logs=logs), stream)
yaml.safe_dump(self.to_summary_dict(butler, do_store_logs=do_store_logs), stream)

Check warning on line 347 in python/lsst/pipe/base/execution_reports.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/execution_reports.py#L347

Added line #L347 was not covered by tests

@classmethod
def make_reports(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_execution_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_make_reports(self) -> None:
# make a simple qgraph to make an execution report on
butler, qgraph = simpleQGraph.makeSimpleQGraph(root=root)
report = QuantumGraphExecutionReport.make_reports(butler, qgraph)
dict_of_expected_failures = report.to_summary_dict(butler, logs=False)
dict_of_expected_failures = report.to_summary_dict(butler, do_store_logs=False)
self.assertIsNotNone(dict_of_expected_failures["task0"]["failed_quanta"])
self.assertEqual(
dict_of_expected_failures["task1"]["outputs"]["add_dataset2"]["missing_upstream_failed"], 1
Expand Down

0 comments on commit a1677f9

Please sign in to comment.