diff --git a/python/lsst/ctrl/mpexec/cli/opt/optionGroups.py b/python/lsst/ctrl/mpexec/cli/opt/optionGroups.py index ce15a5ac..464b2ab9 100644 --- a/python/lsst/ctrl/mpexec/cli/opt/optionGroups.py +++ b/python/lsst/ctrl/mpexec/cli/opt/optionGroups.py @@ -74,6 +74,7 @@ def __init__(self) -> None: ctrlMpExecOpts.order_pipeline_option(), ctrlMpExecOpts.save_pipeline_option(), ctrlMpExecOpts.pipeline_dot_option(), + ctrlMpExecOpts.pipeline_mermaid_option(), pipeBaseOpts.instrument_option(help=instrumentOptionHelp, metavar="instrument", multiple=True), ctrlMpExecOpts.butler_config_option(required=False), ] @@ -109,6 +110,7 @@ def __init__(self) -> None: ctrlMpExecOpts.save_qgraph_option(), ctrlMpExecOpts.save_single_quanta_option(), ctrlMpExecOpts.qgraph_dot_option(), + ctrlMpExecOpts.qgraph_mermaid_option(), ctrlMpExecOpts.summary_option(), ctrlMpExecOpts.save_execution_butler_option(), ctrlMpExecOpts.clobber_execution_butler_option(), diff --git a/python/lsst/ctrl/mpexec/cli/opt/options.py b/python/lsst/ctrl/mpexec/cli/opt/options.py index 4b81d0f1..23789c72 100644 --- a/python/lsst/ctrl/mpexec/cli/opt/options.py +++ b/python/lsst/ctrl/mpexec/cli/opt/options.py @@ -189,6 +189,13 @@ ) +pipeline_mermaid_option = MWOptionDecorator( + "--pipeline-mermaid", + help="Location for storing Mermaid representation of a pipeline.", + type=MWPath(writable=True, file_okay=True, dir_okay=False), +) + + profile_option = MWOptionDecorator( "--profile", help="Dump cProfile statistics to file name.", type=MWPath(file_okay=True, dir_okay=False) ) @@ -266,6 +273,12 @@ type=MWPath(writable=True, file_okay=True, dir_okay=False), ) +qgraph_mermaid_option = MWOptionDecorator( + "--qgraph-mermaid", + help="Location for storing Mermaid representation of a quantum graph.", + type=MWPath(writable=True, file_okay=True, dir_okay=False), +) + replace_run_option = MWOptionDecorator( "--replace-run", diff --git a/python/lsst/ctrl/mpexec/cli/script/build.py b/python/lsst/ctrl/mpexec/cli/script/build.py index 7b00d333..528d7d05 100644 --- a/python/lsst/ctrl/mpexec/cli/script/build.py +++ b/python/lsst/ctrl/mpexec/cli/script/build.py @@ -39,6 +39,7 @@ def build( # type: ignore pipeline, pipeline_actions, pipeline_dot, + pipeline_mermaid, save_pipeline, show, butler_config=None, @@ -65,6 +66,8 @@ def build( # type: ignore A list of pipeline actions in the order they should be executed. pipeline_dot : `str` Path location for storing GraphViz DOT representation of a pipeline. + pipeline_mermaid : `str` + Path location for storing Mermaid representation of a pipeline. save_pipeline : `str` Path location for storing resulting pipeline definition in YAML format. show : `lsst.ctrl.mpexec.showInfo.ShowInfo` @@ -102,6 +105,7 @@ def build( # type: ignore pipeline=pipeline, pipeline_actions=pipeline_actions, pipeline_dot=pipeline_dot, + pipeline_mermaid=pipeline_mermaid, save_pipeline=save_pipeline, ) @@ -124,6 +128,13 @@ def build( # type: ignore task_classes="full", ) + if pipeline_mermaid: + with open(pipeline_mermaid, "w") as stream: + visualization.show_mermaid( + pipeline.to_graph(butler.registry if butler is not None else None, visualization_only=True), + stream, + ) + show.show_pipeline_info(pipeline, butler=butler) return pipeline diff --git a/python/lsst/ctrl/mpexec/cli/script/qgraph.py b/python/lsst/ctrl/mpexec/cli/script/qgraph.py index 43e97dd3..7c796160 100644 --- a/python/lsst/ctrl/mpexec/cli/script/qgraph.py +++ b/python/lsst/ctrl/mpexec/cli/script/qgraph.py @@ -46,6 +46,7 @@ def qgraph( # type: ignore save_qgraph, save_single_quanta, qgraph_dot, + qgraph_mermaid, butler_config, input, output, @@ -105,6 +106,8 @@ def qgraph( # type: ignore qgraph_dot : `str` or `None` Path location for storing GraphViz DOT representation of a quantum graph. + qgraph_mermaid : `str` or `None` + Path location for storing Mermaid representation of a quantum graph. butler_config : `str`, `dict`, or `lsst.daf.butler.Config` If `str`, `butler_config` is the path location of the gen3 butler/registry config file. If `dict`, `butler_config` is key value @@ -194,6 +197,7 @@ def qgraph( # type: ignore save_qgraph=save_qgraph, save_single_quanta=save_single_quanta, qgraph_dot=qgraph_dot, + qgraph_mermaid=qgraph_mermaid, butler_config=butler_config, input=input, output=output,