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
...@@ -235,34 +235,35 @@ class WorkflowJob(object): ...@@ -235,34 +235,35 @@ class WorkflowJob(object):
the size of the list. the size of the list.
""" """
arg_value = self._get_arg_value(arg_name, arg_info) arg_value = self._get_arg_value(arg_name, arg_info)
if arg_info["type"] == "numeric": if arg_value is not None:
# We need this as two seperate if statements otherwise we try if arg_info["type"] == "numeric":
# to interpolate numeric arguments # We need this as two seperate if statements otherwise we try
if not is_number(arg_value): # to interpolate numeric arguments
return (False, "[Error parsing job %s]: Argument '%s' with value '%s' must be numeric." % (self, arg_name, arg_value)) if not is_number(arg_value):
elif arg_info["type"] in chipathlon.conf.argument_types["file"]: return (False, "[Error parsing job %s]: Argument '%s' with value '%s' must be numeric." % (self, arg_name, arg_value))
# If the argument is a rawfile, validate it's extension & existance elif arg_info["type"] in chipathlon.conf.argument_types["file"]:
if arg_info["type"] == "rawfile": # If the argument is a rawfile, validate it's extension & existance
if os.path.isfile(arg_value): if arg_info["type"] == "rawfile":
if not arg_value.endswith(tuple(chipathlon.conf.file_extensions[arg_info["file_type"]])): if os.path.isfile(arg_value):
return (False, "[Error parsing job %s] Argument '%s' with file path '%s' is not of file type '%s'. \ if not arg_value.endswith(tuple(chipathlon.conf.file_extensions[arg_info["file_type"]])):
Should match one of these extensions: %s." % ( return (False, "[Error parsing job %s] Argument '%s' with file path '%s' is not of file type '%s'. \
self, Should match one of these extensions: %s." % (
arg_name, self,
arg_value, arg_name,
arg_info["file_type"], arg_value,
chipathlon.conf.file_extensions[arg_info["file_type"]] arg_info["file_type"],
chipathlon.conf.file_extensions[arg_info["file_type"]]
)
) )
) else:
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))
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
# If the argument is a 'regular' file, we need to make sure that it # references one of the keys of the inputs / outputs
# references one of the keys of the inputs / outputs elif not arg_value.startswith("$"):
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))
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("$"):
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)]):
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 (False, "[Error parsing job %s]: Argument '%s' has reference '%s'. No such input / output exists." % (self, arg_name, arg_value))
return (True, None) return (True, None)
def _get_arg_value(self, arg_name, arg_info): def _get_arg_value(self, arg_name, arg_info):
...@@ -285,10 +286,10 @@ class WorkflowJob(object): ...@@ -285,10 +286,10 @@ class WorkflowJob(object):
elif "path" in arg_info: elif "path" in arg_info:
return self._get_path(arg_info["path"]) + arg_info["default"] return self._get_path(arg_info["path"]) + arg_info["default"]
else: else:
return arg_info["default"] return arg_info.get("default")
else: else:
if arg_info["has_value"]: if arg_info["has_value"]:
return arg_info["default"] return arg_info.get("default")
elif "path" in arg_info: elif "path" in arg_info:
return self._get_path(arg_info["path"]) + arg_name return self._get_path(arg_info["path"]) + arg_name
else: else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment