Skip to content

Commit b4b9868

Browse files
author
Sunil Thaha
committed
fix: ignore whitespaces in MODEL_CONFIG file
This commit trims whitespaces including newlines when reading the MODEL_CONFIG file. Signed-off-by: Sunil Thaha <[email protected]>
1 parent 5eb8e14 commit b4b9868

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/kepler_model/util/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ def get_model_server_list_endpoint():
112112
# set_env_from_model_config: extract environment values based on environment key MODEL_CONFIG
113113
def set_env_from_model_config():
114114
model_config = getConfig("MODEL_CONFIG", "")
115-
if model_config != "":
116-
lines = model_config.splitlines()
117-
for line in lines:
118-
splits = line.split("=")
119-
if len(splits) > 1:
120-
os.environ[splits[0]] = splits[1]
121-
print("set {} to {}.".format(splits[0], splits[1]))
115+
if not model_config:
116+
return
117+
118+
for line in model_config.splitlines():
119+
splits = line.split("=")
120+
if len(splits) > 1:
121+
os.environ[splits[0].strip()] = splits[1].strip()
122+
print("set {} to {}.".format(splits[0], splits[1]))
122123

123124

124125
def is_estimator_enable(prefix):
@@ -156,4 +157,3 @@ def get_init_model_url(energy_source, output_type, model_topurl=model_topurl):
156157
return modelURL
157158
print("no match config for {}, {}".format(output_type, energy_source))
158159
return ""
159-

0 commit comments

Comments
 (0)