Skip to content

Commit

Permalink
add better error message and type checks for pipeline parameters in m…
Browse files Browse the repository at this point in the history
…apping (#83)
  • Loading branch information
Henry authored Jun 20, 2023
1 parent 7e636e6 commit 2dadd26
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/scripts/create-parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,22 @@ def write_parameters_from_mappings(mappings, changes, output_path, config_path):
else:
path, param, param_value, config_file = m

try:
decoded_param_value = json.loads(param_value)
except ValueError:
raise Exception("Cannot parse pipeline value {} from mapping".format(param_value))

# type check pipeline parameters - should be one of integer, string, or boolean
if not isinstance(decoded_param_value, (int, str, bool)):
raise Exception("""
Pipeline parameters can only be integer, string or boolean type.
Found {} of type {}
""".format(decoded_param_value, type(decoded_param_value)))

regex = re.compile(r'^' + path + r'$')
for change in changes:
if regex.match(change):
filtered_mapping.append([param, json.loads(param_value)])
filtered_mapping.append([param, decoded_param_value])
if config_file:
filtered_files.add(config_file + "\n")
break
Expand Down

0 comments on commit 2dadd26

Please sign in to comment.