Fiyinfoba Ogunkeye
01/20/2024, 5:38 AMMarvin
01/20/2024, 5:39 AMcache_key_fn
. While this isn't directly related to your scenario, the pattern for custom caching and dependency could be inferred from this.
2. Removing flow_run clears everything except task_run_state_cache: Although this issue is about cleanup after deletion, it does imply the use of task_run_state_cache
, which might be relevant for your caching logic.
3. Task's `refresh_cache` not working with flow retries: This issue discusses a bug related to refresh_cache
not working with retries. It indicates that there are mechanisms to control cache behavior.
Based on these issues, it's clear that Prefect has some features to manage cache at a task level. You might be able to achieve task dependency by using custom cache_key_fn
functions that consider the state of other tasks or potentially by manipulating the task_run_state_cache
directly.
Unfortunately, no explicit solution for your specific requirement was found in the issues, and it may require some creativity in using caching functions along with Prefect's state handling.
For your scenario, you can consider this approach:
- Create a custom cache_key_fn
for task B that checks the state of task A.
- When task A runs, store its state in a way that it can be accessed by the caching function of task B.
- In the caching function for B, apply logic to determine whether to use the cached value or not, depending on the state of task A.
Note that this will likely involve creating a custom caching strategy and orchestrating the caching logic between tasks, and it might need specific handling in your Prefect flow's code. If this approach doesn't suit you, or you need more guidance, I recommend reaching out to the Prefect community or opening a discussion on the Prefect GitHub repository.