Anton L.
09/03/2024, 11:27 AMMarvin
09/03/2024, 11:27 AMAnton L.
09/03/2024, 11:28 AMMarvin
09/03/2024, 11:28 AMflow_run_name
parameter. It can be a static name or dynamically generated using a function. After that, run your flow as usual from the command line.
Here's a basic example for static and dynamic naming:
1. Static Name:
python
from prefect import flow
@flow(flow_run_name="Static-Flow-Run-Name")
def my_flow():
print("Running the flow...")
if __name__ == "__main__":
my_flow()
2. Dynamic Name using a Function:
python
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():
print("Running the flow...")
if __name__ == "__main__":
my_flow()
You can execute your flow using the command line, and it will respect the defined naming conventions:
sh
python my_flow.py
For more glorious details, you can review the Prefect 2.x documentation here.
Wasn't that fun?