Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-40254: Expand output of --show=graph option #254

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/DM-40254.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The output of the `pipetask ... --show=graph` now includes extended information about dataset references and their related datastore records.
1 change: 0 additions & 1 deletion doc/changes/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ The ``<TYPE>`` should be one of:
* ``perf``: A performance enhancement.
* ``doc``: A documentation improvement.
* ``removal``: An API removal or deprecation.
* ``other``: Other Changes and Additions of interest to general users.
* ``misc``: Changes that are of minor interest.

An example file name would therefore look like ``DM-30291.misc.rst``.
Expand Down
41 changes: 31 additions & 10 deletions python/lsst/ctrl/mpexec/showInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
import re
import sys
from collections import defaultdict
from collections.abc import Mapping
from types import SimpleNamespace
from typing import Any

import lsst.pex.config as pexConfig
import lsst.pex.config.history as pexConfigHistory
from lsst.daf.butler import DatasetRef
from lsst.daf.butler import DatasetRef, DatasetType, DatastoreRecordData, NamedKeyMapping
from lsst.pipe.base import Pipeline, QuantumGraph

from . import util
Expand Down Expand Up @@ -289,19 +290,39 @@
graph : `lsst.pipe.base.QuantumGraph`
Execution graph.
"""
for taskNode in graph.taskGraph:

def _print_refs(
mapping: NamedKeyMapping[DatasetType, tuple[DatasetRef, ...]],
datastore_records: Mapping[str, DatastoreRecordData],
) -> None:
"""Print complete information on quantum input or output refs."""
for key, refs in mapping.items():
if refs:
print(f" {key}:", file=self.stream)
for ref in refs:
print(f" - {ref}", file=self.stream)
for datastore_name, record_data in datastore_records.items():
if record_map := record_data.records.get(ref.id):
print(f" records for {datastore_name}:", file=self.stream)

Check warning on line 306 in python/lsst/ctrl/mpexec/showInfo.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/showInfo.py#L306

Added line #L306 was not covered by tests
for table_name, records in record_map.items():
print(f" - {table_name}:", file=self.stream)

Check warning on line 308 in python/lsst/ctrl/mpexec/showInfo.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/showInfo.py#L308

Added line #L308 was not covered by tests
for record in records:
print(f" - {record}:", file=self.stream)

Check warning on line 310 in python/lsst/ctrl/mpexec/showInfo.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/showInfo.py#L310

Added line #L310 was not covered by tests
else:
print(f" {key}: []", file=self.stream)

Check warning on line 312 in python/lsst/ctrl/mpexec/showInfo.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/showInfo.py#L312

Added line #L312 was not covered by tests

for taskNode in graph.iterTaskGraph():
print(taskNode, file=self.stream)

for iq, quantum in enumerate(graph.getQuantaForTask(taskNode)):
print(f" Quantum {iq}:", file=self.stream)
for iq, quantum_node in enumerate(graph.getNodesForTask(taskNode)):
quantum = quantum_node.quantum
print(
f" Quantum {iq} dataId={quantum.dataId} nodeId={quantum_node.nodeId}:", file=self.stream
)
print(" inputs:", file=self.stream)
for key, refs in quantum.inputs.items():
dataIds = [f"DataId({ref.dataId})" for ref in refs]
print(" {}: [{}]".format(key, ", ".join(dataIds)), file=self.stream)
_print_refs(quantum.inputs, quantum.datastore_records)
print(" outputs:", file=self.stream)
for key, refs in quantum.outputs.items():
dataIds = [f"DataId({ref.dataId})" for ref in refs]
print(" {}: [{}]".format(key, ", ".join(dataIds)), file=self.stream)
_print_refs(quantum.outputs, quantum.datastore_records)

def _showWorkflow(self, graph: QuantumGraph) -> None:
"""Print quanta information and dependency to stdout
Expand Down