diff --git a/openeo_driver/ProcessGraphDeserializer.py b/openeo_driver/ProcessGraphDeserializer.py index 0d5d2940..e6a30f28 100644 --- a/openeo_driver/ProcessGraphDeserializer.py +++ b/openeo_driver/ProcessGraphDeserializer.py @@ -1995,6 +1995,13 @@ def mask_scl_dilation(args: Dict, env: EvalEnv): @process_registry_2xx.add_function(spec=read_spec("openeo-processes/experimental/to_scl_dilation_mask.json")) def to_scl_dilation_mask(args: ProcessArgs, env: EvalEnv): cube: DriverDataCube = args.get_required("data", expected_type=DriverDataCube) + if len(cube.metadata.band_names) != 1: + raise ProcessParameterInvalidException( + parameter="data", + process="to_scl_dilation_mask", + reason=f"The source data cube should only contain a single (SCL) band, but got {cube.metadata.band_names}.", + ) + # Get default values for other args from spec spec = read_spec("openeo-processes/experimental/to_scl_dilation_mask.json") defaults = {param["name"]: param["default"] for param in spec["parameters"] if "default" in param} diff --git a/openeo_driver/dry_run.py b/openeo_driver/dry_run.py index 53d4dfad..271a5d64 100644 --- a/openeo_driver/dry_run.py +++ b/openeo_driver/dry_run.py @@ -509,7 +509,7 @@ def filter_spatial(self, geometries): return cube._process(operation="filter_spatial", arguments={"geometries": geometries}) def filter_bands(self, bands) -> 'DryRunDataCube': - return self._process("bands", bands) + return self._process("bands", bands, metadata=self.metadata.filter_bands(bands)) def filter_properties(self, properties) -> 'DryRunDataCube': return self._process("properties", properties) diff --git a/tests/test_views_execute.py b/tests/test_views_execute.py index e85065f0..7336892e 100644 --- a/tests/test_views_execute.py +++ b/tests/test_views_execute.py @@ -4215,3 +4215,27 @@ def test_to_scl_dilation_mask_defaults(api): "mask1_values": [2, 4, 5, 6, 7], "mask2_values": [3, 8, 9, 10, 11], } + + +def test_to_scl_dilation_mask_multiple_bands(api): + """ + input raster cube with multiple bands should raise error + """ + res = api.result( + { + "loadcollection1": { + "process_id": "load_collection", + "arguments": {"id": "SENTINEL2_L2A_SENTINELHUB", "bands": ["B02", "B03", "SCL"]}, + }, + "to_scl_dilation_mask": { + "process_id": "to_scl_dilation_mask", + "arguments": {"data": {"from_node": "loadcollection1"}}, + "result": True, + }, + } + ) + res.assert_error( + 400, + "ProcessParameterInvalid", + message="The source data cube should only contain a single (SCL) band, but got ['B02', 'B03', 'SCL']", + )