Skip to content

Commit

Permalink
All extra validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tianjing-li committed Jan 21, 2025
1 parent 8b6b418 commit f07f7a0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/backend/model_deployments/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ def get_deployment_config_var(var_name: str, default: str, **kwargs: Any) -> str
"""
ctx = kwargs.get("ctx")
db_config = kwargs.get("db_config", {})
config = None

# Get Request Header value
ctx_deployment_config = ctx.deployment_config if ctx else {}
config = ctx_deployment_config.get(var_name)

# Return immediately with a valid config
if config:
return config
if ctx_deployment_config:
config = ctx_deployment_config.get(var_name)

# Check if DB config exists, otherwise use default
config = db_config.get(var_name, default)
if not config:
# Check if DB config exists, otherwise use default
config = db_config.get(var_name, default)

# After all fallbacks, if config is still invalid
if not config:
raise ValueError(f"Missing deployment config variable: {var_name}")

Expand Down

0 comments on commit f07f7a0

Please sign in to comment.