Commit db6244b7 authored by aknecht2's avatar aknecht2
Browse files

Updated workflow_module code to work with both param types.

parent 2a473169
......@@ -114,28 +114,32 @@ class WorkflowModule(object):
valid = False
return (valid, msg)
def _load_required_files(self, markers, prefix = None, master_files = {}):
input_files = []
def _load_required_params(self, markers, prefix = None, master_files = {}):
inputs = []
additional_files = []
output_files = []
job_list = self._get_data_list(self.workflow, markers)
for job_dict in job_list:
job_name = job_dict.keys()[0]
job_info = job_dict[job_name]
for file_type, file_list in zip(["inputs", "additional_inputs", "outputs"], [input_files, additional_files, output_files]):
if job_info[file_type] is not None:
for file_id in job_info[file_type]:
if file_id not in file_list and file_id not in output_files:
if prefix is None or self._get_full_name(prefix, markers, file_id) in master_files:
file_list.append(file_id)
return (input_files, additional_files, output_files)
def get_files(self, markers, prefix = None, master_files = {}):
for param_type, param_list in zip(["inputs", "additional_inputs", "outputs"], [inputs, additional_files, output_files]):
if job_info[param_type] is not None:
for param in job_info[param_type]:
param_name = param.keys()[0]
if param["type"] == "file":
if param_name not in file_list and param_name not in output_files:
if prefix is None or self._get_full_name(prefix, markers, param_name) in master_files:
param_list.append({"name": param_name, "type": "file"})
else:
param_list.append({"name": param_name, "type": "argument"})
return (inputs, additional_files, output_files)
def get_params(self, markers, prefix = None, master_files = {}):
valid, msg = self._check_input_markers(markers)
if valid:
input_files, additional_files, output_files = self._load_required_files(markers, prefix = prefix, master_files = master_files)
inputs, additional_files, output_files = self._load_required_params(markers, prefix = prefix, master_files = master_files)
return valid, {
"inputs": input_files,
"inputs": inputs,
"additional_files": additional_files,
"output_files": output_files
}
......@@ -154,7 +158,7 @@ class WorkflowModule(object):
"""
valid = True
msg = ""
valid, msg, module_files = self._check_files(master_files, prefix, markers, inputs, additional_files)
valid, msg, module_files = self._check_params(master_files, prefix, markers, inputs, additional_files)
self._traverse_jobs(dax, master_jobs, master_files, prefix, markers, inputs, additional_files)
return
......@@ -210,26 +214,28 @@ class WorkflowModule(object):
dax.depends(child = job, parent = master_jobs[file_dict["name"]])
return
def _check_files(self, master_files, prefix, markers, inputs, additional_files):
def _check_params(self, master_files, prefix, markers, inputs, additional_files):
valid = True
msg = ""
data = ""
valid, module_files = self.get_files(markers, prefix, master_files)
valid, module_params = self.get_params(markers, prefix, master_files)
if valid:
data = module_files
for arg_params, file_key in zip([inputs, additional_files], ["inputs", "additional_files"]):
# Only consider file arguments
for file_name in [arg_param for arg_param in arg_params if arg_param["type"] == "file"]:
if file_name not in module_files[file_key]:
data = module_params
for arg_params, param_key in zip([inputs, additional_files], ["inputs", "additional_files"]):
for file_dict in [arg_param for arg_param in arg_params if arg_param["type"] == "file"]:
file_name = file_dict["name"]
if file_name not in module_params[param_key]:
valid = False
msg += "Error loading '%s' jobs. Supplied file with name '%s' does not exist in module %s.\n" % (self.name, file_name, file_key)
if arg_files[file_name] not in master_files:
msg += "Error loading '%s' jobs. Supplied file with name '%s' does not exist in module %s.\n" % (self.name, file_name, param_key)
if arg_params[file_name] not in master_files:
valid = False
msg += "Error loading '%s' jobs. File with name '%s', value '%s', does not exist in master_files.\n" % (self.name, file_name, arg_files[file_name])
for file_name in module_files[file_key]:
if file_name not in arg_files:
valid = False
msg += "Error loading '%s' jobs. Required file '%s' for %s not defined.\n" % (self.name, file_name, file_key)
msg += "Error loading '%s' jobs. File with name '%s', value '%s', does not exist in master_files.\n" % (self.name, file_name, arg_params[file_name])
for param_dict in module_params[param_key]:
if param_dict["type"] == "file":
file_name = param_dict["name"]
if file_name not in arg_files:
valid = False
msg += "Error loading '%s' jobs. Required file '%s' for %s not defined.\n" % (self.name, file_name, param_key)
else:
valid = False
msg += "Error loading '%s' jobs. Could not load files.\n" % (self.name,)
......
Supports Markdown
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