Skip to content

Commit 2a935cc

Browse files
committed
Harden some CollectionMetadata/CubeMetadata usage
see also #464
1 parent 0cf3bdd commit 2a935cc

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

openeo/extra/spectral_indices/spectral_indices.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Dict, List, Optional, Set
55

66
from openeo import BaseOpenEoException
7+
from openeo.metadata import CollectionMetadata
78
from openeo.processes import ProcessBuilder, array_create, array_modify
89
from openeo.rest.datacube import DataCube
910

@@ -273,7 +274,7 @@ def compute_and_rescale_indices(
273274
# Automatic band mapping
274275
band_mapping = _BandMapping()
275276
if platform is None:
276-
if datacube.metadata and datacube.metadata.get("id"):
277+
if isinstance(datacube.metadata, CollectionMetadata) and datacube.metadata.get("id"):
277278
platform = band_mapping.guess_platform(name=datacube.metadata.get("id"))
278279
else:
279280
raise BandMappingException("Unable to determine satellite platform from data cube metadata")

openeo/metadata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ def resample_spatial(
488488
def resample_cube_spatial(self, target: CubeMetadata) -> CubeMetadata:
489489
return self._clone_and_update(dimensions=list(target._dimensions))
490490

491+
491492
class CollectionMetadata(CubeMetadata):
492493
"""
493494
Wrapper for EO Data Collection metadata.

openeo/rest/datacube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def process_with_node(self, pg: PGNode, metadata: Optional[CollectionMetadata] =
157157

158158
def _do_metadata_normalization(self) -> bool:
159159
"""Do metadata-based normalization/validation of dimension names, band names, ..."""
160-
return isinstance(self.metadata, CollectionMetadata)
160+
return isinstance(self.metadata, CubeMetadata)
161161

162162
def _assert_valid_dimension_name(self, name: str) -> str:
163163
if self._do_metadata_normalization():

0 commit comments

Comments
 (0)