Shubham
12/27/2025, 5:32 AMMarvin
12/27/2025, 5:32 AMMarvin
12/27/2025, 5:35 AMfrom prefect import flow, task
@task(persist_result=True)
def transform(x):
return {"y": x + 1}
@flow(persist_result=True)
def my_flow(a: int):
return transform(a)
- Globally (verified CLI):
prefect config set PREFECT_RESULTS_PERSIST_BY_DEFAULT=true
- Optional: configure where results are stored (e.g., S3, local block):
@flow(result_storage="s3-bucket/my-bucket")
def my_flow(a: int): ...
Docs: Persisting results
Use Artifacts to display human-friendly outputs
- Add tables/markdown/progress to runs for quick inspection:
from prefect import task
from prefect.artifacts import create_markdown_artifact, create_table_artifact
@task
def report():
create_markdown_artifact(
key="summary",
markdown="# Run Summary\nEverything looks good ✅",
description="High-level summary"
)
create_table_artifact(
key="top-customers",
table=[{"customer_id": 1, "score": 98}, {"customer_id": 2, "score": 95}],
description="Top customers"
)
Docs: Artifacts overview and How to create artifacts
Static DAG during development
- To preview structure before running:
from prefect import flow, task
@task
def a(): return 1
@task
def b(x): return x + 1
@flow
def pipe():
return b(a())
pipe.visualize() # requires Graphviz
Docs: Visualize workflow structure
Reference for the flow run graph (if you’re curious about the API powering the UI)
- Flow run graph API
Would you like help turning on result persistence in your project or adding artifacts to your runs? Also, are you on Prefect Cloud or the open-source UI?