<@ULVA73B9P> Is there a way to rename the flow run...
# ask-marvin
d
@Marvin Is there a way to rename the flow run in the process of its execution somehow without the API "patch" call to Prefect?
m
thought for 139.3 seconds
Short answer: no — not through a supported in-process runtime API. In Prefect 3.x, a flow run’s name is intended to be set once, right before the run enters
Running
. After that, there isn’t a built-in
prefect
runtime helper like “rename this flow run now” that avoids talking to the API. Supported way to set the name Use
flow_run_name
on the
@flow
decorator:
Copy code
python
from prefect import flow

@flow(flow_run_name="customer-{customer_id}")
def my_flow(customer_id: str):
    ...
or with a callable:
Copy code
python
from prefect import flow
from datetime import datetime

def make_name():
    return f"run-{datetime.utcnow().strftime('%Y%m%d-%H%M%S')}"

@flow(flow_run_name=make_name)
def my_flow():
    ...
A couple caveats: - String templates can use flow parameters - The name is applied near the start of execution, before
Running
- There’s no supported “change it later during execution” API except updating the run through the client/server API If you do want to rename mid-run, that effectively means an API update, e.g. via the Prefect client (
update_flow_run
/
set_flow_run_name
), which still results in a PATCH to the server. So if your requirement is specifically without an API PATCH call: I don’t think Prefect supports that. Relevant source/docs: - Flow run naming docs: Flow run names -
@flow
API reference: prefect.flows - Prefect source showing runtime name application in the flow engine: flow_engine.py If you want, I can also suggest a few patterns to simulate this without renaming the run itself, like: - logging a changing “display name” - storing progress metadata elsewhere - encoding dynamic context into artifacts or task run names