<@ULVA73B9P> Using FlowRunContext, how would I get...
# ask-marvin
d
@Marvin Using FlowRunContext, how would I get the name of a deployment?
m
thought for 183.8 seconds
Short answer: you don’t. In Prefect 3.x,
FlowRunContext
doesn’t expose deployment info. Use the runtime API instead. Example:
Copy code
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