openeo-python-client
openeo-python-client copied to clipboard
Reduce_temporal throws MetadataException after load_stac
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:
- Not only check if the metadata is not None but also whether it contains a temporal dimension
- Implement reading a temporal dimension (and spatial) from stac metadata
- Catch metadata related errors and throw them as warnings (Discussion) as this blocks the execution of a batch job while it would run fine.