Skip to content

Commit

Permalink
chunk_polygon: pass context
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed May 30, 2023
1 parent 982591b commit 1bb4e30
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions openeo_driver/ProcessGraphDeserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,10 +822,12 @@ def reduce_dimension(args: dict, env: EvalEnv) -> DriverDataCube:
@process_registry_100.add_function(spec=read_spec("openeo-processes/experimental/chunk_polygon.json"))
def chunk_polygon(args: dict, env: EvalEnv) -> DriverDataCube:
import shapely

data_cube = extract_arg(args, "data")
reduce_pg = extract_deep(args, "process", "process_graph")
chunks = extract_arg(args, 'chunks')
mask_value = args.get('mask_value', None)
data_cube = extract_arg(args, 'data')
context = args.get("context", {})
if not isinstance(data_cube, DriverDataCube):
raise ProcessParameterInvalidException(
parameter="data", process="chunk_polygon",
Expand Down Expand Up @@ -862,7 +864,7 @@ def chunk_polygon(args: dict, env: EvalEnv) -> DriverDataCube:
if not isinstance(mask_value, float) and mask_value is not None:
reason = "mask_value parameter is not of type float. Actual type: {m!s}".format(m=type(mask_value))
raise ProcessParameterInvalidException(parameter='mask_value', process='chunk_polygon', reason=reason)
return data_cube.chunk_polygon(reducer=reduce_pg, chunks=polygon, mask_value=mask_value, env=env)
return data_cube.chunk_polygon(reducer=reduce_pg, chunks=polygon, mask_value=mask_value, context=context, env=env)


@process_registry_100.add_function(spec=read_spec("openeo-processes/experimental/fit_class_random_forest.json"))
Expand Down
2 changes: 1 addition & 1 deletion openeo_driver/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.51.1a1"
__version__ = "0.51.2a1"
8 changes: 7 additions & 1 deletion openeo_driver/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ def reduce_dimension(
self._not_implemented()

def chunk_polygon(
self, reducer, chunks, mask_value: float, env: EvalEnv, context: Optional[dict] = None
self,
*,
reducer: dict,
chunks: Union[shapely.geometry.base.BaseGeometry],
mask_value: Union[float, None],
env: EvalEnv,
context: Optional[dict] = None,
) -> "DriverDataCube":
# TODO: rename/update `chunk_polygon` to `apply_polygon` (https://github.com/Open-EO/openeo-processes/pull/298)
self._not_implemented()
Expand Down

0 comments on commit 1bb4e30

Please sign in to comment.