Skip to content

Commit

Permalink
EP-3251 reduce/apply "callback" has been renamed to "process_graph" (O…
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Mar 17, 2020
1 parent 74c11c3 commit 326164e
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions openeo/internal/graphbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def arrayElementDone(self, node):
def leaveArgument(self, argument_id, node: Dict):
if 'from_node' in node:
node['from_node'] = self._last_node_id
if isinstance(node, dict) and 'callback' in node:
callback = node['callback']
if isinstance(node, dict) and 'process_graph' in node:
callback = node['process_graph']
flat_callback = GraphFlattener(key_generator=self._key_generator).flatten(callback)
node['callback'] = flat_callback
node['process_graph'] = flat_callback
20 changes: 10 additions & 10 deletions openeo/rest/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,14 @@ def _create_reduced_collection(self, callback_graph_builder, extend_previous_cal
# TODO: avoid hardcoded dimension name 'spectral_bands' #116
'dimension': 'spectral_bands',
'reducer': {
'callback': callback_graph_builder.result_node
'process_graph': callback_graph_builder.result_node
}
}
return self.graph_add_process("reduce", args) # TODO #124 reduce_dimension/reduce_dimension_binary
else:
# TODO #117 is shallow_copy still necessary?
process_graph_copy = self.builder.shallow_copy()
process_graph_copy.result_node['arguments']['reducer']['callback'] = callback_graph_builder.result_node
process_graph_copy.result_node['arguments']['reducer']['process_graph'] = callback_graph_builder.result_node

# now current_node should be a reduce node, let's modify it
# TODO: set metadata of reduced cube?
Expand Down Expand Up @@ -406,14 +406,14 @@ def _reduce_bands_binary(self, operator, other: 'DataCube', arg_name='data'):
del cube_list[0]["from_node"]
del cube_list[1]["from_node"]
the_node["arguments"]["overlap_resolver"] = {
'callback': merged.result_node
'process_graph': merged.result_node
}
return DataCube(builder=cubes_merged, connection=self._connection, metadata=self.metadata)
else:
args = {
'data': {'from_node': self.builder.result_node},
'reducer': {
'callback': merged.processes
'process_graph': merged.processes
}
}
return self.graph_add_process("reduce", args) # TODO #124 reduce_dimension/reduce_dimension_binary
Expand All @@ -424,7 +424,7 @@ def _reduce_bands_binary(self, operator, other: 'DataCube', arg_name='data'):
reducing_graph = other
# TODO #117 is shallow_copy still necessary?
new_builder = reducing_graph.builder.shallow_copy()
new_builder.result_node['arguments']['reducer']['callback'] = merged.result_node
new_builder.result_node['arguments']['reducer']['process_graph'] = merged.result_node
# now current_node should be a reduce node, let's modify it
# TODO: set metadata of reduced cube?
return DataCube(builder=new_builder, connection=reducing_graph._connection)
Expand Down Expand Up @@ -479,7 +479,7 @@ def _get_band_graph_builder(self):
if current_node["process_id"] in ("reduce_dimension", "reduce_dimension_binary"):
# TODO: avoid hardcoded "spectral_bands" dimension #76 #93 #116
if current_node["arguments"]["dimension"] == "spectral_bands":
callback_graph = current_node["arguments"]["reducer"]["callback"]
callback_graph = current_node["arguments"]["reducer"]["process_graph"]
return GraphBuilder.from_process_graph(callback_graph)
return None

Expand Down Expand Up @@ -547,7 +547,7 @@ def apply_dimension(self, code: str, runtime=None, version="latest", dimension='
},
'dimension': dimension,
'process': {
'callback': callback
'process_graph': callback
}
}
return self.graph_add_process(process_id, args)
Expand All @@ -566,7 +566,7 @@ def _reduce(self, dimension: str, callback: dict, process_id="reduce_dimension")
"from_node": self.builder.result_node,
},
"reducer": {
"callback": callback,
"process_graph": callback,
},
"dimension": dimension,
# TODO: add `context` argument
Expand Down Expand Up @@ -646,7 +646,7 @@ def apply(self, process: str, data_argument='data', arguments={}) -> 'ImageColle
args = {
'data': {'from_node': self.builder.result_node},
'process': {
'callback': {
'process_graph': {
"unary": {
"arguments": arguments,
"process_id": process,
Expand Down Expand Up @@ -913,7 +913,7 @@ def graph_add_aggregate_process(graph) -> 'ImageCollection':
'data': {'from_node': self.builder.result_node},
'polygons': polygons,
'reducer': {
'callback': {
'process_graph': {
"arguments": {
"data": {
"from_argument": "data"
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/aggregate_zonal.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}
},
"reducer": {
"callback": {
"process_graph": {
"mean1": {
"process_id": "mean",
"arguments": {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/aggregate_zonal_vector_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"from_node": "readvector1"
},
"reducer": {
"callback": {
"process_graph": {
"mean1": {
"process_id": "mean",
"arguments": {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/apply_dimension_temporal_cumsum.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dimension": "temporal",
"process": {
"callback": {
"process_graph": {
"cumsum1": {
"arguments": {
"data": {
Expand Down
4 changes: 2 additions & 2 deletions tests/data/1.0.0/band0.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"arguments": {
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"arrayelement1": {
"process_id": "array_element",
"arguments": {
"index": 0,
"data": {
"from_argument": "data"
}
},
"process_id": "array_element",
"result": true
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/band_red.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"arguments": {
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"arrayelement1": {
"arguments": {
"index": 2,
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/band_red_filtered.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"arrayelement1": {
"arguments": {
"data": {
Expand Down
6 changes: 3 additions & 3 deletions tests/data/1.0.0/cube_merge_or.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"arrayelement1": {
"process_id": "array_element",
"arguments": {
Expand Down Expand Up @@ -67,7 +67,7 @@
},
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"arrayelement2": {
"process_id": "array_element",
"arguments": {
Expand Down Expand Up @@ -113,7 +113,7 @@
"from_node": "linearscalerange2"
},
"overlap_resolver": {
"callback": {
"process_graph": {
"or1": {
"process_id": "or",
"arguments": {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/evi_graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"arrayelement1": {
"process_id": "array_element",
"arguments": {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/logical_and.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"arrayelement1": {
"process_id": "array_element",
"arguments": {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/logical_or.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"arrayelement1": {
"process_id": "array_element",
"arguments": {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/min_time.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"process_id": "reduce_dimension",
"arguments": {
"reducer": {
"callback": {
"process_graph": {
"min1": {
"arguments": {
"data": {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/notequal.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"arrayelement1": {
"process_id": "array_element",
"arguments": {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/1.0.0/udf_graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dimension": "spectral_bands",
"reducer": {
"callback": {
"process_graph": {
"runudf1": {
"process_id": "run_udf",
"arguments": {
Expand Down
4 changes: 2 additions & 2 deletions tests/rest/datacube/test_bandmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_band_operation(con100, process, expected):
"process_id": "reduce_dimension",
"arguments": {
"data": {"from_node": "loadcollection1"},
"reducer": {"callback": callback},
"reducer": {"process_graph": callback},
"dimension": "spectral_bands",
},
"result": True,
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_reduce_dimension_binary(con100):
'arguments': {
'data': {'from_node': 'loadcollection1'},
'dimension': 'bands',
'reducer': {'callback': {
'reducer': {'process_graph': {
'add1': {
'process_id': 'add',
'arguments': {'x': {'from_argument': 'x'}, 'y': {'from_argument': 'y'}},
Expand Down

0 comments on commit 326164e

Please sign in to comment.