Hello - if I run the same task function multiple t...
# prefect-getting-started
d
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
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()
🙌 1
d
nice thanks!