Skip to content

Commit ba4043e

Browse files
author
Sunil Thaha
committed
fix: ignore whitespaces in config files
This commit trims whitespaces including newlines when reading config files. Thus ... MODEL_SERVER_ENABLE containing `true\n` will evaluate to `true` Signed-off-by: Sunil Thaha <[email protected]> (cherry picked from commit d3798c6e3959b88b3564c454db5bfde6e3f3e2b6)
1 parent ef88478 commit ba4043e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/kepler_model/util/config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@
4141
SERVE_SOCKET = "/tmp/estimator.sock"
4242

4343

44-
def getConfig(key, default):
44+
def getConfig(key: str, default):
4545
# check configmap path
4646
file = os.path.join(CONFIG_PATH, key)
4747
if os.path.exists(file):
4848
with open(file, "r") as f:
49-
return f.read()
49+
return f.read().strip()
5050
# check env
51-
return os.getenv(key, default)
51+
cfg = os.environ.get(key, default)
52+
if type(cfg) is str:
53+
return cfg.strip()
54+
return cfg
5255

5356

5457
def getPath(subpath):

0 commit comments

Comments
 (0)