Skip to content

Commit

Permalink
Simplify to_summary_dict and add tests to exercise human-readable option
Browse files Browse the repository at this point in the history
  • Loading branch information
eigerx committed Mar 13, 2024
1 parent e656347 commit e362e43
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
14 changes: 4 additions & 10 deletions python/lsst/pipe/base/execution_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,10 @@ def to_summary_dict(
A dictionary containing a summary of a `TaskExecutionReport` for
each task in the quantum graph.
"""
if human_readable:
return {
task: report.to_summary_dict(butler, do_store_logs=do_store_logs, human_readable=True)
for task, report in self.tasks.items()
}
else:
return {
task: report.to_summary_dict(butler, do_store_logs=do_store_logs)
for task, report in self.tasks.items()
}
return {
task: report.to_summary_dict(butler, do_store_logs=do_store_logs, human_readable=human_readable)
for task, report in self.tasks.items()
}

def write_summary_yaml(self, butler: Butler, filename: str, do_store_logs: bool = True) -> None:
"""Take the dictionary from
Expand Down
22 changes: 16 additions & 6 deletions tests/test_execution_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,19 @@ 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, do_store_logs=False)
self.assertIsNotNone(dict_of_expected_failures["task0"]["failed_quanta"])
self.assertEqual(dict_of_expected_failures["task1"]["outputs"]["add_dataset2"]["blocked"], 1)
self.assertDictEqual(dict_of_expected_failures["task2"]["failed_quanta"], {})
self.assertEqual(dict_of_expected_failures["task3"]["outputs"]["add_dataset4"]["produced"], 0)
self.assertEqual(dict_of_expected_failures["task4"]["n_quanta_blocked"], 1)
# make a summary dictionary with a certain amount of
# expected failures and check that they are there
exp_failures = report.to_summary_dict(butler, do_store_logs=False)
self.assertIsNotNone(exp_failures["task0"]["failed_quanta"])
self.assertEqual(exp_failures["task1"]["outputs"]["add_dataset2"]["blocked"], 1)
self.assertDictEqual(exp_failures["task2"]["failed_quanta"], {})
self.assertEqual(exp_failures["task3"]["outputs"]["add_dataset4"]["produced"], 0)
self.assertEqual(exp_failures["task4"]["n_quanta_blocked"], 1)

# now we'll make a human-readable summary dict and repeat the tests:
hr_exp_failures = report.to_summary_dict(butler, do_store_logs=False, human_readable=True)
self.assertIsNotNone(hr_exp_failures["task0"]["failed_quanta"])
self.assertEqual(hr_exp_failures["task1"]["outputs"]["add_dataset2"]["blocked"], 1)
self.assertDictEqual(hr_exp_failures["task2"]["failed_quanta"], {})
self.assertEqual(hr_exp_failures["task3"]["outputs"]["add_dataset4"]["produced"], 0)
self.assertEqual(hr_exp_failures["task4"]["n_quanta_blocked"], 1)

0 comments on commit e362e43

Please sign in to comment.