<@ULVA73B9P> Can you confirm that if I set `PREFEC...
# ask-marvin
t
@Marvin Can you confirm that if I set
PREFECT_RESULTS_PERSIST_BY_DEFAULT
to true and
PREFECT_TASKS_DEFAULT_PERSIST_RESULT
to false, task results will not be persisted by default (unless overriding setting on individual tasks), but final flow result will be persisted?
m
thought for 133.0 seconds
Yes — in Prefect 3.x, that combination behaves exactly as you described: - With
PREFECT_TASKS_DEFAULT_PERSIST_RESULT=false
, task results are not persisted by default. This task-level default takes precedence for tasks. - With
PREFECT_RESULTS_PERSIST_BY_DEFAULT=true
, flow results are persisted by default. There’s no separate flow-level default env var, so flows use this setting. You can still override per object: - Tasks:
@task(persist_result=True/False)
- Flows (including subflows):
@flow(persist_result=True/False)
Example:
Copy code
from prefect import flow, task

@task(persist_result=True)  # overrides the task default
def compute(x):
    return x + 1

@flow(persist_result=False)  # overrides the flow default if you don't want the final flow result persisted
def my_flow():
    return compute(1)
Docs and references: - Results and persistence overview: Results (Prefect 3 docs) - Relevant source (for precedence and defaults): - prefect/results.py - prefect/context.py - prefect/flow_engine.py Note: Ensure you have appropriate result storage configured (e.g., via
result_storage
on a flow/deployment) if you want persisted results to be written to a durable location. Subflows are flows, so they’ll follow the flow rule above unless you override
persist_result
on the subflow decorator.
1