Skip to content

Commit

Permalink
Merge pull request #384 from sthaha/fix-config-read
Browse files Browse the repository at this point in the history
fix: ignore whitespaces in config files
  • Loading branch information
rootfs authored Aug 20, 2024
2 parents ef88478 + ba4043e commit 5eb8e14
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/kepler_model/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@
SERVE_SOCKET = "/tmp/estimator.sock"


def getConfig(key, default):
def getConfig(key: str, default):
# check configmap path
file = os.path.join(CONFIG_PATH, key)
if os.path.exists(file):
with open(file, "r") as f:
return f.read()
return f.read().strip()
# check env
return os.getenv(key, default)
cfg = os.environ.get(key, default)
if type(cfg) is str:
return cfg.strip()
return cfg


def getPath(subpath):
Expand Down

0 comments on commit 5eb8e14

Please sign in to comment.