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
Andreas Nord
09/06/2022, 3:18 PM
Never mind, the with_options(name=x) in the _foo call seems to do the job
upvote 1
n
Nate
09/06/2022, 3:20 PM
yep spot on, that's what I would recommend for that
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.