Skip to content

Commit

Permalink
validates module's name
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomcteixeira committed Jan 3, 2022
1 parent 7d621ba commit 3eda188
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/haddock/gear/prepare_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def setup_run(workflow_path, restart_from=None):
# read config
params = read_config(workflow_path)

validate_module_names_are_not_mispelled(params)

# update default non-mandatory parameters with user params
params = {**non_mandatory_general_parameters_defaults, **params}

Expand Down Expand Up @@ -333,3 +335,16 @@ def inject_in_modules(modules_params, key, value):
"Can't inject."
)
params[key] = value


def validate_module_names_are_not_mispelled(params):
"""Validate headers are not mispelled."""
module_names = sorted(modules_category.keys())
for param_name, value in params.items():
if isinstance(value, dict):
if get_module_name(param_name) not in module_names:
emsg = (
f"Module {param_name!r} is not a valid module name. "
f"Valid modules are: {', '.join(module_names)}."
)
raise ValueError(emsg)

0 comments on commit 3eda188

Please sign in to comment.