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):
def _set_parameters(self, args):
parameters = self.get_parameters()
for param in parameters:
if args[param.name]:
try: args[param.name] = args[param.name].encode('ascii','ignore')
except: pass
if param.__class__ == Parameter:
new_param = Parameter(param.name, param.help, 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__ == InputFile:
try: args[param.name] = args[param.name].encode('ascii','ignore')
except: pass
if param.__class__ == Parameter:
if args[param.name]: default = args[param.name]
else: default = param.default
new_param = Parameter(param.name, param.help, default=default, 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__ == InputFile:
if args[param.name]:
# handle url inputs
default, is_uri = self._download_urlfile(args[param.name])
# handle upload inputs
......@@ -235,11 +237,14 @@ class Workflow(threading.Thread):
except: is_local = False
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]))
new_param = InputFile(param.name, param.help, file_format=param.file_format, default=default, 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__ == InputFileList:
else:
default = param.default
new_param = InputFile(param.name, param.help, file_format=param.file_format, default=default, 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__ == InputFileList:
if args[param.name]:
path2test = args[param.name]
if not path2test.__class__.__name__ == "list":
path2test = [path2test]
......@@ -260,28 +265,29 @@ class Workflow(threading.Thread):
for path in path2test:
default_vals.append(os.path.join(self.jflow_config_reader.get_tmp_directory(), (path)))
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])
elif param.__class__ == MultiParameter:
sub_args = {}
for sarg in args[param.name]:
elif param.__class__ == MultiParameter:
sub_args = {}
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]
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]
final_sub_args[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]
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)
final_sub_args[sub_param.name] = sub_param.default
self.__getattribute__(param.name).append(final_sub_args)
def get_execution_graph(self):
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