MCPcopy
hub / github.com/StructuredLabs/preswald / workflow_dag_demo

Function workflow_dag_demo

preswald/tutorial/hello.py:249–302  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

247# --- WORKFLOW DAG COMPONENT ---
248@workflow.atom()
249def workflow_dag_demo():
250 text("## 8. Visualizing Workflow Dependencies with `workflow_dag()`")
251 text(
252 """
253The `workflow_dag()` function renders a Directed Acyclic Graph (DAG) to visualize task dependencies in your workflow.
254"""
255 )
256
257 # Create a demo workflow for visualization
258 demo_workflow = Workflow()
259
260 @demo_workflow.atom()
261 def demo_load_data():
262 return get_df("sample_csv")
263
264 @demo_workflow.atom(dependencies=["demo_load_data"])
265 def demo_clean_data(demo_load_data):
266 return demo_load_data.dropna()
267
268 @demo_workflow.atom(dependencies=["demo_clean_data"])
269 def demo_analyze_data(demo_clean_data):
270 return demo_clean_data.describe()
271
272 # Execute the demo workflow
273 demo_workflow.execute()
274
275 # Render the workflow DAG
276 workflow_dag(demo_workflow, title="Sample Workflow Dependency Graph")
277
278 text(
279 """
280The `workflow_dag()` component helps visualize dependencies and relationships within workflows.
281**Example:**
282```python
283from preswald import workflow_dag, Workflow
284workflow = Workflow()
285@workflow.atom()
286def load_data():
287 return get_df("sample_csv")
288@workflow.atom(dependencies=['load_data'])
289def clean_data(load_data):
290 return load_data.dropna()
291@workflow.atom(dependencies=['clean_data'])
292def analyze_data(clean_data):
293 return clean_data.describe()
294workflow.execute()
295workflow_dag(workflow, title="Workflow Dependency Graph")
296```
297**Key Features:**
298- **Visualize Dependencies:** Clearly see how tasks are interconnected.
299- **Interactive Exploration:** Zoom, pan, and hover over nodes for details.
300- **Customizable Titles:** Make your DAGs more descriptive and easy to understand.
301"""
302 )
303
304
305# --- WORKFLOW ANALYZER COMPONENT ---

Callers

nothing calls this directly

Calls 4

executeMethod · 0.95
textFunction · 0.90
WorkflowClass · 0.90
workflow_dagFunction · 0.90

Tested by

no test coverage detected