Commit b5c53008 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

make sure input file, output file and parameter are correctly written down

parent 6791a785
...@@ -63,7 +63,9 @@ class Workflow(threading.Thread): ...@@ -63,7 +63,9 @@ class Workflow(threading.Thread):
STATUS_COMPLETED = "completed" STATUS_COMPLETED = "completed"
STATUS_FAILED = "failed" STATUS_FAILED = "failed"
STATUS_ABORTED = "aborted" STATUS_ABORTED = "aborted"
INPUTFILE_TYPES = ["inputfile", "localfile", "urlfile", "browsefile"]
def __init__(self, args={}, id=None, function= "process", parameters_section=None): def __init__(self, args={}, id=None, function= "process", parameters_section=None):
""" """
""" """
...@@ -117,9 +119,11 @@ class Workflow(threading.Thread): ...@@ -117,9 +119,11 @@ class Workflow(threading.Thread):
self.set_stderr() self.set_stderr()
self._serialize() self._serialize()
def add_input_file(self, name, help, file_format="any", default=None, type=types.StringType, choices=None, def add_input_file(self, name, help, file_format="any", default=None, type="inputfile", choices=None,
required=False, flag=None, group="default", display_name=None, is_list=False, add_to=None): required=False, flag=None, group="default", display_name=None, is_list=False, add_to=None):
if type not in self.INPUTFILE_TYPES:
raise ValueError("Workflow.add_input_file: wrong type provided: '"+type+"', this should be choosen between '"
+ "', '".join(self.INPUTFILE_TYPES)+"'")
if is_list: if is_list:
if default == None: default = [] if default == None: default = []
new_param = InputFileList(name, help, flag=flag, file_format=file_format, default=default, type=type, new_param = InputFileList(name, help, flag=flag, file_format=file_format, default=default, type=type,
...@@ -137,14 +141,14 @@ class Workflow(threading.Thread): ...@@ -137,14 +141,14 @@ class Workflow(threading.Thread):
self.params_order.append(name) self.params_order.append(name)
self.__setattr__(name, new_param) self.__setattr__(name, new_param)
def add_output_file(self, name, help, file_format="any", default=None, type=types.StringType, choices=None, def add_output_file(self, name, help, file_format="any", default=None, choices=None, required=False,
required=False, flag=None, group="default", display_name=None, is_list=False, add_to=None): flag=None, group="default", display_name=None, is_list=False, add_to=None):
if is_list: if is_list:
if default == None: default = [] if default == None: default = []
new_param = OutputFileList(name, help, flag=flag, file_format=file_format, default=default, type=type, new_param = OutputFileList(name, help, flag=flag, file_format=file_format, default=default, type="localfile",
choices=choices, required=required, group=group, display_name=display_name) choices=choices, required=required, group=group, display_name=display_name)
else: else:
new_param = OutputFile(name, help, flag=flag, file_format=file_format, default=default, type=type, new_param = OutputFile(name, help, flag=flag, file_format=file_format, default=default, type="localfile",
choices=choices, required=required, group=group, display_name=display_name) choices=choices, required=required, group=group, display_name=display_name)
# if this input should be added to a particular parameter # if this input should be added to a particular parameter
if add_to: if add_to:
...@@ -166,6 +170,9 @@ class Workflow(threading.Thread): ...@@ -166,6 +170,9 @@ class Workflow(threading.Thread):
def add_parameter(self, name, help, default=None, type=types.StringType, choices=None, required=False, def add_parameter(self, name, help, default=None, type=types.StringType, choices=None, required=False,
flag=None, group="default", display_name=None, is_list=False, add_to=None): flag=None, group="default", display_name=None, is_list=False, add_to=None):
if type in self.INPUTFILE_TYPES:
raise ValueError("Workflow.add_parameter: wrong type provided: '"+type+"', this should not be choosen between '"
+ "', '".join(self.INPUTFILE_TYPES)+"'")
if is_list: if is_list:
if default == None: default = [] if default == None: default = []
new_param = ParameterList(name, help, flag=flag, default=default, type=type, choices=choices, new_param = ParameterList(name, help, flag=flag, default=default, type=type, choices=choices,
...@@ -227,7 +234,12 @@ class Workflow(threading.Thread): ...@@ -227,7 +234,12 @@ class Workflow(threading.Thread):
choices=param.choices, required=param.required, flag=param.flag, choices=param.choices, required=param.required, flag=param.flag,
group=param.group, display_name=param.display_name) group=param.group, display_name=param.display_name)
self.__setattr__(param.name, new_param) self.__setattr__(param.name, new_param)
elif param.__class__ == ParameterList or param.__class__ == InputFileList: elif param.__class__ == OutputFile:
new_param = OutputFile(param.name, param.help, file_format=param.file_format, default=args[param.name], type=param.type,
choices=param.choices, required=param.required, flag=param.flag,
group=param.group, display_name=param.display_name)
self.__setattr__(param.name, new_param)
elif param.__class__ == ParameterList or param.__class__ == InputFileList or param.__class__ == OutputFileList:
self.__getattribute__(param.name).extend(args[param.name]) self.__getattribute__(param.name).extend(args[param.name])
elif param.__class__ == MultiParameter: elif param.__class__ == MultiParameter:
sub_args = {} sub_args = {}
...@@ -238,6 +250,8 @@ class Workflow(threading.Thread): ...@@ -238,6 +250,8 @@ class Workflow(threading.Thread):
self.__getattribute__(param.name)[sub_param.name] = sub_args[sub_param.flag] self.__getattribute__(param.name)[sub_param.name] = sub_args[sub_param.flag]
else: else:
self.__getattribute__(param.name)[sub_param.name] = self.__getattribute__(param.name).default[sub_param.name] self.__getattribute__(param.name)[sub_param.name] = self.__getattribute__(param.name).default[sub_param.name]
elif param.__class__ == MultiParameterList:
print args[param.name]
def _download_urlfile(self, input): def _download_urlfile(self, input):
try: try:
......
...@@ -70,8 +70,9 @@ class WorkflowsManager(object): ...@@ -70,8 +70,9 @@ class WorkflowsManager(object):
for class_name, obj in inspect.getmembers(sys.modules[modname], inspect.isclass): for class_name, obj in inspect.getmembers(sys.modules[modname], inspect.isclass):
if issubclass(obj, jflow.workflow.Workflow) and obj.__name__ != jflow.workflow.Workflow.__name__: if issubclass(obj, jflow.workflow.Workflow) and obj.__name__ != jflow.workflow.Workflow.__name__:
# try to build the workflow # try to build the workflow
try: wf_instances.append(obj(parameters_section=parameters_section)) wf_instances.append(obj(parameters_section=parameters_section))
except: pass #try: wf_instances.append(obj(parameters_section=parameters_section))
#except: pass
return wf_instances return wf_instances
def rerun_workflow(self, workflow_id): def rerun_workflow(self, workflow_id):
......
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