From c0390ff7a4292c92bc621db1c1e9fcbc95eaf126 Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Fri, 31 Jan 2025 15:34:26 -0600 Subject: [PATCH 1/3] be explicit about intended behavior --- docs/v3/develop/task-caching.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/v3/develop/task-caching.mdx b/docs/v3/develop/task-caching.mdx index 681e04a12de9..6bb5a43aa24b 100644 --- a/docs/v3/develop/task-caching.mdx +++ b/docs/v3/develop/task-caching.mdx @@ -68,7 +68,7 @@ Prefect comes prepackaged with a few common cache policies: - `DEFAULT`: this cache policy uses the task's inputs, its code definition, as well as the prevailing flow run ID to compute the task's cache key. - `INPUTS`: this cache policy uses _only_ the task's inputs to compute the cache key. -- `TASK_SOURCE`: this cache policy uses _only_ the task's code definition to compute the cache key. +- `TASK_SOURCE`: this cache policy uses _only_ the task's code definition (and **not** source code of nested tasks) to compute the cache key. - `FLOW_PARAMETERS`: this cache policy uses _only_ the parameter values provided to the parent flow run to compute the cache key. - `NO_CACHE`: this cache policy always returns `None` and therefore avoids caching and result persistence altogether. From 04cd10f07e65a025f09297a00ef7e78b8f411273 Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Fri, 31 Jan 2025 15:35:25 -0600 Subject: [PATCH 2/3] update docstring --- src/prefect/cache_policies.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/prefect/cache_policies.py b/src/prefect/cache_policies.py index 61dfc4f91219..7266d1c6dfb9 100644 --- a/src/prefect/cache_policies.py +++ b/src/prefect/cache_policies.py @@ -252,6 +252,8 @@ def __add__(self, other: "CachePolicy") -> "CachePolicy": class TaskSource(CachePolicy): """ Policy for computing a cache key based on the source code of the task. + + This policy only considers raw lines of code in the task, and not the source code of nested tasks. """ def compute_key( From c78efe2f11b1b9b13314b1fc92ddd49caf57fe23 Mon Sep 17 00:00:00 2001 From: nate nowack Date: Fri, 31 Jan 2025 15:45:06 -0600 Subject: [PATCH 3/3] Update docs/v3/develop/task-caching.mdx --- docs/v3/develop/task-caching.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/v3/develop/task-caching.mdx b/docs/v3/develop/task-caching.mdx index 6bb5a43aa24b..21ac82e10e80 100644 --- a/docs/v3/develop/task-caching.mdx +++ b/docs/v3/develop/task-caching.mdx @@ -68,7 +68,7 @@ Prefect comes prepackaged with a few common cache policies: - `DEFAULT`: this cache policy uses the task's inputs, its code definition, as well as the prevailing flow run ID to compute the task's cache key. - `INPUTS`: this cache policy uses _only_ the task's inputs to compute the cache key. -- `TASK_SOURCE`: this cache policy uses _only_ the task's code definition (and **not** source code of nested tasks) to compute the cache key. +- `TASK_SOURCE`: this cache policy only considers raw lines of code in the task (and not the source code of nested tasks) to compute the cache key. - `FLOW_PARAMETERS`: this cache policy uses _only_ the parameter values provided to the parent flow run to compute the cache key. - `NO_CACHE`: this cache policy always returns `None` and therefore avoids caching and result persistence altogether.