From 5bb35eeb8262e92b9f5313dd816e85201bd946bf Mon Sep 17 00:00:00 2001 From: Jan Van den bosch Date: Fri, 30 Oct 2026 07:07:58 +0100 Subject: [PATCH 1/3] extend raster:bands if no bands https://github.com/Open-EO/openeo-geotrellis-extensions/issues/863 --- openeo_driver/backend_/_geopyspark.py | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/openeo_driver/backend_/_geopyspark.py b/openeo_driver/backend_/_geopyspark.py index 0f4bef55..3a328844 100644 --- a/openeo_driver/backend_/_geopyspark.py +++ b/openeo_driver/backend_/_geopyspark.py @@ -480,21 +480,7 @@ def jsonable_nodata(nodata: Optional[float]) -> Union[None, float, str]: ) for band in bands ] - - raster_bands = result_dict.get("raster:bands") - if raster_bands is None: - if nodata_value is not None or data_type_value is not None: - result_dict["raster:bands"] = [ - dict_no_none(data_type=data_type_value, nodata=nodata_value) for _ in bands - ] - else: - for raster_band in raster_bands: - if "nodata" not in raster_band and nodata_value is not None: - raster_band["nodata"] = nodata_value - if "data_type" not in raster_band and data_type_value is not None: - raster_band["data_type"] = data_type_value else: - def raster_bands(band_index) -> dict: rb = asset_metadata.get("raster:bands", []) return rb[band_index] if band_index < len(rb) else {} @@ -513,6 +499,20 @@ def raster_bands(band_index) -> dict: for (i, band) in enumerate(bands) ] + if not stac11: + raster_bands = result_dict.get("raster:bands") + if raster_bands is None and bands is not None: + if nodata_value is not None or data_type_value is not None: + result_dict["raster:bands"] = [ + dict_no_none(data_type=data_type_value, nodata=nodata_value) for _ in bands + ] + elif raster_bands is not None: + for raster_band in raster_bands: + if "nodata" not in raster_band and nodata_value is not None: + raster_band["nodata"] = nodata_value + if "data_type" not in raster_band and data_type_value is not None: + raster_band["data_type"] = data_type_value + asset_proj_epsg = asset_metadata.get("proj:epsg", job_info.epsg) result_dict.update( dict_no_none( From ad180905c726ca849eb5d3a3aff139db19da7b64 Mon Sep 17 00:00:00 2001 From: Jan Van den bosch Date: Fri, 30 Oct 2026 07:20:02 +0100 Subject: [PATCH 2/3] add test https://github.com/Open-EO/openeo-geotrellis-extensions/issues/863 --- openeo_driver/dummy/dummy_backend.py | 1 + tests/test_views.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/openeo_driver/dummy/dummy_backend.py b/openeo_driver/dummy/dummy_backend.py index 6326ed93..442b8a09 100644 --- a/openeo_driver/dummy/dummy_backend.py +++ b/openeo_driver/dummy/dummy_backend.py @@ -969,6 +969,7 @@ def get_result_assets(self, job_id: str, user_id: str) -> Dict[str, dict]: "roles": ["data"], "type": "application/x-netcdf", "nodata": -1, + "raster:bands": [{}], }, "vectorcube.geojson": { "output_dir": f"{self._output_root()}/{job_id}", diff --git a/tests/test_views.py b/tests/test_views.py index 1f611244..74f62200 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1919,6 +1919,7 @@ def test_get_job_results_100(self, api100): "roles": ["data"], "title": "output.nc", "type": "application/x-netcdf", + "raster:bands": [{"nodata": -1}], }, "randomforest.model": { "href": "http://oeo.net/openeo/1.0.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/randomforest.model", @@ -1996,6 +1997,7 @@ def test_get_job_results_100(self, api100): "proj:epsg": 4326, "proj:code": "EPSG:4326", "proj:shape": [300, 600], + "raster:bands": [{"nodata": -1}], }, "randomforest.model": { "href": "http://oeo.net/openeo/1.0.0/jobs/53c71345-09b4-46b4-b6b0-03fd6fe1f199/results/assets/randomforest.model", @@ -2095,6 +2097,7 @@ def test_get_job_results_110(self, api110): "roles": ["data"], "title": "output.nc", "type": "application/x-netcdf", + "raster:bands": [{"nodata": -1}], }, "randomforest.model": { "href": "http://oeo.net/openeo/1.1.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/randomforest.model", @@ -2184,6 +2187,7 @@ def test_get_job_results_110(self, api110): "proj:epsg": 4326, "proj:code": "EPSG:4326", "proj:shape": [300, 600], + "raster:bands": [{"nodata": -1}], }, "randomforest.model": { "href": "http://oeo.net/openeo/1.1.0/jobs/53c71345-09b4-46b4-b6b0-03fd6fe1f199/results/assets/randomforest.model", @@ -2367,6 +2371,7 @@ def test_get_job_results_signed_100(self, api100, flask_app, backend_config_over "roles": ["data"], "title": "output.nc", "type": "application/x-netcdf", + "raster:bands": [{"nodata": -1}], }, "randomforest.model": { "href": "http://oeo.net/openeo/1.0.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/TXIuVGVzdA==/741cfd7379a9eda4bc1c8b0c5155bfe9/randomforest.model", @@ -2515,6 +2520,7 @@ def test_get_job_results_signed_110(self, api110, flask_app, backend_config_over "roles": ["data"], "title": "output.nc", "type": "application/x-netcdf", + "raster:bands": [{"nodata": -1}], }, "randomforest.model": { "href": "http://oeo.net/openeo/1.1.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/TXIuVGVzdA==/741cfd7379a9eda4bc1c8b0c5155bfe9/randomforest.model", @@ -2665,6 +2671,7 @@ def test_get_job_results_signed_with_expiration_100(self, api100, flask_app, bac "roles": ["data"], "title": "output.nc", "type": "application/x-netcdf", + "raster:bands": [{"nodata": -1}], }, "randomforest.model": { "href": "http://oeo.net/openeo/1.0.0/jobs/07024ee9-7847-4b8a-b260-6c879a2b3cdc/results/assets/TXIuVGVzdA==/22b76413158c59acaccc74e74841a473/randomforest.model?expires=2234", @@ -2864,6 +2871,7 @@ def test_get_job_results_signed_with_expiration_110(self, api110, flask_app, bac "proj:epsg": 4326, "proj:code": "EPSG:4326", "proj:shape": [300, 600], + "raster:bands": [{"nodata": -1}], }, "randomforest.model": { "href": "http://oeo.net/openeo/1.1.0/jobs/53c71345-09b4-46b4-b6b0-03fd6fe1f199/results/assets/TXIuVGVzdA==/18fd2346c52945c0caba7b13246f5a63/randomforest.model?expires=2234", From 5e91454a7c7942b13be1ae394e38a0ea9cfa7017 Mon Sep 17 00:00:00 2001 From: Jan Van den bosch Date: Fri, 30 Oct 2026 07:48:20 +0100 Subject: [PATCH 3/3] empty raster:bands is not allowed Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- openeo_driver/backend_/_geopyspark.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openeo_driver/backend_/_geopyspark.py b/openeo_driver/backend_/_geopyspark.py index 3a328844..340cd7da 100644 --- a/openeo_driver/backend_/_geopyspark.py +++ b/openeo_driver/backend_/_geopyspark.py @@ -501,7 +501,7 @@ def raster_bands(band_index) -> dict: if not stac11: raster_bands = result_dict.get("raster:bands") - if raster_bands is None and bands is not None: + if raster_bands is None and bands: if nodata_value is not None or data_type_value is not None: result_dict["raster:bands"] = [ dict_no_none(data_type=data_type_value, nodata=nodata_value) for _ in bands