Hi community! I have a question regarding how and when environment variables are pulled, and whether I need to pass environment variables to an agent or not. If I have the following python script for a flow
Copy code
import os
from prefect import task
@task
def get_env():
return os.environ.get("CURRENT_ENV")
with Flow(name="get-env") as flow:
env = get_env()
flow.register(project="get_env")
and I have “CURRENT_ENV” in my bash/zsh environment variables, and run the flow in with a LocalAgent, then it’s not necessary to pass any environment variables when I execute
prefect agent local start
because the environment variable is already in the local system.
But if wanted to run the flow in a non-local environment, say in a Dask cluster in Kubernetes, then I would need to pass environment variables to
prefect agent kubernetes start
?
k
Kevin Kho
04/16/2021, 6:07 PM
Hello again @Julio Venegas! Yes you can pass it upon agent start
j
Julio Venegas
04/16/2021, 6:14 PM
Hi Kevin! 😄 sweet, I hadn’t read those two key bullet points, thank you! so envs passed at agent start are available for all flows in the relevant environment 👌
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.