diff --git a/actinia_gdi/core/gmodulesActinia.py b/actinia_gdi/core/gmodulesActinia.py index f72d4c4..8fa05cb 100644 --- a/actinia_gdi/core/gmodulesActinia.py +++ b/actinia_gdi/core/gmodulesActinia.py @@ -157,6 +157,7 @@ def __init__(self, val, param, module, module_id): self.module_id = module_id # import_training_data self.comment = None self.run_interface_descr = False + self.enum = None # matches placeholder in longer value, e.g. in # 'res = if(input <= {{ my_values }}, 1, null() )' @@ -214,6 +215,8 @@ def collect_value_placeholders(self, vp): self.input_dict[vp.module_id]["gparams"][vp.key]['amkey'] = vp.placeholders[0] if vp.comment is not None: self.input_dict[vp.module_id]["gparams"][vp.key]['comment'] = vp.comment + if vp.enum is not None: + self.input_dict[vp.module_id]["gparams"][vp.key]['enum'] = vp.enum else: for amkey in vp.placeholders: newkey = "%s_%s" % (vp.key, amkey) @@ -221,6 +224,8 @@ def collect_value_placeholders(self, vp): self.input_dict[vp.module_id]["gparams"][newkey]['amkey'] = amkey if vp.comment is not None: self.input_dict[vp.module_id]["gparams"][newkey]['comment'] = vp.comment + if vp.enum is not None: + self.input_dict[vp.module_id]["gparams"][newkey]['enum'] = vp.enum def collect_im_and_exporter_placeholders(self, vp, j, im_or_export): for key, val in j[im_or_export].items(): @@ -288,6 +293,8 @@ def loop_list_items(self, i): vp = ValuePlaceholder(val, j['param'], module, module_id) if 'comment' in j: vp.comment = j['comment'] + if 'enum' in j: + vp.enum = j['enum'] if ('{{ ' in val and ' }}' in val and val not in self.aggregated_vals): @@ -324,6 +331,10 @@ def populate_vm_params_and_returns(self, gm, pc): amkey = self.aks[ak]['amkey'] self.vm_params[amkey] = gm['parameters'][param] + if 'enum' in self.aks[param]: + enum = self.aks[param]['enum'] + self.vm_params[amkey]['schema']['enum'] = enum + add_param_description( self.vm_params[amkey], param, self.aks) diff --git a/actinia_gdi/templates/pc_templates/add_enumeration.json b/actinia_gdi/templates/pc_templates/add_enumeration.json new file mode 100644 index 0000000..9b99243 --- /dev/null +++ b/actinia_gdi/templates/pc_templates/add_enumeration.json @@ -0,0 +1,24 @@ +{ + "id": "add_enumeration", + "description": "Example PC to add possible values", + "template": { + "list": [ + { + "id": "group_input_of_classification", + "module": "i.group", + "inputs": [ + { + "param": "group", + "value": "classificationinput" + }, + { + "param": "input", + "enum": ["B02","B03","B04","B08","ndvi"], + "value": "{{ classificationinput }}" + } + ] + } + ], + "version": "1" + } +}