Commits
Click on a commit to change the comparison rangefix: exclude DEFAULT cache policy from triggering automatic persist_result
When with_options() is called on a task, it copies the DEFAULT cache policy
to the new task instance. During initialization, the logic that automatically
sets persist_result=True was incorrectly treating DEFAULT as an explicit
user-configured cache policy, causing results to be persisted even when
PREFECT_TASKS_DEFAULT_PERSIST_RESULT is set to False.
This fix adds DEFAULT to the exclusion list alongside NO_CACHE and NotSet,
ensuring that the auto-assigned DEFAULT policy doesn't trigger automatic
result persistence. This preserves the global persist_result setting when
using with_options().
Closes #16302
Co-Authored-By: alex.s@prefect.io <ajstreed1@gmail.com>2 days ago
by devin-ai-integration[bot] test: add coverage for DEFAULT cache policy not triggering persist_result
- Add test_default_cache_policy_does_not_set_persist_result_with_options
- Update test_setting_cache_policy_sets_persist_result_to_true to exclude DEFAULT
- Verifies fix for issue #16302
Co-Authored-By: alex.s@prefect.io <ajstreed1@gmail.com>2 days ago
by devin-ai-integration[bot] refactor: preserve user-provided persist_result and cache_policy in private variables
Address PR feedback to use a cleaner approach that preserves the user's
original persist_result and cache_policy values rather than modifying
the cache_policy check logic.
Changes:
- Store user-provided persist_result in _user_persist_result before automatic logic
- Store user-provided cache_policy in _user_cache_policy before automatic logic
- Use _user_persist_result in with_options() instead of self.persist_result
- Use _user_cache_policy in with_options() instead of self.cache_policy
- Update MaterializingTask.with_options to map these parameters to private variables
- Revert the previous change that added cache_policy != DEFAULT check
This ensures with_options() passes the original user intent, allowing the
new task to exercise the default persist_result logic and respect the
global PREFECT_TASKS_DEFAULT_PERSIST_RESULT setting.
Co-Authored-By: alex.s@prefect.io <ajstreed1@gmail.com>1 day ago
by devin-ai-integration[bot] test: address PR feedback - add MaterializingTask coverage and revert parametrized test
- Add test for MaterializingTask.with_options() preserving user-provided values
- Revert parametrized test to include DEFAULT in cache policies (per reviewer request)
Co-Authored-By: alex.s@prefect.io <ajstreed1@gmail.com>1 day ago
by devin-ai-integration[bot]