Skip to content

Commit

Permalink
Allow Mermaid diagrams to be saved as images
Browse files Browse the repository at this point in the history
  • Loading branch information
enourbakhsh committed Mar 2, 2025
1 parent d2afd0a commit 1431d72
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion python/lsst/ctrl/mpexec/cli/script/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,22 @@ def build( # type: ignore
)

if pipeline_mermaid:
with open(pipeline_mermaid, "w") as stream:
# Determine output format based on file extension.
if pipeline_mermaid.endswith(".svg"):
output_format = "svg"
file_mode = "wb"
elif pipeline_mermaid.endswith(".png"):
output_format = "png"
file_mode = "wb"
else: # Default to the text-based mmd format.
output_format = "mmd"
file_mode = "w"

with open(pipeline_mermaid, file_mode) as stream:
visualization.show_mermaid(
pipeline.to_graph(butler.registry if butler is not None else None, visualization_only=True),
stream,
output_format=output_format,
dataset_types=True,
task_classes="full",
)
Expand Down

0 comments on commit 1431d72

Please sign in to comment.