Skip to content

Commit

Permalink
Refresh pipeline directed graph colors
Browse files Browse the repository at this point in the history
  • Loading branch information
leeskelvin committed May 19, 2023
1 parent c57ef26 commit 04f4f6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 14 additions & 11 deletions python/lsst/ctrl/mpexec/dotTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@

# Node styles indexed by node type.
_STYLES = dict(
task=dict(shape="box", style="filled,bold", fillcolor="gray70"),
quantum=dict(shape="box", style="filled,bold", fillcolor="gray70"),
dsType=dict(shape="box", style="rounded,filled", fillcolor="gray90"),
dataset=dict(shape="box", style="rounded,filled", fillcolor="gray90"),
task=dict(shape="box", style="filled", color="transparent", fontcolor="white", fillcolor="#058B8C"),
quantum=dict(shape="box", style="filled", color="transparent", fontcolor="white", fillcolor="#058B8C"),
dsType=dict(shape="box", style="rounded,filled,bold", color="#00BABC", fillcolor="#F5F5F5"),
dataset=dict(shape="box", style="rounded,filled,bold", color="#00BABC", fillcolor="#F5F5F5"),
)

# Edge attributes - do not use 'style' here; that's reserved for prerequisites.
_EDGEATTRIBS = dict(color="#313333")


def _renderNode(file: io.TextIOBase, nodeName: str, style: str, labels: list[str]) -> None:
"""Render GV node"""
Expand Down Expand Up @@ -177,13 +180,13 @@ def graph2dot(qgraph: QuantumGraph, file: Any) -> None:
for dsRefs in quantumNode.quantum.inputs.values():
for dsRef in dsRefs:
nodeName = _makeDSNode(dsRef, allDatasetRefs, file)
_renderEdge(nodeName, taskNodeName, file)
_renderEdge(nodeName, taskNodeName, file, **_EDGEATTRIBS)

Check warning on line 183 in python/lsst/ctrl/mpexec/dotTools.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/dotTools.py#L183

Added line #L183 was not covered by tests

# quantum outputs
for dsRefs in quantumNode.quantum.outputs.values():
for dsRef in dsRefs:
nodeName = _makeDSNode(dsRef, allDatasetRefs, file)
_renderEdge(taskNodeName, nodeName, file)
_renderEdge(taskNodeName, nodeName, file, **_EDGEATTRIBS)

Check warning on line 189 in python/lsst/ctrl/mpexec/dotTools.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/dotTools.py#L189

Added line #L189 was not covered by tests

print("}", file=file)
if close:
Expand Down Expand Up @@ -267,11 +270,11 @@ def expand_dimensions(connection: connectionTypes.BaseConnection) -> list[str]:
_renderDSTypeNode(attr.name, dimensions, file)
allDatasets.add(attr.name)
nodeName, component = DatasetType.splitDatasetTypeName(attr.name)
_renderEdge(attr.name, taskNodeName, file)
_renderEdge(attr.name, taskNodeName, file, **_EDGEATTRIBS)
# connect component dataset types to the composite type that
# produced it
if component is not None and (nodeName, attr.name) not in allDatasets:
_renderEdge(nodeName, attr.name, file)
_renderEdge(nodeName, attr.name, file, **_EDGEATTRIBS)
allDatasets.add((nodeName, attr.name))
if nodeName not in allDatasets:
dimensions = expand_dimensions(attr)
Expand All @@ -288,22 +291,22 @@ def expand_dimensions(connection: connectionTypes.BaseConnection) -> list[str]:
_renderDSTypeNode(attr.name, dimensions, file)
allDatasets.add(attr.name)
# use dashed line for prerequisite edges to distinguish them
_renderEdge(attr.name, taskNodeName, file, style="dashed")
_renderEdge(attr.name, taskNodeName, file, style="dashed", **_EDGEATTRIBS)

Check warning on line 294 in python/lsst/ctrl/mpexec/dotTools.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/dotTools.py#L294

Added line #L294 was not covered by tests

for attr in sorted(iterConnections(taskDef.connections, "outputs"), key=lambda x: x.name):
if attr.name not in allDatasets:
dimensions = expand_dimensions(attr)
_renderDSTypeNode(attr.name, dimensions, file)
allDatasets.add(attr.name)
_renderEdge(taskNodeName, attr.name, file)
_renderEdge(taskNodeName, attr.name, file, **_EDGEATTRIBS)

# This for loop is a workaround until DM-29658 at which time metadata
# connections should start working with the above code
for matchLabel, dsTypeName in metadataNodesToLink:
# only render an edge to metadata if the label is part of the current
# graph
if (result := labelToTaskName.get(matchLabel)) is not None:
_renderEdge(result, dsTypeName, file)
_renderEdge(result, dsTypeName, file, **_EDGEATTRIBS)

print("}", file=file)
if close:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dotTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def testPipeline2dot(self):
continue

# make sure components are connected appropriately
self.assertIn('"D" -> "D.C";', file.getvalue())
self.assertIn('"D" -> "D.C"', file.getvalue())

# make sure there is a connection created for metadata if someone
# tries to read it in
Expand Down

0 comments on commit 04f4f6e

Please sign in to comment.