()
| 247 | # --- WORKFLOW DAG COMPONENT --- |
| 248 | @workflow.atom() |
| 249 | def workflow_dag_demo(): |
| 250 | text("## 8. Visualizing Workflow Dependencies with `workflow_dag()`") |
| 251 | text( |
| 252 | """ |
| 253 | The `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 | """ |
| 280 | The `workflow_dag()` component helps visualize dependencies and relationships within workflows. |
| 281 | **Example:** |
| 282 | ```python |
| 283 | from preswald import workflow_dag, Workflow |
| 284 | workflow = Workflow() |
| 285 | @workflow.atom() |
| 286 | def load_data(): |
| 287 | return get_df("sample_csv") |
| 288 | @workflow.atom(dependencies=['load_data']) |
| 289 | def clean_data(load_data): |
| 290 | return load_data.dropna() |
| 291 | @workflow.atom(dependencies=['clean_data']) |
| 292 | def analyze_data(clean_data): |
| 293 | return clean_data.describe() |
| 294 | workflow.execute() |
| 295 | workflow_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 --- |
nothing calls this directly
no test coverage detected