Skip to content

Commit 3e4d1ff

Browse files
committed
fix: fix rendering documentation
Signed-off-by: Armin Graf <arminhammer@gmail.com>
1 parent 8ee4876 commit 3e4d1ff

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ print(yaml_output)
139139

140140
You can see full examples in the [tests/specification](tests/specification) directory
141141

142-
## Generate workflow state machine and graph
142+
## Generate workflow rendered graph
143143

144144
**Note** Please note that `pip install serverlessworkflow[viz]` needs to be installed in order for this to work. The `viz` feature installs pydot, which supports `graphviz`.
145145

@@ -150,13 +150,13 @@ To dot files:
150150
workflow.render_graph(filename="/tmp/out.dot")
151151
```
152152

153-
The following requires `graphviz` to be installed (verify by checking to see if the `dot` binary is on the PATH):
154-
155-
To png files:
153+
An example rendered png from the dot file:
156154
```python
157-
workflow.render_graph(filename="/tmp/out.png")
155+
workflow.render_graph(filename="/tmp/out.png", format="png")
158156
```
159157

158+
![Workflow Graph](tests/visualization/accumulate-room-readings.png)
159+
160160
# Local development
161161

162162
## Install dependencies and run tests
31.9 KB
Loading

tests/visualization/test_graphviz.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ def test_graphviz_examples(example_file):
3333
rendered_graph = workflow.render_graph(
3434
filename=f"tests/visualization/outputs/{example_name}.dot"
3535
)
36-
rendered_graph = workflow.render_graph(
37-
filename=f"tests/visualization/outputs/{example_name}.png"
38-
)
3936

4037
# Render PNG visualizations for comparison
4138
fixture_dot = Path(f"tests/visualization/fixtures/{example_name}.dot")
@@ -52,6 +49,19 @@ def test_graphviz_examples(example_file):
5249
except (subprocess.CalledProcessError, FileNotFoundError) as e:
5350
print(f" Warning: Could not render {fixture_png}: {e}")
5451

52+
output_filename = Path(f"tests/visualization/outputs/{example_name}.dot")
53+
if output_filename.exists():
54+
output_png = output_filename.with_suffix(".png")
55+
try:
56+
subprocess.run(
57+
["dot", "-Tpng", str(output_filename), "-o", str(output_png)],
58+
check=True,
59+
capture_output=True,
60+
)
61+
print(f" Generated: {output_png}")
62+
except (subprocess.CalledProcessError, FileNotFoundError) as e:
63+
print(f" Warning: Could not render {output_png}: {e}")
64+
5565
with open(f"tests/visualization/fixtures/{example_name}.dot", encoding="utf-8") as f:
5666
expected_graph = f.read()
5767

0 commit comments

Comments
 (0)