thankful-father-61351
07/17/2023, 1:03 PMvictorious-lawyer-58417
07/17/2023, 1:35 PMIncludeFile
Or you can include them directly as environment variables with @environmentstale-vegetable-18192
07/17/2023, 3:39 PMsquare-wire-39606
07/17/2023, 3:50 PMstale-vegetable-18192
07/17/2023, 4:07 PMthankful-father-61351
07/17/2023, 7:54 PMthankful-father-61351
07/17/2023, 9:56 PM@environment(vars={"STEP_VAR": f"{os.getenv('MSG')} from container"}) (this would have been the answer to my original question 🙂). Very strange, since I had not been able to do this (!!), and I was not even able to reproduce the example when I tried to do this loosely.
The reason, it turns out, was because I used what I expected to be equivalent, os.environ['MSG'] , which raises a KeyError instead of defaulting to None. This matter apparently! Any idea why this is?? 🤔
Bonus info: If I replace the environment decorator above with @environment(vars={"STEP_VAR": f'{print("MSG:", os.environ.get("MSG", "DOES NOT EXISTS!!!")) or os.environ.get("MSG")} from container/local'}) then everything works, but it prints “DOES NOT EXISTS!!!” twice for every step. Both the local and the container steps.thankful-father-61351
07/20/2023, 7:30 AMancient-application-36103
07/20/2023, 3:45 PMos.environ['foo'] will raise a KeyError if foo doesn't exist as an env varthankful-father-61351
07/20/2023, 4:01 PMos.environ["FOO"] to work just as well as os.getenv("FOO") , ie. I would not expect these to behave differently (fails vs runs successfully) in the case where FOO exists as an environment variable in the process that runs the flow.ancient-application-36103
07/20/2023, 4:07 PMf"{os.getenv('MSG')} from container"} is also executed locally where the environment variable might not be presentthankful-father-61351
07/20/2023, 4:08 PMexport MSG=something .ancient-application-36103
07/20/2023, 4:14 PMprint statement gets evaluated for every step resulting in multiple printsancient-application-36103
07/20/2023, 4:14 PMancient-application-36103
07/20/2023, 4:17 PM@environment(vars={"STEP_VAR": os.environ["MSG"]}) to a step and running MSG=foo python flow.py run works as expected for meancient-application-36103
07/20/2023, 4:18 PMthankful-father-61351
07/20/2023, 4:20 PMthankful-father-61351
07/20/2023, 4:21 PMos.getenv("FOO") with os.environ["FOO"]ancient-application-36103
07/20/2023, 4:23 PMread_locally step or as args to the @environment ?ancient-application-36103
07/20/2023, 4:26 PMancient-application-36103
07/20/2023, 4:28 PMos.getenv(...) while we resolve the issue for remote executionthankful-father-61351
07/20/2023, 10:17 PM