https://prefect.io logo
j

justabill

02/07/2023, 2:00 PM
billy mays But wait there's more! Yesterday, we shipped an off-cycle bonus release, 2.7.12. In addition to squashing a few bugs, the release included a highly anticipated requested feature - custom flow and task run names 🎉! A new keyword argument (
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:
Copy code
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:
Copy code
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.
🙌 9
🔥 24
👍 10
🎉 7
P 8
7
gratitude thank you 8
📣 7
🎉 7
🚀 3
🥳 7
🦜 1
👍🏻 1
ooh 5