https://prefect.io logo
n

Nico Neumann

08/11/2023, 7:39 PM
How do I get the deployed name of the flow inside the flow? I deploy the flow with a different name, than in the flow decorator. The flow is shown with the modified name in Prefect cloud. But when I run the flow, it shows me the original name instead of the modified one.
Copy code
from prefect import flow
from prefect.context import get_run_context
from prefect.deployments import Deployment, run_deployment


@flow(name="a", log_prints=True)
def my_flow_a():
    # always prints "a" even if I start flow b in prefect cloud
    print(get_run_context().flow.name)


my_flow_b = my_flow_a.with_options(name="b")

Deployment.build_from_flow(
    flow=my_flow_b,
    name="deployment",
    apply=True,
)

run_deployment(name="b/deployment")
d

Deceivious

08/14/2023, 1:24 PM
run_context