Skip to content

Commit 5eb8e14

Browse files
authored
Merge pull request #384 from sthaha/fix-config-read
fix: ignore whitespaces in config files
2 parents ef88478 + ba4043e commit 5eb8e14

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)