Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ckuhtz committed Jul 16, 2024
1 parent 227770e commit 754746f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 0 additions & 3 deletions api/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# implement REST API using FastAPI

import os
import sys
import logging
from fastapi import FastAPI
Expand Down Expand Up @@ -34,8 +33,6 @@

# check env and use defaults if not present

logger.info(os.environ())

env = check_env_vars(logger=logger)

# add REST routes
Expand Down
13 changes: 6 additions & 7 deletions api/tooling/check_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ def check_env_vars(logger: Logger) -> Dict:
'LOG_LEVEL': 'info'
}

all_env_vars = dict(os.environ)

env = {}

for var in vars:
if var not in os.environ:
logger.info(f'{var} = \'{var_defaults[var]}\' (default)')
# The problematic exiting of fastapi/uvicorn/gunicorn and restart behavior means
# we will populate anything not specified in required with a sane default and leave it
# to the user to override if they have other ideas of what's sane. Bailing is not an option.
if not all_env_vars[var]:
env[var] = var_defaults[var]
logger.info(f'{var} = \'{env[var]}\' (default)')
else:
logger.info(f'{var} = \'{os.environ(var)}\'')
env[var] = os.environ(var)
env[var] = all_env_vars[var]
logger.info(f'{var} = \'{env[var]}\'')
return env

0 comments on commit 754746f

Please sign in to comment.