<@ULVA73B9P> is it possible to overwrite the flow ...
# ask-marvin
d
@Marvin is it possible to overwrite the flow run name from within the flow code?
m
In Prefect, you can indeed overwrite the flow run name from within the flow code. This feature is supported in both Prefect 2.x and 3.x. For Prefect 2.x, you can define a function that returns a string which will be used as the 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

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.