https://prefect.io logo
k

Krzysztof Nawara

07/21/2021, 4:49 PM
Is it possible to check (from inside the task) if the flow is being executed locally, without agent or it it's being executed in Prefect Server/Cloud by an agent? E.g. by looking up some property in the context?
k

Kevin Kho

07/21/2021, 4:52 PM
Hey @Krzysztof Nawara, you can do
if prefect.config.backend != "cloud":
Actually no that only distinguishes between cloud and server. Let me think for the agent.
k

Krzysztof Nawara

07/21/2021, 5:04 PM
👍
k

Kevin Kho

07/21/2021, 5:08 PM
Use
prefect.context.get("running_with_backend")
. This does not exist for
flow.run()
calls.
k

Krzysztof Nawara

07/21/2021, 5:25 PM
Thanks!