<#4503 [BUG] Can't retrieve env vars from pyflyte ...
# flytekit
a
#4503 [BUG] Can't retrieve env vars from pyflyte run Issue created by jiwidi Describe the bug I am not able to retrieve env pars passed to pyflyte run with the --env/--envvars parameter. They are not accessible within the workflow code. Basing myself on documentation https://docs.flyte.org/projects/flytekit/en/latest/pyflyte.html and issue #4092 where it mentions its possibility. Expected behavior To pass env vars to pyflyte run and access them during code execution time Additional context to reproduce I have a python file main.py:
Copy code
from flytekit import task, workflow
import os

@workflow
def workflow() -> None:
    print([key for key in os.environ])
    print(os.environ["DUMMY_KEY"])
    return None
Which can be run with
pyflyte run --envvars '{"DUMMY_KEY"="DUMMY_VALUE"}' main.py workflow
or
pyflyte run --env '{"DUMMY_KEY"="DUMMY_VALUE"}' main.py workflow
Both result in failure:
Copy code
Failed with Unknown Exception <class 'KeyError'> Reason: "Error encountered while executing 'workflow':\n  'DUMMY_KEY'"
"Error encountered while executing 'workflow':\n  'DUMMY_KEY'"
Due to the line at print(os.environ["DUMMY_KEY"]) and no presence of DUMMY_KEY in the list of os.ENVIRON Screenshots No response Are you sure this issue hasn't been raised already? ☑︎ Yes Have you read the Code of Conduct? ☑︎ Yes flyteorg/flyte