Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Add better error message and type checks #83

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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