<@ULVA73B9P> My flow's code contains as a decorato...
# ask-marvin
r
@Marvin My flow's code contains as a decorator :
Copy code
@flow(
    description="...",
    name="iuep-pipeline",
    flow_run_name="iuep-pipeline-{org_id}",
)
And in my prefect.yaml :
Copy code
- name: "iuep-pipeline-{{ $ORG_ID }}"
    tags:
      - "{{ $TENANT_ID }}"
      - "{{ $ORG_ID }}"
    entrypoint: app/flows/iuep_pipeline.py:iuep_pipeline
    work_pool:
      name: "{{ $WORK_POOL_NAME }}"
      job_variables: 
        env: *env-vars
    parameters:
      org_id: "{{ $ORG_ID }}"
    schedules:
        - cron: "{{ $SCHEDULE_CRON }}"
          slug: "scheduled-iuep"
          timezone: "{{ $SCHEDULE_TIMEZONE }}"
          active: true
    pull:
      - prefect.deployments.steps.set_working_directory:
          directory: /app
So as you can see, I've configure the flow name, the flow run name and the slug name of that scheduled deployment set to
scheduled-iuep
but the next run flow run name is a random name, why ? how can I use the defined flow run name template ? sBut when I deploy it and I go to the UI, I can see my deployment with the right name, the scheduling name set to
m
thought for 508.4 seconds
Short answer: this is expected. In Prefect 3.x, the
flow_run_name
template on the
@flow
decorator is applied by the worker when the flow actually starts. The UI will show a randomly generated placeholder for “Next run” and scheduled runs until the run begins; then it’s renamed to your template (e.g.,
iuep-pipeline-<org_id>
). A couple of notes specific to your config: - The schedule
slug: "scheduled-iuep"
is just an identifier for the schedule, not the run name. - The deployment
name
is the deployment’s name, also not the run name. - The
@flow(flow_run_name="iuep-pipeline-{org_id}")
is the correct way to template run names; it will use the run’s parameters. If you still see a random name after the run starts, double-check: - Your flow signature has a parameter named exactly
org_id
, e.g.:
Copy code
@flow(
      description="...",
      name="iuep-pipeline",
      flow_run_name="iuep-pipeline-{org_id}",
  )
  def iuep_pipeline(org_id: str):
      ...
- Your deployment is passing that parameter (which you are with
parameters: { org_id: "{{ $ORG_ID }}" }
). - At runtime,
org_id
is actually present. You can log/verify:
Copy code
from prefect import get_run_context

  @flow(flow_run_name="iuep-pipeline-{org_id}")
  def iuep_pipeline(org_id: str):
      ctx = get_run_context()
      print("Flow parameters:", ctx.parameters)  # should include 'org_id'
Optional: If you need to programmatically set or adjust the name during the run, you can do so:
Copy code
from prefect.client.orchestration import get_client
from prefect.runtime import flow_run

@flow
def iuep_pipeline(org_id: str):
    with get_client(sync_client=True) as client:
        client.set_flow_run_name(flow_run.id, f"iuep-pipeline-{org_id}")
Docs for reference: - Custom flow run names - prefect.runtime.flow_run Can you confirm whether the name remains random after the run starts, and share your flow function signature if so? That will help pinpoint if the template isn’t resolving (usually due to a parameter name mismatch).