鹿野孟城
03/09/2026, 2:02 AMpersist_result parameter of the flow and task decorator and PREFECT_RESULTS_PERSIST_BY_DEFAULT and PREFECT_TASKS_DEFAULT_PERSIST_RESULT environment variables has been set?Marvin
03/09/2026, 2:02 AMMarvin
03/09/2026, 2:04 AM@task(persist_result=...)
2) PREFECT_TASKS_DEFAULT_PERSIST_RESULT (if set, this overrides the parent flow’s setting)
3) Enclosing flow’s persist_result (from @flow)
4) PREFECT_RESULTS_PERSIST_BY_DEFAULT
5) Otherwise False
For flows (highest to lowest):
1) Explicit @flow(persist_result=...)
2) PREFECT_RESULTS_PERSIST_BY_DEFAULT
3) Otherwise False
Notes:
- Explicit decorator settings always win over env vars.
- For tasks, PREFECT_TASKS_DEFAULT_PERSIST_RESULT takes precedence over both the flow’s setting and the global default.
- Certain options implicitly enable persistence regardless of defaults:
- Tasks: setting cache_policy, cache_key_fn, result_storage_key, result_storage, or result_serializer
- Flows: setting result_storage or result_serializer
Example: If @flow(persist_result=True) but PREFECT_TASKS_DEFAULT_PERSIST_RESULT=False, tasks will not persist unless you set @task(persist_result=True) explicitly.