mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-31 16:01:46 +00:00
check for nullish-ness
This commit is contained in:
parent
4074fcf83c
commit
0b22c84bb7
1 changed files with 5 additions and 8 deletions
|
@ -265,7 +265,7 @@ class EnvVarError(Exception):
|
|||
self.var_name = var_name
|
||||
self.path = path
|
||||
super().__init__(
|
||||
f"Environment variable '{var_name}' not set{f' at {path}' if path else ''}"
|
||||
f"Environment variable '{var_name}' not set or empty{f' at {path}' if path else ''}"
|
||||
)
|
||||
|
||||
|
||||
|
@ -295,14 +295,11 @@ def replace_env_vars(config: Any, path: str = "") -> Any:
|
|||
env_var = match.group(1)
|
||||
default_val = match.group(2)
|
||||
|
||||
if default_val is None:
|
||||
if env_var not in os.environ:
|
||||
value = os.environ.get(env_var)
|
||||
if not value:
|
||||
if default_val is None:
|
||||
raise EnvVarError(env_var, path)
|
||||
value = os.environ[env_var]
|
||||
else:
|
||||
# use the default if env var is "nullish"
|
||||
value = os.environ.get(env_var)
|
||||
if not value:
|
||||
else:
|
||||
value = default_val
|
||||
|
||||
return value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue