Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed May 30, 2023
1 parent 57da075 commit c8ec8bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions flytekit/clis/sdk_in_container/pyflyte.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from flytekit.clis.sdk_in_container.run import run
from flytekit.clis.sdk_in_container.serialize import serialize
from flytekit.clis.sdk_in_container.serve import serve
from flytekit.configuration.file import FLYTECTL_CONFIG_ENV_VAR
from flytekit.configuration.file import FLYTECTL_CONFIG_ENV_VAR, FLYTECTL_CONFIG_ENV_VAR_OVERRIDE
from flytekit.configuration.internal import LocalSDK
from flytekit.exceptions.base import FlyteException
from flytekit.exceptions.user import FlyteInvalidInputException
Expand Down Expand Up @@ -124,10 +124,10 @@ def main(ctx, pkgs: typing.List[str], config: str, verbose: bool):
cfg = configuration.ConfigFile(config)
# Set here so that if someone has Config.auto() in their user code, the config here will get used.
if FLYTECTL_CONFIG_ENV_VAR in os.environ:
print(
cli_logger.info(
f"Config file arg {config} will override env var {FLYTECTL_CONFIG_ENV_VAR}: {os.environ[FLYTECTL_CONFIG_ENV_VAR]}"
)
os.environ[FLYTECTL_CONFIG_ENV_VAR] = config
os.environ[FLYTECTL_CONFIG_ENV_VAR_OVERRIDE] = config
if not pkgs:
pkgs = LocalSDK.WORKFLOW_PACKAGES.read(cfg)
if pkgs is None:
Expand Down
9 changes: 7 additions & 2 deletions flytekit/configuration/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

# This is the env var that the flytectl sandbox instructions say to set
FLYTECTL_CONFIG_ENV_VAR = "FLYTECTL_CONFIG"
# This is an explicit override only to be used by pyflyte and takes precedence in get_config_file over the main
# environment variable.
# This env var should not be set by users
FLYTECTL_CONFIG_ENV_VAR_OVERRIDE = "_FLYTECTL_CONFIG_PYFLYTE_OVERRIDE"


def _exists(val: typing.Any) -> bool:
Expand Down Expand Up @@ -239,8 +243,9 @@ def get_config_file(c: typing.Union[str, ConfigFile, None]) -> typing.Optional[C
Checks if the given argument is a file or a configFile and returns a loaded configFile else returns None
"""
if c is None:
# Env var always takes the highest precedence
flytectl_path_from_env = getenv(FLYTECTL_CONFIG_ENV_VAR, None)
# Pyflyte override env var takes highest precedence
# Env var takes second highest precedence
flytectl_path_from_env = getenv(FLYTECTL_CONFIG_ENV_VAR_OVERRIDE, getenv(FLYTECTL_CONFIG_ENV_VAR, None))
if flytectl_path_from_env:
flytectl_path = Path(flytectl_path_from_env)
if flytectl_path.exists():
Expand Down

0 comments on commit c8ec8bb

Please sign in to comment.