Skip to content
Snippets Groups Projects
Commit e2daefe0 authored by aknecht2's avatar aknecht2
Browse files

Fixed a validation error with jobs with non-required arguments. Trying to...

Fixed a validation error with jobs with non-required arguments.  Trying to evaluate numeric types without a value.
parent eb4146a3
No related branches found
No related tags found
1 merge request!34Resolve "Zerone"
......@@ -235,34 +235,35 @@ class WorkflowJob(object):
the size of the list.
"""
arg_value = self._get_arg_value(arg_name, arg_info)
if arg_info["type"] == "numeric":
# We need this as two seperate if statements otherwise we try
# to interpolate numeric arguments
if not is_number(arg_value):
return (False, "[Error parsing job %s]: Argument '%s' with value '%s' must be numeric." % (self, arg_name, arg_value))
elif arg_info["type"] in chipathlon.conf.argument_types["file"]:
# If the argument is a rawfile, validate it's extension & existance
if arg_info["type"] == "rawfile":
if os.path.isfile(arg_value):
if not arg_value.endswith(tuple(chipathlon.conf.file_extensions[arg_info["file_type"]])):
return (False, "[Error parsing job %s] Argument '%s' with file path '%s' is not of file type '%s'. \
Should match one of these extensions: %s." % (
self,
arg_name,
arg_value,
arg_info["file_type"],
chipathlon.conf.file_extensions[arg_info["file_type"]]
if arg_value is not None:
if arg_info["type"] == "numeric":
# We need this as two seperate if statements otherwise we try
# to interpolate numeric arguments
if not is_number(arg_value):
return (False, "[Error parsing job %s]: Argument '%s' with value '%s' must be numeric." % (self, arg_name, arg_value))
elif arg_info["type"] in chipathlon.conf.argument_types["file"]:
# If the argument is a rawfile, validate it's extension & existance
if arg_info["type"] == "rawfile":
if os.path.isfile(arg_value):
if not arg_value.endswith(tuple(chipathlon.conf.file_extensions[arg_info["file_type"]])):
return (False, "[Error parsing job %s] Argument '%s' with file path '%s' is not of file type '%s'. \
Should match one of these extensions: %s." % (
self,
arg_name,
arg_value,
arg_info["file_type"],
chipathlon.conf.file_extensions[arg_info["file_type"]]
)
)
)
else:
return (False, "[Error parsing job %s]: Argument '%s' is a rawfile, however the specified path '%s' does not exist. " % (self, arg_name, arg_value))
# If the argument is a 'regular' file, we need to make sure that it
# references one of the keys of the inputs / outputs
elif not arg_value.startswith("$"):
return (False, "[Error parsing job %s]: Argument '%s' has value '%s'. File references must start with a '$'." % (self, arg_name, arg_value))
elif isinstance(arg_value, str) and arg_value.startswith("$"):
if not any([str(arg_value)[1:] == ref for ref in (self.valid_inputs + self.valid_outputs)]):
return (False, "[Error parsing job %s]: Argument '%s' has reference '%s'. No such input / output exists." % (self, arg_name, arg_value))
else:
return (False, "[Error parsing job %s]: Argument '%s' is a rawfile, however the specified path '%s' does not exist. " % (self, arg_name, arg_value))
# If the argument is a 'regular' file, we need to make sure that it
# references one of the keys of the inputs / outputs
elif not arg_value.startswith("$"):
return (False, "[Error parsing job %s]: Argument '%s' has value '%s'. File references must start with a '$'." % (self, arg_name, arg_value))
elif isinstance(arg_value, str) and arg_value.startswith("$"):
if not any([str(arg_value)[1:] == ref for ref in (self.valid_inputs + self.valid_outputs)]):
return (False, "[Error parsing job %s]: Argument '%s' has reference '%s'. No such input / output exists." % (self, arg_name, arg_value))
return (True, None)
def _get_arg_value(self, arg_name, arg_info):
......@@ -285,10 +286,10 @@ class WorkflowJob(object):
elif "path" in arg_info:
return self._get_path(arg_info["path"]) + arg_info["default"]
else:
return arg_info["default"]
return arg_info.get("default")
else:
if arg_info["has_value"]:
return arg_info["default"]
return arg_info.get("default")
elif "path" in arg_info:
return self._get_path(arg_info["path"]) + arg_name
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment