Kyle McChesney
09/11/2025, 8:10 PMresult_storage='s3-bucket/flow-results' as a kwarg in the decorator. This is the slug to an s3 block. When I am running unit tests I call the flow directly with my_flow(), I don't want the flow to write to s3 in that case, is there a way to accomplish this?Marvin
09/11/2025, 8:10 PMNate
09/11/2025, 8:11 PMLocalFilesystem() block we create in a fixture that references tmp_dir or something and use with_options to set the result_storage kwarg (assuming you already have the s3 block hard coded into your flow and don't wanna change it for the sake of the testsMarvin
09/11/2025, 8:15 PMresult_storage=....
# in your test
result = my_flow.with_options(persist_result=False, result_storage=None)()
- persist_result=False prevents writing results.
- result_storage=None is optional here; it explicitly clears any storage configured on the decorator for this run.
2) Disable globally within a test using temporary settings
- Handy if you want to disable persistence for an entire test or test module:
from prefect.settings import temporary_settings, PREFECT_RESULTS_PERSIST_BY_DEFAULT
def test_my_flow():
with temporary_settings({PREFECT_RESULTS_PERSIST_BY_DEFAULT: False}):
my_flow() # no writes to S3
- Alternatively, set env var during tests: PREFECT_RESULTS_PERSIST_BY_DEFAULT=false.
Notes:
- If any specific flow or task is explicitly defined with persist_result=True, that explicit setting will override the default. In that case, use with_options(persist_result=False) to force-disable it per run.
- Using result_storage=None ensures there’s no storage target even if persistence were enabled elsewhere.
Docs:
- Results (Prefect 3.x)
- Settings referenceNate
09/11/2025, 8:34 PM