Commit 53a98dca authored by Jerome Mariette's avatar Jerome Mariette
Browse files

handle exclusive groups

parent 4eb4af43
......@@ -134,6 +134,16 @@ if __name__ == '__main__':
if group == "default":
for param in parameters_groups[group]:
sub_parser.add_argument(param.flag, **param.export_to_argparse())
elif group.startswith("exclude-"):
is_required = False
for param in parameters_groups[group]:
if param.required:
is_required = True
# an exlcusive parameter cannot be required, the require is at the group level
param.required = False
pgroup = sub_parser.add_mutually_exclusive_group(required=is_required)
for param in parameters_groups[group]:
pgroup.add_argument(param.flag, **param.export_to_argparse())
else:
pgroup = sub_parser.add_argument_group(group)
for param in parameters_groups[group]:
......
......@@ -312,7 +312,7 @@ class Workflow(threading.Thread):
reader.read(self._get_property_path())
parameters, param_order = [], []
try:
params, sub_order = {}, {}
params, sub_order, excludes, hash_params = {}, {}, [], {}
# first grab all parameters name
for param in reader.items(self.parameters_section):
cvalue = reader.get(self.parameters_section, param[0])
......@@ -334,6 +334,7 @@ class Workflow(threading.Thread):
for param in params[param_name]:
sub_params_values = param.split(".")
if len(sub_params_values) == 2:
# TODO: handle exclusive for sub parameter
key = None
if sub_params_values[1] == "name":
key = "display_name"
......@@ -346,6 +347,16 @@ class Workflow(threading.Thread):
sub_params[sub_params_values[0]][key] = params[param_name][param]
else:
if param == "name": current_params["display_name"] = params[param_name][param]
elif param == "exclude":
found = False
for exclude_group in excludes:
if param_name in exclude_group:
exclude_group.append(params[param_name][param])
found = True
elif params[param_name][param] in exclude_group:
exclude_group.append(param_name)
found = True
if not found: excludes.append([param_name, params[param_name][param]])
else: current_params[param] = params[param_name][param]
current_params["name"] = param_name
if sub_order.has_key(param_name):
......@@ -355,6 +366,12 @@ class Workflow(threading.Thread):
current_params["sub_parameters"] = sub_objs
oparam = Parameter(**current_params)
parameters.append(oparam)
hash_params[oparam.name] = oparam
# overwrite the group to exclude some parameters
for i, exclude_group in enumerate(excludes):
group_name = "exclude-"+str(i)
for param in set(exclude_group):
hash_params[param].group = group_name
except:
pass
# finally add the metadata parameter
......
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