The flow run name can not be set in advance, but it can be changed using the RenameFlowRun task after the flow run has been created.
You can use this task inside the Flow block or through a flow-level state handler. When calling the task from a state handler, make sure to call the task’s
Here is a flow-level state handler example:
from prefect import Flow, task from prefect.tasks.prefect import RenameFlowRun def rename_handler(flow, new_state, old_state): if new_state.is_running(): RenameFlowRun().run(flow_run_name="new_name") return @task def first_task(): return 1 with Flow("test-flow", state_handlers=[rename_handler]) as flow: first_task()