Skip to content

Commit c3f2cf9

Browse files
committed
Add check for when user sets an envvars: variable incorrectly
1 parent a3216d4 commit c3f2cf9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

ush/setup.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def load_config_for_setup(ushdir, default_config_path, user_config_path):
6161
invalid sections/keys or (3) it does not contain mandatory information or (4)
6262
an invalid datetime format is used.
6363
"""
64+
logger = logging.getLogger(__name__)
6465

6566
ushdir = Path(ushdir)
6667

@@ -115,6 +116,17 @@ def load_config_for_setup(ushdir, default_config_path, user_config_path):
115116
default_workflow = ushdir.parent / "parm" / "wflow" / "default_workflow.yaml"
116117
workflow_config = get_yaml_config(default_workflow)
117118

119+
# Check user config for envvars not placed in the envvars section
120+
errmsg=''
121+
for section in user_config:
122+
if envvars:=default_config[section].get("envvars"):
123+
for k,v in envvars.items():
124+
if k in user_config[section]:
125+
errmsg+=f"\n{section}:{k} should be {section}:envvars:{k}"
126+
if errmsg:
127+
logger.critical("Found invalid variable(s) in user config:")
128+
raise ValueError(errmsg)
129+
118130
# Update default config with other loaded config file. Order matters.
119131
for cfg in (
120132
constants,

0 commit comments

Comments
 (0)