Hello folks, i am trying to find a way to give a f...
# ask-community
a
Hello folks, i am trying to find a way to give a flow runs a name (currently its generated dynamically in prefect, see screenshot) Is there a way i can configure a flow run name in a code? I don’t see any parameter in
flow.register()
I looked into the documentation but couldn’t find it.
g
There's no parameter for this in
flow.register()
because you're wanting to set a flow run name (not the flow name). Flows are registered once and then can be run an arbitrary number of times afterwards, each run would get a different name. To specify the flow run name you could: • provide the name in the UI when starting a new run; • provide the name as a parameter when running the CLI or with a GraphQL mutation (https://docs.prefect.io/orchestration/flow-runs/creation.html#flow-run-names) • use
prefect.tasks.prefect.StartFlowRun
or
prefect.tasks.prefect.create_flow_run
and provide the
run_name
parameter: https://docs.prefect.io/api/latest/tasks/prefect.html#startflowrun
r
if you want to rename a flow run based on another task you can use this:
Copy code
@task
def rename_flow_task(name: str):
    flow_run_id = prefect.context.get("flow_run_id")

    client = prefect.Client()
    return client.set_flow_run_name(flow_run_id, name)
a
Thanks @Greg Roche and @Robert Hales. this helps 🙏