How to visualize flow in prefect 2.0?

on this page Flow Visualization | Prefect Docs, there is an example give for prefect 1.0 to visualize a flow. it simply calls Flow.visualize() method.

however, I can’t find this method in prefect 2.1.1. what method should be used to visualize a flow?

thanks

3 Likes

Great question! For now, we recommend managing that by separating environments:

  • running first locally or in a development workspaces
  • investigating whether everything looks good, checking the Radar view
  • finally, moving to a production workspace and running there

Due to the dynamicism, there is no precompiled DAG view because 2.0 doesn’t precompile the DAG - all the magic happens at runtime and the view is generated on the fly dynamically

Came here with the same question. Was looking for something like https://streamlit-streamlit-kbregula-apache-airflowvisualize-dag-emhqvl.streamlitapp.com/

Would be nice to have something even if it is just a graphviz plot.

Take an example from the tutorial (second one here) First steps - Prefect 2.0

import requests
from prefect import flow, task

@task
def call_api(url):
    response = requests.get(url)
    print(response.status_code)
    return response.json()

@task
def parse_fact(response):
    fact = response["fact"]
    print(fact)
    return fact

@flow
def api_flow(url):
    fact_json = call_api(url)
    fact_text = parse_fact(fact_json)
    return fact_text

api_flow("https://catfact.ninja/fact")

Or even something in the UI to show the sequence of tasks rans

1 Like

Mind explaining this?

Think I got it

2 Likes