Robert Szomolanyi
05/14/2026, 11:24 AMMarvin
05/14/2026, 11:24 AMMarvin
05/14/2026, 11:26 AMFlowRun object that run_deployment() returns.
run_deployment() returns a FlowRun, which includes flow_id, not flow_name. To get the flow name, read the flow by that ID.
Example:
python
from prefect.deployments import run_deployment
from prefect.client.orchestration import get_client
flow_run = run_deployment(
name="my-flow/my-deployment",
timeout=0,
)
with get_client(sync_client=True) as client:
flow = client.read_flow(flow_run.flow_id)
flow_name = flow.name
print(flow_name)
If you're in async code:
python
from prefect.deployments import run_deployment
from prefect.client.orchestration import get_client
async def main():
flow_run = await run_deployment(
name="my-flow/my-deployment",
timeout=0,
)
async with get_client() as client:
flow = await client.read_flow(flow_run.flow_id)
return flow.name
A few details:
- flow_run.name = the flow run name
- flow_run.flow_id = the underlying flow's ID
- flow.name = the flow name you want
So the short answer is:
- No, run_deployment() does not return flow_name directly
- Yes, you can retrieve it immediately afterward using flow_run.flow_id
Relevant docs:
- `run_deployment` API
- Prefect client API
If you want, I can also show you how to get the deployment name + flow name in one helper function.