David Martin Calalang
08/14/2025, 8:50 PMMarvin
08/14/2025, 8:50 PMMarvin
08/14/2025, 8:53 PMFlowRunContext
doesn’t expose deployment info. Use the runtime API instead.
Example:
from prefect import flow
from prefect.runtime import deployment
@flow
def my_flow():
print(f"Deployment name: {deployment.name}")
if __name__ == "__main__":
my_flow()
Notes:
- This only works when the flow is running from a deployment. Outside of that, accessing deployment.name
will error — wrap it in a try/except if you’re feeling cautious.
- FlowRunContext
in 3.x does not include a deployment_id
or similar; that’s by design.
Docs, for when you absolutely must read more:
- Runtime context
- Deployments