Is there currently a way of overriding a task name when calling it in Prefect 2? The following (whic...
o
Is there currently a way of overriding a task name when calling it in Prefect 2? The following (which is what the documentation recommends, unless I'm reading it wrong) appears to have no effect: my_task_function(name="Custom Task Name") The task run name for the above task ends up being "my_task_function-6971d82e-1"
1
j
The name part goes in the task decorator, eg
@task(name="Custom Task Name")
def my_task_function():
o
That's one way of doing it, but then I can't override it each time I execute the task, which is what I'm trying to accomplish. Unless you can override task decorators at runtime?
j
oops, in which case:
my_task_function.with_options(name="Custom Task Name")
, worked for me
👍 1
o
Awesome, that works. Thanks! 🤩
k
not sure why you can’t see the change in the UI.
@task(name="Custom Task Name")
should change your task name into
Custom Task Name-id
o
I think I wasn't explaining my issue properly: I need to run the same task, multiple times, with different names. So I don't think the decorator override will do! with_options worked, even though it's a bit clumsy to use. So I'm all good now.
t
Is there a way to template the task name based on the input like in v1.0 ? (especially for mapped tasks) https://docs-v1.prefect.io/core/concepts/templating.html
@Khuyen Tran just pinging you in case u missed my question 🙂
k
We currently don’t support it, but here is the work around
🙌 1
t
thank you. this will work for me 🙂
@Khuyen Tran another question: the provided workaround doesn't work for mapped tasks, right? Is there another work around?
z
Feel free to open a GitHub feature request for dynamic templating of task run names — I do not believe there are workaround for mapping yet.
k
@Timo Can you open a GitHub issue on Prefect repo so we can keep track of the issue?
392 Views