Skip to content

Commit

Permalink
Set empty components in runscript to empty dictionary and give out a …
Browse files Browse the repository at this point in the history
…warning via user_note.
  • Loading branch information
nwieters committed Aug 18, 2023
1 parent 789ad40 commit 04bd9dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/esm_parser/esm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,23 @@ def initialize_from_yaml(filepath):
)
return user_config

def check_for_empty_components_in_user_config(user_config):
for model in list(user_config):
if user_config[model] is None or user_config[model] == "" or not user_config[model]:
user_note(
f"Warning: YAML syntax",
f"The component ``{model}`` in your configuration "
f"file ``{user_config['general']['runscript_abspath']}`` is empty. "
"No further variables are set for this component in your runscript."
)
user_config[model] = {}
return user_config

def complete_config(user_config):
if not "general" in user_config:
user_config["general"] = {}
user_config["general"]["additional_files"] = []
user_config = check_for_empty_components_in_user_config(user_config)

while True:
for model in list(user_config):
Expand Down
2 changes: 0 additions & 2 deletions src/esm_parser/yaml_to_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ def yaml_file_to_dict(filepath):
yaml_load["computer"]["runtime_environment_changes"][
"add_export_vars"
] = add_export_vars
# Check for empty components/models
check_for_empty_components(yaml_load, filepath + extension)
return yaml_load
except IOError as error:
logger.debug(
Expand Down

0 comments on commit 04bd9dc

Please sign in to comment.