Kyle McChesney
10/15/2025, 8:58 PMMarvin
10/15/2025, 8:59 PMMarvin
10/15/2025, 9:01 PMfrom prefect.visualization import get_task_viz_tracker, build_task_dependencies
# Call this near the end of your flow or right after running it locally
tvt = get_task_viz_tracker()
if tvt:
graph = build_task_dependencies(tvt) # returns graphviz.Digraph
print(graph.source) # DOT source (nodes/edges)
# Optional: render to file (requires Graphviz installed)
graph.render("flow-topology", format="png", cleanup=True)
Notes:
- graph.source contains a DOT description you can parse if you want nodes/edges programmatically.
- Rendering requires Graphviz on your system; if it isn’t present you’ll see an error.
- See it in the UI
- Run the flow once (locally or via a deployment) and open the run’s details page; you’ll get a visualization of task executions and their dependencies for that run.
- Inspect a specific run via CLI
- For a given run id:
prefect flow-run inspect <RUN_ID>
This shows details about that flow run (states, etc.); it’s not a static DAG preview, but helpful for understanding what ran.
Limitations to be aware of:
- Because control flow is dynamic (loops, conditionals, mapping), the topology can differ between runs based on parameters and runtime branches. The visualization reflects the actual run, not a static plan.
If you’re hoping to inspect the topology without running anything at all, can you share more about your use case? I can suggest a minimal “smoke run” approach or alternatives depending on what you need.