Skip to content

to_mermaid.py

pipeline_to_mermaid(nodes, datasets, legend=True, use_dataset_styles=True, connect_wrapped_datasets=True, title=None, layout=None, theme=None, look=None)

Convert a pipeline to a mermaid diagram

Parameters:

Name Type Description Default
nodes set[Node]

set of ordeq.framework.Node

required
datasets dict[str, Input | Output]

dict of name and ordeq.framework.IO

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

Returns:

Type Description
str

the pipeline rendered as mermaid diagram syntax

Examples:

>>> from pathlib import Path
>>> from ordeq_viz import (
...    gather_ios_from_module,
...    gather_nodes_from_registry,
...    pipeline_to_mermaid
... )

>>> import catalog as catalog_module  # doctest: +SKIP
>>> import pipeline as pipeline_module  # doctest: +SKIP

Gather all nodes in your project:

>>> nodes = gather_nodes_from_registry()

Find all objects of type "IO" in catalog.py:

>>> datasets = gather_ios_from_module(catalog_module)  # doctest: +SKIP
>>> mermaid = pipeline_to_mermaid(nodes, datasets)  # doctest: +SKIP
>>> Path("pipeline.mermaid").write_text(mermaid)  # doctest: +SKIP