<@ULVA73B9P> how do i set the name of a flow_run?
# ask-marvin
j
@Marvin how do i set the name of a flow_run?
m
To set the name of a flow run in Prefect, you can provide a custom name using the
flow_run_name
parameter in the flow decorator. This capability is available in both Prefect 2.x and 3.x. Here is a basic example:
Copy code
python
from prefect import flow

@flow(flow_run_name="my-custom-flow-run")
def my_flow():
    pass

# This flow will be called 'my-custom-flow-run' on execution
my_flow()
You can also use a function to dynamically generate a flow run name. Here's an example:
Copy code
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(name: str):
    pass

# This will create a flow run with a name like 'Thursday-is-a-nice-day'
my_flow(name="marvin")
If you need to use information from the flow itself or its parameters,
prefect.runtime.flow_run
can be utilized to access this information and incorporate it into your flow run name. #### References - Prefect 2.x Documentation: Flow Concepts - Prefect 3.x Documentation: Writing Flows These links provide more detailed information on how to work with flow run names in their respective versions. If you have any more questions or need further assistance, feel free to ask!