Skip to content

Commit a965d9f

Browse files
committed
Harden bands metadata in batch job results Open-EO/openeo-aggregator#183
1 parent 93491cd commit a965d9f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and start a new "In Progress" section above it.
3030
- Allow `overlap` in `apply_neighborhood` to be not specified ([#401](https://github.com/Open-EO/openeo-python-driver/issues/401))
3131
- Start including STAC-1.1.0-style "bands" metadata in assets in batch job results ([#298](https://github.com/Open-EO/openeo-python-driver/issues/298))
3232
- Start including STAC-1.1.0-style "bands" summaries in collection metadata ([#298](https://github.com/Open-EO/openeo-python-driver/issues/298))
33+
- Harden "bands" metadata handling in batch job results listings ([Open-EO/openeo-aggregator#183](https://github.com/Open-EO/openeo-aggregator/issues/183))
3334

3435

3536
## 0.133.0

openeo_driver/dummy/dummy_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ def get_result_assets(self, job_id: str, user_id: str) -> Dict[str, dict]:
826826
"roles": ["data"],
827827
"type": "text/csv",
828828
"href": "s3://OpenEO-data/batch_jobs/j-2406047c20fc4966ab637d387502728f/timeseries.csv",
829-
"bands": [Band(name="S2-L2A-EVI_t0"), Band(name="S2-L2A-EVI_t1"), Band(name="S2-L2A-EVI_t2")],
829+
"bands": [Band(name="S2-L2A-EVI_t0"), Band(name="S2-L2A-EVI_t1"), {"name": "S2-L2A-EVI_t2"}],
830830
"geometry": {"type": "Polygon",
831831
"coordinates": [[[2.70964374625748, 51.00377983772219],
832832
[2.70964374625748, 51.10589339112414],

openeo_driver/views.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
send_from_directory,
2626
url_for,
2727
)
28+
import openeo.metadata
2829
from openeo.util import Rfc3339, TimingLogger, deep_get, dict_no_none, rfc3339
2930
from openeo.utils.version import ComparableVersion
3031
from pyproj import CRS
@@ -1535,6 +1536,22 @@ def _asset_object(job_id, user_id, filename: str, asset_metadata: dict, job_info
15351536
bands = asset_metadata.get("bands")
15361537

15371538
if bands:
1539+
# TODO: #298 this is a quick stop-gap solution for lack of clear API
1540+
# what "bands" actually is expected to be:
1541+
# a list of Band objects (current approach in openeo-geopyspark-driver)
1542+
# or a list of dictionaries (as handled in openeo-aggregator)
1543+
# TODO: move this normalization to a more general utility?
1544+
bands = [
1545+
openeo.metadata.Band(
1546+
name=b.get("name"),
1547+
common_name=b.get("eo:common_name") or b.get("common_name"),
1548+
wavelength_um=b.get("eo:center_wavelength") or b.get("center_wavelength"),
1549+
)
1550+
if isinstance(b, dict)
1551+
else b
1552+
for b in bands
1553+
]
1554+
15381555
# TODO: eliminate this legacy "eo:bands" construct at some point?
15391556
result_dict["eo:bands"] = [
15401557
dict_no_none(

0 commit comments

Comments
 (0)