openeo-python-client icon indicating copy to clipboard operation
openeo-python-client copied to clipboard

Reduce_temporal throws MetadataException after load_stac

Open VictorVerhaert opened this issue 8 months ago • 6 comments

When using load_stac, the python client tries to read metadata from the provided stac. The only metadata currently being read is bands, so no spatial or temporal metadata.

When the python client fails to read metadata from the stac, metadata is simply set to None. These lines check is metadata is present and have default behaviour otherwise: https://github.com/Open-EO/openeo-python-client/blob/36ecc2bdb0feaf4b7876819946866bd651a18189/openeo/rest/datacube.py#L1350-L1359 and https://github.com/Open-EO/openeo-python-client/blob/36ecc2bdb0feaf4b7876819946866bd651a18189/openeo/rest/datacube.py#L1216

The problem arises however when metadata IS being read from the STAC. As only bands are read cube.metadata is not None, but it does not contain a temporal dimension resulting in a MetadataException originating for example from: https://github.com/Open-EO/openeo-python-client/blob/36ecc2bdb0feaf4b7876819946866bd651a18189/openeo/metadata.py#L271-L275

The solution is threefold I think:

  1. Not only check if the metadata is not None but also whether it contains a temporal dimension
  2. Implement reading a temporal dimension (and spatial) from stac metadata
  3. Catch metadata related errors and throw them as warnings (Discussion) as this blocks the execution of a batch job while it would run fine.

VictorVerhaert avatar Jun 04 '24 09:06 VictorVerhaert