Hello - if I run the same task function multiple times in a loop (with different kwargs is the reason), am I able to specify task names? It defaults to task-name-0, task-name-1, etc
n
Nate
05/02/2024, 1:10 AM
hey @Drew Hibbard! yes you can give
task_run_name
a template string that can reference / render your task's parameters
Copy code
In [1]: from prefect import task
In [2]: @task(task_run_name="{x}")
...: def foo(x: str):
...: pass
...:
In [3]: for i in "abc":
...: foo(i)
...:
20:10:33.386 | INFO | prefect.engine - Created task run 'foo-84148b01' for task 'foo'
20:10:35.648 | INFO | Task run 'a' - Finished in state Completed()
20:10:35.863 | INFO | prefect.engine - Created task run 'foo-d4caecd8' for task 'foo'
20:10:36.310 | INFO | Task run 'b' - Finished in state Completed()
20:10:36.515 | INFO | prefect.engine - Created task run 'foo-91b8a5b2' for task 'foo'
20:10:36.966 | INFO | Task run 'c' - Finished in state Completed()
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.