Skip to content

Commit 3608385

Browse files
committed
Move pipeline-dot build from cmdLineFwk to builder
This commit moves the pipeline-dot build logic from cmdLineFwk into cli/script/build.py. As part of this commit, a switch to using the same back-end display args parser as --show pipeline-graph is also made.
1 parent f1e75d8 commit 3608385

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

python/lsst/ctrl/mpexec/cli/cmd/commands.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,12 @@ def build(ctx: click.Context, **kwargs: Any) -> None:
124124
"""
125125
kwargs = _collectActions(ctx, **kwargs)
126126
show = ShowInfo(kwargs.pop("show", []))
127-
if kwargs.get("butler_config") is not None and {"pipeline-graph", "task-graph"}.isdisjoint(show.commands):
127+
if kwargs.get("butler_config") is not None and (
128+
{"pipeline-graph", "task-graph"}.isdisjoint(show.commands) and not kwargs.get("pipeline_dot")
129+
):
128130
raise click.ClickException(
129131
"--butler-config was provided but nothing uses it "
130-
"(only --show pipeline-graph and --show task-graph do)."
132+
"(only --show pipeline-graph, --show task-graph and --pipeline-dot do)."
131133
)
132134
script.build(**kwargs, show=show)
133135
_unhandledShow(show, "build")

python/lsst/ctrl/mpexec/cli/script/build.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from types import SimpleNamespace
2929

3030
from lsst.daf.butler import Butler
31+
from lsst.pipe.base.pipeline_graph import visualization
3132

3233
from ... import CmdLineFwk
3334
from ..utils import _PipelineAction
@@ -114,6 +115,15 @@ def build( # type: ignore
114115
else:
115116
butler = None
116117

118+
if pipeline_dot:
119+
with open(pipeline_dot, "w") as stream:
120+
visualization.show_dot(
121+
pipeline.to_graph(butler.registry if butler is not None else None),
122+
stream,
123+
dataset_types=True,
124+
task_classes="full",
125+
)
126+
117127
show.show_pipeline_info(pipeline, butler=butler)
118128

119129
return pipeline

python/lsst/ctrl/mpexec/cmdLineFwk.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
from lsst.utils.logging import getLogger
7676
from lsst.utils.threads import disable_implicit_threading
7777

78-
from .dotTools import graph2dot, pipeline2dot
78+
from .dotTools import graph2dot
7979
from .executionGraphFixup import ExecutionGraphFixup
8080
from .mpGraphExecutor import MPGraphExecutor
8181
from .preExecInit import PreExecInit, PreExecInitLimited
@@ -582,9 +582,6 @@ def makePipeline(self, args: SimpleNamespace) -> Pipeline:
582582
if args.save_pipeline:
583583
pipeline.write_to_uri(args.save_pipeline)
584584

585-
if args.pipeline_dot:
586-
pipeline2dot(pipeline, args.pipeline_dot)
587-
588585
return pipeline
589586

590587
def makeGraph(self, pipeline: Pipeline, args: SimpleNamespace) -> QuantumGraph | None:

0 commit comments

Comments
 (0)