-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
TASK_SOURCE cache policy is not applied to nested tasks #16925
Comments
hey @edalfon, thanks for the issue! the current behavior is intentional - That said, I think the use case makes sense. While you could write a @task(cache_policy=INPUTS + TASK_SOURCE.depends(subtask))
def main_task(input: str):
... what do you think about something like this? |
Hi @zzstoatzz, thanks for taking a look at this and clarifying the intended behavior. I think explicitly declaring dependencies between tasks using something like I initially assumed that, since Prefect already detects dependencies between tasks within a flow, it would be easier to extend that logic to caching. But I understand could get quite complex. So, I'll experiment with writing a custom Thanks again! |
Going to close this with the docs update and the information about how to achieve the desired end state - we can revisit if it becomes a popular request |
Bug summary
When using the new feature in Prefect 3.0 that allows nesting tasks within other tasks, I expected that cache policies—specifically TASK_SOURCE—would apply recursively to all nested tasks. However, this does not seem to be the case.
Consider the following minimal example:
Expected Behavior (this is MY expected behavior, but I am not sure if it is the intended design. So I am not necessarily claiming this is a bug -despite the label that seemed the only appropriate one-)
Given a flow (like the example above) where:
I expected that changing the source code of a nested task would invalidate the cache and trigger a re-execution of the affected task(s).
Observed Behavior:
The cache policy works as expected when:
Issue: When only the source of a nested task changes, Prefect does not detect this modification. Instead, it seems to me that it checks only the inputs and source of the main task. Since those remain unchanged, Prefect retrieves cached results, even though the nested task has been modified. This can lead to outdated or incorrect results in workflows where the nested task's logic impacts the main task.
Question / Feature Request
Is this behavior intentional, or should TASK_SOURCE cache policy apply recursively to nested tasks?
If this is the expected behavior, I suggest adding a clear note in the documentation to avoid confusion.
If not, would it be possible to add recursive cache invalidation for nested tasks to the roadmap?
Version info
Additional context
No response
The text was updated successfully, but these errors were encountered: