Joël Luijmes

01/19/2021, 3:29 PM
How can I make a distinction (run-time) to see wether I’m running the flow directly or from the agent / server? Case: when running on production (i.e. from the kubernetes agent) it should perform a task (actually its a resource manager) - which deploys a cloudsql proxy and connect through that proxy - but if I’m developing I want to connect with localhost database. In theory, its fine if I deploy the cloudsql proxy (resource manager) while developing the flow, but I still need to know at runtime if which hostname it should use to connect with the database.
Could I use the
Copy code
if __name__ == "__main__":
check maybe? And, actually construct a different flow when running the script locally vs. when its triggered from the server?


01/19/2021, 4:02 PM
Yeah that is one way you could do it! Another thing I have seen people do is using either environment variables or Prefect Secrets. e.g. Having a local environment variable set for the host and then in your RunConfig having a different one when running w/ the server.

Joël Luijmes

01/20/2021, 7:31 AM
Ohm.. of course, makes sense 😅 thanks 🙂