Skip to content

Commit

Permalink
adjust schema type and subtype of actinia processes (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
metzm authored May 5, 2021
1 parent 643a4fb commit 0863d14
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/openeo_grass_gis_driver/actinia_processing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,20 @@ def openeo_to_actinia(node: Node) -> Tuple[list, list]:
node.get_parent_by_name(
parent_name=key).output_objects)[0]
data_object = value
# check schema subtype of parameter and compare with
# datatype of data_object
if ao["schema"]["subtype"] == "cell" and \
data_object.datatype != GrassDataType.RASTER:
raise Exception(
"Wrong input data type, expecting 'cell'")
elif ao["schema"]["subtype"] == "strds" and \
data_object.datatype != GrassDataType.STRDS:
raise Exception(
"Wrong input data type, expecting 'strds'")
elif ao["schema"]["subtype"] == "vector" and \
data_object.datatype != GrassDataType.VECTOR:
raise Exception(
"Wrong input data type, expecting 'vector'")
elif ao["schema"]["type"] == "boolean":
# flag
if node.arguments[key] is True:
Expand Down
14 changes: 14 additions & 0 deletions src/openeo_grass_gis_driver/processes_process_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,22 @@ def get(self, process_id):
iface = ActiniaInterface()
module = ACTINIA_OPENEO_PROCESS_DESCRIPTION_DICT[process_id]
module_name = module["id"]
# note that this will list all outputs of a module, not the
# selected output of the pseudo module
status_code, module = iface.list_module(module_name)
if status_code == 200:
if "parameters" in module:
for item in module["parameters"]:
if "subtype" in item["schema"]:
if item["schema"]["subtype"] in ("cell", "strds"):
item["schema"]["type"] = "object"
item["schema"]["subtype"] = "raster-cube"
if "returns" in module:
for item in module["returns"]:
if "subtype" in item["schema"]:
if item["schema"]["subtype"] in ("cell", "strds"):
item["schema"]["type"] = "object"
item["schema"]["subtype"] = "raster-cube"
return make_response(jsonify(module), 200)

return make_response(
Expand Down
14 changes: 14 additions & 0 deletions src/openeo_grass_gis_driver/register_actinia_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ def register_processes():
for module in modules:
# convert grass module names to openeo process names
process = module["id"].replace('.', '_')
if "parameters" in module:
for item in module["parameters"]:
if "subtype" in item["schema"]:
if item["schema"]["subtype"] in ("cell", "strds"):
item["schema"]["type"] = "object"
item["schema"]["subtype"] = "raster-cube"
if "returns" in module:
for item in module["returns"]:
if "subtype" in item["schema"]:
if item["schema"]["subtype"] in ("cell", "strds"):
item["schema"]["type"] = "object"
item["schema"]["subtype"] = "raster-cube"
ACTINIA_PROCESS_DESCRIPTION_DICT[process] = module

# create "pseudo" modules which comply to openeo
Expand All @@ -37,6 +49,8 @@ def register_processes():
# create "pseudo" module for every output:
for returns in module['returns']:
pm = dict(module)
# TODO: do not change the id, otherwise it breaks
# iface.list_module(pm['id'])
pm['id'] = "%s_%s" % (
module['id'], returns['name'])
pm['returns'] = returns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@
}
},
"compute_slope": {
"process_id": "r_slope_aspect",
"process_id": "r_slope_aspect_slope",
"arguments": {
"elevation": {"from_node": "get_elevation_data"},
"e": True,
Expand Down

0 comments on commit 0863d14

Please sign in to comment.