justabill
flow_run_name
for flows, task_run_name
for tasks) accepts a string that will be used to create a run name for each run of the function. For example:
from datetime import datetime
from prefect import flow, task
@task(task_run_name="custom-static-name")
def my_task(name):
print(f"hi {name}")
@flow(flow_run_name="custom-but-fixed-name")
def my_flow(name: str, date: datetime):
return my_task(name)
my_flow()
In order to make these names dynamic, you can template them using the parameter names of the task or flow function, using all of the basic rules of Python string formatting as follows:
from datetime import datetime
from prefect import flow, task
@task(task_run_name="{name}")
def my_task(name):
print(f"hi {name}")
@flow(flow_run_name="{name}-on-{date:%A}")
def my_flow(name: str, date: datetime):
return my_task(name)
my_flow()
Check out the Prefect release notes for more information.