Hi! I want to set the runtime name of a task depen...
# prefect-community
a
Hi! I want to set the runtime name of a task depending on one of the arguments, without having to set name on every function call. Basically what is the Prefect 2 equivalent of the prefect 1 code below
Copy code
from prefect import task, Flow


def foo(x):
    return _foo(x, task_args=dict(name=x))


@task(task_run_name="{x}")
def _foo(x):
    print(x)


with Flow("flow") as flow:
    foo('a') # should be named 'a' 
    foo('b') # should be named 'b'

flow()
1
Never mind, the with_options(name=x) in the _foo call seems to do the job
upvote 1
n
yep spot on, that's what I would recommend for that