Romain Lefebvre
12/08/2025, 4:21 PMMarvin
12/08/2025, 4:21 PMMarvin
12/08/2025, 4:29 PMflow_run_name template is applied by the engine when the run actually starts (i.e., as it transitions to RUNNING). That’s why you only see the “real” name once it’s RUNNING, and why it’s not available during pull steps.
A few practical ways to work around this for your frontend:
- Set the run name up-front when you create the run
- If you’re triggering programmatically, you can pass a name that will be set immediately and won’t be replaced by the template:
from prefect.deployments.flow_runs import run_deployment
flow_run = await run_deployment(
name="my-flow/my-deployment",
parameters={"source": "acme"},
flow_run_name="ingest-acme-2025-12-08T12:00Z",
# optional: tags=["source:acme"]
)
- If you’re calling the REST API, use the “create flow run from deployment” endpoint and include a name in the payload; it will be used at creation time.
- Immediately update the run name after you create it
- If your frontend already creates the run and gets the run ID back, you can rename it right away so your UI shows the right name before RUNNING:
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import FlowRunUpdate
async def set_name(flow_run_id: str, new_name: str):
async with get_client() as client:
await client.update_flow_run(flow_run_id, FlowRunUpdate(name=new_name))
- Tag runs for early discoverability
- If you can’t set the name at creation, consider adding a tag like source:acme when you create the run. Your frontend can show/filter by that tag immediately, then swap to the final name when the run transitions to RUNNING. The Python helper above accepts tags=... and the REST endpoint accepts tags as well.
Questions to help me tailor the best fix:
- Are you on Prefect 3.x?
- How are you triggering runs from your frontend (Python client, REST, or CLI)?
- Are you able to compute the final name in your frontend (e.g., based on the same parameters you pass)? If so, setting it at creation will give you the exact behavior you want.
If it’d be helpful, I can also sketch the exact REST call payload for your setup.