Fix nesting of repeats and error when repeat is provided literally.

This fixex #7048, where in addition to repeat values
('repeat_0|param: some_value') there are also values
for the repeat param itself ('repeat': []).
This commit is contained in:
mvdbeek
2018-12-04 13:41:32 +01:00
parent 9aaafd8aea
commit cf25f7dcec
+12 -8
View File
@@ -72,26 +72,30 @@ def expand_workflow_inputs(inputs):
return params, params_keys
def process_key(incoming_key, d):
def process_key(incoming_key, incoming_value, d):
key_parts = incoming_key.split('|')
if len(key_parts) == 1:
# Regular parameter
d[incoming_key] = object()
d[incoming_key] = incoming_value
elif key_parts[0].rsplit('_', 1)[-1].isdigit():
# Repeat
input_name_index = key_parts[0].rsplit('_', 1)
input_name, index = input_name_index
index = int(index)
if input_name not in d:
d[input_name] = []
subdict = {}
d[input_name].append(subdict)
process_key("|".join(key_parts[1:]), d=subdict)
if len(d[input_name]) > index:
subdict = d[input_name][index]
else:
subdict = {}
d[input_name].append(subdict)
process_key("|".join(key_parts[1:]), incoming_value=incoming_value, d=subdict)
else:
# Section / Conditional
input_name = key_parts[0]
subdict = {}
d[input_name] = subdict
process_key("|".join(key_parts[1:]), d=subdict)
process_key("|".join(key_parts[1:]), incoming_value=incoming_value, d=subdict)
def expand_meta_parameters(trans, tool, incoming):
@@ -113,9 +117,9 @@ def expand_meta_parameters(trans, tool, incoming):
# according to tool.inputs (which is ordered).
incoming_copy = incoming.copy()
nested_dict = {}
for incoming_key in incoming_copy:
for incoming_key, incoming_value in incoming_copy.items():
if not incoming_key.startswith('__'):
process_key(incoming_key, d=nested_dict)
process_key(incoming_key, incoming_value=incoming_value, d=nested_dict)
reordered_incoming = OrderedDict()