1111from pydantic import BaseModel
1212
1313from pipelex import log
14- from pipelex .graph .graph_analysis import GraphAnalysis
1514from pipelex .graph .mermaidflow .mermaid_html import render_mermaid_html_async , render_mermaid_html_with_data_async
1615from pipelex .graph .mermaidflow .mermaidflow_factory import MermaidflowFactory
1716from pipelex .graph .mermaidflow .stuff_collector import collect_stuff_data_html , collect_stuff_data_text
1817from pipelex .graph .reactflow .reactflow_html import generate_reactflow_html_async
19- from pipelex .graph .reactflow .viewspec import LayoutSpec
20- from pipelex .graph .reactflow .viewspec_transformer import graphspec_to_viewspec
2118from pipelex .tools .misc .string_utils import snake_to_title_case
2219
2320if TYPE_CHECKING :
@@ -37,14 +34,12 @@ class GraphOutputs(BaseModel):
3734 graphspec_json: The GraphSpec serialized as JSON.
3835 mermaidflow_mmd: Mermaidflow view as Mermaid flowchart code.
3936 mermaidflow_html: Mermaidflow view as standalone HTML page.
40- reactflow_viewspec: The ViewSpec serialized as JSON for ReactFlow rendering.
4137 reactflow_html: ReactFlow interactive graph as standalone HTML page.
4238 """
4339
4440 graphspec_json : str | None = None
4541 mermaidflow_mmd : str | None = None
4642 mermaidflow_html : str | None = None
47- reactflow_viewspec : str | None = None
4843 reactflow_html : str | None = None
4944
5045
@@ -64,15 +59,14 @@ async def generate_graph_outputs(
6459 This can generate:
6560 - GraphSpec JSON: The canonical graph representation
6661 - Mermaidflow view: Data flow with controller subgraphs (Mermaid)
67- - ReactFlow ViewSpec: JSON for ReactFlow rendering
6862 - ReactFlow HTML: Interactive graph viewer
6963
7064 Args:
7165 graph_spec: The GraphSpec to render.
7266 graph_config: Configuration controlling which outputs to generate and data inclusion.
7367 pipe_code: The pipe code, used to derive the HTML page title when title is not provided.
7468 title: Explicit HTML page title. When provided, overrides the auto-derived title from pipe_code.
75- direction: Flowchart direction for Mermaid diagrams . When None, uses graph_config.mermaid_config.direction .
69+ direction: Flowchart direction override for both Mermaid and ReactFlow outputs . When None, each renderer uses its own config default .
7670 include_subgraphs: Whether to render controller hierarchy as subgraphs in Mermaid output.
7771
7872 Returns:
@@ -84,7 +78,6 @@ async def generate_graph_outputs(
8478 graphspec_json : str | None = None
8579 mermaidflow_mmd : str | None = None
8680 mermaidflow_html : str | None = None
87- reactflow_viewspec : str | None = None
8881 reactflow_html : str | None = None
8982
9083 # Generate GraphSpec JSON
@@ -121,47 +114,34 @@ async def generate_graph_outputs(
121114 else :
122115 mermaidflow_html = await render_mermaid_html_async (mermaidflow .mermaid_code , title = page_title , theme = mermaid_theme )
123116
124- # Generate ReactFlow outputs
125- if inclusion .reactflow_viewspec or inclusion .reactflow_html :
126- analysis = GraphAnalysis .from_graphspec (graph_spec )
127- rf_config = graph_config .reactflow_config
128- effective_rf_direction = direction or rf_config .layout_direction
129- layout = LayoutSpec (
130- direction = effective_rf_direction ,
131- nodesep = rf_config .nodesep ,
132- ranksep = rf_config .ranksep ,
117+ # Generate ReactFlow HTML
118+ if inclusion .reactflow_html :
119+ # Collect stuff data in alternate formats if configured
120+ rf_stuff_data_text : dict [str , str ] | None = None
121+ rf_stuff_data_html : dict [str , str ] | None = None
122+ if graph_config .data_inclusion .stuff_text_content :
123+ log .verbose ("Collecting stuff data text for graph_spec" )
124+ rf_stuff_data_text = collect_stuff_data_text (graph_spec )
125+ else :
126+ log .verbose ("No stuff data text to collect for graph_spec" )
127+ if graph_config .data_inclusion .stuff_html_content :
128+ rf_stuff_data_html = collect_stuff_data_html (graph_spec )
129+
130+ effective_rf_config = graph_config .reactflow_config
131+ if direction is not None :
132+ effective_rf_config = effective_rf_config .model_copy (update = {"layout_direction" : direction })
133+ reactflow_html = await generate_reactflow_html_async (
134+ graph_spec ,
135+ effective_rf_config ,
136+ stuff_data_text = rf_stuff_data_text ,
137+ stuff_data_html = rf_stuff_data_html ,
138+ title = page_title ,
133139 )
134- viewspec = graphspec_to_viewspec (graph_spec , analysis , layout = layout )
135-
136- if inclusion .reactflow_viewspec :
137- reactflow_viewspec = viewspec .model_dump_json (indent = 2 )
138-
139- if inclusion .reactflow_html :
140- # Collect stuff data in alternate formats if configured
141- rf_stuff_data_text : dict [str , str ] | None = None
142- rf_stuff_data_html : dict [str , str ] | None = None
143- if graph_config .data_inclusion .stuff_text_content :
144- log .verbose ("Collecting stuff data text for graph_spec" )
145- rf_stuff_data_text = collect_stuff_data_text (graph_spec )
146- else :
147- log .verbose ("No stuff data text to collect for graph_spec" )
148- if graph_config .data_inclusion .stuff_html_content :
149- rf_stuff_data_html = collect_stuff_data_html (graph_spec )
150-
151- reactflow_html = await generate_reactflow_html_async (
152- viewspec ,
153- graph_config .reactflow_config ,
154- graphspec = graph_spec ,
155- stuff_data_text = rf_stuff_data_text ,
156- stuff_data_html = rf_stuff_data_html ,
157- title = page_title ,
158- )
159140
160141 return GraphOutputs (
161142 graphspec_json = graphspec_json ,
162143 mermaidflow_mmd = mermaidflow_mmd ,
163144 mermaidflow_html = mermaidflow_html ,
164- reactflow_viewspec = reactflow_viewspec ,
165145 reactflow_html = reactflow_html ,
166146 )
167147
@@ -205,12 +185,6 @@ def save_graph_outputs_to_dir(
205185 saved_files ["mermaidflow_html" ] = file_path
206186 log .verbose (f"Mermaidflow HTML saved to: { file_path } " )
207187
208- if graph_outputs .reactflow_viewspec is not None :
209- file_path = output_dir / "viewspec.json"
210- file_path .write_text (graph_outputs .reactflow_viewspec , encoding = "utf-8" )
211- saved_files ["reactflow_viewspec" ] = file_path
212- log .verbose (f"ReactFlow ViewSpec saved to: { file_path } " )
213-
214188 if graph_outputs .reactflow_html is not None :
215189 file_path = output_dir / "reactflow.html"
216190 file_path .write_text (graph_outputs .reactflow_html , encoding = "utf-8" )
0 commit comments