Is there a way to create a task that's reused with different parameters, that for each use is given ...
h
Is there a way to create a task that's reused with different parameters, that for each use is given a different name that then appears in the schematic visualization? I thought that doing
@task(task_run_name="{name_val}")
and then passing in a name_val variable would do it, but in the dashboard everything is still showing up as the name of the function definition
k
Hey @Harry Baker, I’ll try this myself
I think I know what you’re saying. There are two schematics in the
Flow Schematic
and the
Flow Run Schematic
. The Flow Schematic is created during build time when the template values are not there yet, so of course it can’t reflect the templated name. But the
Flow Run Schematic
will. Here is a sample flow:
Copy code
from prefect import task, Flow

@task(task_run_name="{name_val}")
def test(x, name_val):
    return x + 1

with Flow("task_name") as flow:
    test(1, name_val="test1")
    test(2, name_val="test2")
    test(3, name_val="test3")
    test(4, name_val="test4")

flow.register("dremio")
If you go to the Flow Run page, the schematic will reflect “test1”, “test2", “test3”, “test4"
h
oh, I see. is there any way to have the names correctly show up in the flow schematic, or would this require custom defining specific tasks
k
It would require @task(name=“”)
h
gotcha. ok thank you!