Moishe
02/05/2025, 8:30 PMfrom prefect import flow, task
@flow
def my_flow():
for i in range(0, 4):
task_n(i)
@task()
def task_n(i:int):
print(i)
if __name__ == "__main__":
my_flow()
I'm trying to see the input passed to task_n
(I expect i=0
, i=1
, etc) but for all the tasks, the input is displayed as:
{
"i": []
}
I also executed:
prefect config set PREFECT_RESULTS_PERSIST_BY_DEFAULT=true
and got the same result.
This happens whether I'm running a local server or using the cloud server.
I feel like I'm missing something super obvious, any hints?Marvin
02/05/2025, 8:30 PMPREFECT_RESULTS_PERSIST_BY_DEFAULT=true
enables result persistence, which ensures that task results are stored and can be retrieved later. However, this setting alone doesn't affect how inputs are displayed or passed to tasks. More on result persistence here.
2. Common Gotchas: In Prefect 3.x, there are some key changes and common pitfalls:
- Prefect 3.x uses Pydantic 2, which might affect how data types are handled.
- Ensure that task inputs are appropriately typed and that you're not facing a type mismatch issue.
3. Debugging Steps:
- Double-check that the task
decorator is properly applied and that there are no hidden syntax errors.
- Try logging the input i
directly within the task_n
function to see if it prints correctly before reaching Prefect's internal handling.
4. Further Investigation: If the problem persists, consider exploring the Prefect GitHub repository for any open issues related to task input handling in Prefect 3.x.
If none of these suggestions resolve the issue, it might be worth raising a bug report with the Prefect team. You can also explore the Prefect GitHub repository for similar issues or updates.Nate
02/05/2025, 8:31 PMNate
02/05/2025, 8:32 PMNate
02/05/2025, 8:32 PMMoishe
02/05/2025, 8:33 PMMoishe
02/05/2025, 8:33 PMMoishe
02/05/2025, 8:34 PMNate
02/05/2025, 8:34 PMcache_policy
might be something to check out
https://docs.prefect.io/v3/develop/task-caching#configure-task-cachingNate
02/05/2025, 8:35 PMMoishe
02/05/2025, 8:36 PMMoishe
02/05/2025, 8:37 PMMoishe
02/05/2025, 8:38 PM