Drew Hentz
08/07/2025, 6:34 AMMarvin
08/07/2025, 6:34 AMMarvin
08/07/2025, 6:35 AMprefect.settings.get_current_settings()
2. Settings are validated when you update them, so you'll get immediate feedback if there's an issue
3. For more complex configurations, you might want to work with profiles directly through the prefect.settings.profiles
module
Would you like me to provide more specific examples for any particular settings you're interested in configuring?Drew Hentz
08/07/2025, 6:38 AMMarvin
08/07/2025, 6:39 AMMarvin
08/07/2025, 6:39 AMPREFECT_RESULTS_PERSIST_BY_DEFAULT
to True:
1. Temporary Setting (only for a specific code block):
python
from prefect.settings import temporary_settings
# Changes only apply within this block
with temporary_settings({"PREFECT_RESULTS_PERSIST_BY_DEFAULT": True}):
# Any flows/tasks executed here will have results persisted by default
pass
2. Permanent Setting (updates the current profile):
python
from prefect.settings import update_current_profile
# This will persist until explicitly changed
update_current_profile(
{"PREFECT_RESULTS_PERSIST_BY_DEFAULT": True}
)
After setting this, all task results will be persisted by default unless explicitly overridden at the task level using persist_result=False
.
You can verify the current setting at any time using:
python
from prefect.settings import get_current_settings
settings = get_current_settings()
print(settings.PREFECT_RESULTS_PERSIST_BY_DEFAULT) # Should print True after updating
Note that while this setting enables persistence by default, you'll still need to configure a result storage block if you want to persist results somewhere other than the default SQLite database. Would you like me to explain how to set up a specific result storage block as well?Drew Hentz
08/08/2025, 8:28 AMMarvin
08/08/2025, 8:28 AMMarvin
08/08/2025, 8:34 AMDrew Hentz
08/08/2025, 8:47 AMMarvin
08/08/2025, 8:47 AMMarvin
08/08/2025, 8:48 AMMarvin
08/08/2025, 8:50 AMDrew Hentz
08/08/2025, 10:16 PMprefect config set PREFECT_DEFAULT_RESULT_STORAGE_BLOCK='s3-bucket/my-prod-block'
How does this reconcile with what you just told me? Am I missing something?Marvin
08/08/2025, 10:16 PMMarvin
08/08/2025, 10:19 PMPREFECT_DEFAULT_RESULT_STORAGE_BLOCK
- Prefect 3.x: PREFECT_RESULTS_DEFAULT_STORAGE_BLOCK
So in 3.x you’d do:
prefect config set PREFECT_RESULTS_DEFAULT_STORAGE_BLOCK='s3-bucket/my-prod-block'
And one more important nuance in 3.x: just setting a default storage block does not automatically turn on persistence. You also need to opt in to persisting results, either globally…
prefect config set PREFECT_RESULTS_PERSIST_BY_DEFAULT=true
…or per task/flow with persist_result=True
.
To verify what your profile actually has set:
prefect config view --show-defaults
Docs, so you don’t have to take my bleak word for it:
- Prefect 3.x Results settings: Results (Prefect 3.x)
- You can see the 3.x settings fields (persist_by_default
, default_storage_block
, etc.) reflected in code as well: ResultsSettings source
If you’re actually on 2.x, then your original command is correct. Which version are you running?