to_mermaid.py
pipeline_to_mermaid(nodes, ios, legend=True, use_dataset_styles=True, connect_wrapped_datasets=True, title=None, layout=None, theme=None, look=None, io_shape_template='[({value})]', node_shape_template='([{value}])')
Convert a pipeline to a mermaid diagram
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes
|
set[Node]
|
set of |
required |
ios
|
dict[tuple[str, str], Input | Output]
|
dict of name and |
required |
legend
|
bool
|
if True, display a legend |
True
|
use_dataset_styles
|
bool
|
if True, use a distinct color for each dataset type |
True
|
connect_wrapped_datasets
|
bool
|
if True, connect wrapped datasets with a dashed line |
True
|
title
|
str | None
|
Title of the mermaid diagram |
None
|
layout
|
str | None
|
Layout type for the diagram (e.g., 'dagre') |
None
|
theme
|
str | None
|
Theme for the diagram (e.g., 'neo') |
None
|
look
|
str | None
|
Look and feel for the diagram (e.g., 'neo') |
None
|
io_shape_template
|
str
|
Shape template for IO nodes, with |
'[({value})]'
|
node_shape_template
|
str
|
Shape template for processing nodes, with
|
'([{value}])'
|
Returns:
| Type | Description |
|---|---|
str
|
the pipeline rendered as mermaid diagram syntax |
Examples:
>>> from pathlib import Path
>>> from ordeq_viz import (
... pipeline_to_mermaid
... )
>>> import catalog as catalog_module # doctest: +SKIP
>>> import pipeline as pipeline_module # doctest: +SKIP
Gather all nodes and ios in your project:
>>> from ordeq._resolve import _resolve_runnables_to_nodes_and_ios
>>> nodes, ios = _resolve_runnables_to_nodes_and_ios( # doctest: +SKIP
... catalog_module,
... pipeline_module
... )
Generate the pipeline visualization and write to file:
>>> mermaid = pipeline_to_mermaid(nodes, ios) # doctest: +SKIP
>>> Path("pipeline.mermaid").write_text(mermaid) # doctest: +SKIP