Skip to content

Commit

Permalink
bugy#141 cleaned up parameter and script config files after spliting
Browse files Browse the repository at this point in the history
  • Loading branch information
bugy committed Feb 14, 2019
1 parent 7cc0627 commit 760d929
Show file tree
Hide file tree
Showing 8 changed files with 730 additions and 1,422 deletions.
21 changes: 21 additions & 0 deletions src/model/model_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ def read_dict(values_dict, key, default=None):
raise Exception('"' + key + '" has invalid type. Dict expected')


def read_bool_from_config(key, config_obj, *, default=None):
value = config_obj.get(key)
if value is None:
return default

if isinstance(value, bool):
return value

if isinstance(value, str):
return value.lower() == 'true'

raise Exception('"' + key + '" field should be true or false')


def read_bool(value):
if isinstance(value, bool):
return value
Expand All @@ -115,6 +129,7 @@ def normalize_incoming_values(param_values, parameters):

return normalized_values


def fill_parameter_values(parameter_configs, template, values):
result = template

Expand Down Expand Up @@ -187,3 +202,9 @@ class InvalidFileException(Exception):
def __init__(self, path, message) -> None:
super().__init__(message)
self.path = path


class InvalidValueException(Exception):
def __init__(self, param_name, validation_error) -> None:
super().__init__(validation_error)
self.param_name = param_name
Loading

0 comments on commit 760d929

Please sign in to comment.