https://prefect.io logo
r

Robert Rehner

08/03/2023, 3:28 PM
I want to call a task multiple times with different parameters. In order to distinguish them in the logs I would like to give each task run a different name. Any idea how to do it? If I define the name in
@task
then I can not change it. I tried using
with_options(name="task name")
or
set_name("task name")
but both do not work
r

redsquare

08/03/2023, 3:30 PM
Copy code
import pendulum
from prefect import task, flow

@task(task_run_name="{greeting}-{name}")
def my_task(name, greeting="hi"):
    print(f"{greeting} {name}!")

@flow(flow_run_name="{date:%A}-run")
def my_flow(date):
    return my_task(name="chris")

my_flow(date=pendulum.now())
1
❤️ 3
r

Robert Rehner

08/03/2023, 3:32 PM
looks fancy, I have to try this
It Works. Thanks!!
👍 1