Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
enable setting of specific enum
Browse files Browse the repository at this point in the history
  • Loading branch information
mmacata committed Jun 16, 2020
1 parent 3a685c5 commit 9791e8d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions actinia_gdi/core/gmodulesActinia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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() )'
Expand Down Expand Up @@ -214,13 +215,17 @@ 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)
self.input_dict[vp.module_id]["gparams"][newkey] = {}
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():
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down
24 changes: 24 additions & 0 deletions actinia_gdi/templates/pc_templates/add_enumeration.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 9791e8d

Please sign in to comment.