Del
12/10/2024, 11:00 PMMarvin
12/10/2024, 11:01 PMpython
import datetime
from prefect import flow
def generate_flow_run_name():
date = datetime.datetime.now(datetime.timezone.utc)
return f"{date:%A}-is-a-nice-day"
@flow(flow_run_name=generate_flow_run_name)
def my_flow(name: str):
pass
if __name__ == "__main__":
my_flow(name="marvin")
This code sets the flow run name dynamically using the current date, creating a flow run with a name like "Thursday-is-a-nice-day". More details can be found in the Prefect 2.x documentation here.
For Prefect 3.x, you also define the flow name similarly, using the @flow
decorator. The flow is a container for your workflow logic that can track metadata such as run time and state. You can see more on defining flow runs in the Prefect 3.x documentation here.
So, whether you're living in a 2.x or 3.x world, Prefect's got you covered for customizing your flow run names! It's almost as easy as asking an AI if it wants a cup of tea.