Skip to content

Commit

Permalink
minor improvement to config validate/format
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Oct 9, 2017
1 parent 3d6e067 commit 3463787
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion atomic_hpc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from atomic_hpc import config_yaml, deploy_runs, mockssh, context_folder, utils

__version__ = "0.1.7"
__version__ = "0.1.8"

13 changes: 9 additions & 4 deletions atomic_hpc/config_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,17 @@ def format_config_yaml(file_obj, errormsg_only=False):
dct = ryaml.load(file_obj)

logger.info("validating & formatting config: {}".format(file_obj))

validate(dct, _config_schema)

try:
validate(dct, _config_schema)
except ValidationError as err:
if errormsg_only:
err = err.message
raise ValidationError("error in top-level config: {0}".format(err))

runs = []
defaults = edict.merge([_global_defaults, dct.get('defaults', {})], overwrite=True)


for i, run in enumerate(dct['runs']):

new_run = edict.merge([defaults, run], overwrite=True)
Expand All @@ -210,7 +215,7 @@ def format_config_yaml(file_obj, errormsg_only=False):

if new_run["input"] is not None:
all_none = True
if new_run["input"]["remote"]["hostname"] is None:
if new_run["input"]["remote"] is not None and new_run["input"]["remote"]["hostname"] is None:
new_run["input"]["remote"] = None
for field in ["remote", "path", "scripts", "files", "variables"]:
if new_run["input"][field] is not None:
Expand Down

0 comments on commit 3463787

Please sign in to comment.