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

fix a bug with default parameters

parent ad1dca7b
...@@ -220,14 +220,16 @@ class Workflow(threading.Thread): ...@@ -220,14 +220,16 @@ class Workflow(threading.Thread):
def _set_parameters(self, args): def _set_parameters(self, args):
parameters = self.get_parameters() parameters = self.get_parameters()
for param in parameters: for param in parameters:
if args[param.name]: try: args[param.name] = args[param.name].encode('ascii','ignore')
try: args[param.name] = args[param.name].encode('ascii','ignore') except: pass
except: pass if param.__class__ == Parameter:
if param.__class__ == Parameter: if args[param.name]: default = args[param.name]
new_param = Parameter(param.name, param.help, default=args[param.name], type=param.type, choices=param.choices, else: default = param.default
required=param.required, flag=param.flag, group=param.group, display_name=param.display_name) new_param = Parameter(param.name, param.help, default=default, type=param.type, choices=param.choices,
self.__setattr__(param.name, new_param) required=param.required, flag=param.flag, group=param.group, display_name=param.display_name)
elif param.__class__ == InputFile: self.__setattr__(param.name, new_param)
elif param.__class__ == InputFile:
if args[param.name]:
# handle url inputs # handle url inputs
default, is_uri = self._download_urlfile(args[param.name]) default, is_uri = self._download_urlfile(args[param.name])
# handle upload inputs # handle upload inputs
...@@ -235,11 +237,14 @@ class Workflow(threading.Thread): ...@@ -235,11 +237,14 @@ class Workflow(threading.Thread):
except: is_local = False except: is_local = False
if not is_uri and not is_local and param.type.__name__ == "inputfile" or param.type.__name__ == "browsefile": if not is_uri and not is_local and param.type.__name__ == "inputfile" or param.type.__name__ == "browsefile":
default = os.path.join(self.jflow_config_reader.get_tmp_directory(), (args[param.name])) default = os.path.join(self.jflow_config_reader.get_tmp_directory(), (args[param.name]))
new_param = InputFile(param.name, param.help, file_format=param.file_format, default=default, type=param.type, else:
choices=param.choices, required=param.required, flag=param.flag, default = param.default
group=param.group, display_name=param.display_name) new_param = InputFile(param.name, param.help, file_format=param.file_format, default=default, type=param.type,
self.__setattr__(param.name, new_param) choices=param.choices, required=param.required, flag=param.flag,
elif param.__class__ == InputFileList: group=param.group, display_name=param.display_name)
self.__setattr__(param.name, new_param)
elif param.__class__ == InputFileList:
if args[param.name]:
path2test = args[param.name] path2test = args[param.name]
if not path2test.__class__.__name__ == "list": if not path2test.__class__.__name__ == "list":
path2test = [path2test] path2test = [path2test]
...@@ -260,28 +265,29 @@ class Workflow(threading.Thread): ...@@ -260,28 +265,29 @@ class Workflow(threading.Thread):
for path in path2test: for path in path2test:
default_vals.append(os.path.join(self.jflow_config_reader.get_tmp_directory(), (path))) default_vals.append(os.path.join(self.jflow_config_reader.get_tmp_directory(), (path)))
self.__getattribute__(param.name).extend(default_vals) self.__getattribute__(param.name).extend(default_vals)
elif param.__class__ == ParameterList: elif param.__class__ == ParameterList:
if args[param.name]:
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 = {}
for sarg in args[param.name]: for sarg in args[param.name]:
sub_args[sarg[0]] = sarg[1]
for sub_param in param.sub_parameters:
if sub_args.has_key(sub_param.flag):
self.__getattribute__(param.name)[sub_param.name] = sub_args[sub_param.flag]
else:
self.__getattribute__(param.name)[sub_param.name] = sub_param.default
elif param.__class__ == MultiParameterList:
for sargs in args[param.name]:
sub_args, final_sub_args = {}, {}
for sarg in sargs:
sub_args[sarg[0]] = sarg[1] sub_args[sarg[0]] = sarg[1]
for sub_param in param.sub_parameters: for sub_param in param.sub_parameters:
if sub_args.has_key(sub_param.flag): if sub_args.has_key(sub_param.flag):
self.__getattribute__(param.name)[sub_param.name] = sub_args[sub_param.flag] final_sub_args[sub_param.name] = sub_args[sub_param.flag]
else: else:
self.__getattribute__(param.name)[sub_param.name] = sub_param.default final_sub_args[sub_param.name] = sub_param.default
elif param.__class__ == MultiParameterList: self.__getattribute__(param.name).append(final_sub_args)
for sargs in args[param.name]:
sub_args, final_sub_args = {}, {}
for sarg in sargs:
sub_args[sarg[0]] = sarg[1]
for sub_param in param.sub_parameters:
if sub_args.has_key(sub_param.flag):
final_sub_args[sub_param.name] = sub_args[sub_param.flag]
else:
final_sub_args[sub_param.name] = sub_param.default
self.__getattribute__(param.name).append(final_sub_args)
def get_execution_graph(self): def get_execution_graph(self):
graph = Graph() graph = Graph()
......
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