From 1106de53ea3aa3adbb97457e14e6bef44eb437af Mon Sep 17 00:00:00 2001 From: jteulade Date: Mon, 10 Jun 2024 15:34:27 +0200 Subject: [PATCH 1/3] #156: catch InvalidProductError when we try to get cloud_coverage property --- eoreader/stac/stac_extensions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eoreader/stac/stac_extensions.py b/eoreader/stac/stac_extensions.py index e8ae9d11..f7d4e242 100644 --- a/eoreader/stac/stac_extensions.py +++ b/eoreader/stac/stac_extensions.py @@ -56,6 +56,7 @@ get_media_type, repr_multiline_str, ) +from eoreader.exceptions import InvalidProductError class EoExt: @@ -77,7 +78,7 @@ def __init__(self, prod, **kwargs): try: if prod._has_cloud_cover: self.cloud_cover = prod.get_cloud_cover() - except AttributeError: + except (AttributeError, InvalidProductError): pass self.bands = prod.bands From 0ee3ad631d623223ea01bc4a4f1c83b953f9d280 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 13:36:55 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- eoreader/stac/stac_extensions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eoreader/stac/stac_extensions.py b/eoreader/stac/stac_extensions.py index f7d4e242..805b4866 100644 --- a/eoreader/stac/stac_extensions.py +++ b/eoreader/stac/stac_extensions.py @@ -29,6 +29,7 @@ from rasterio.crs import CRS from eoreader import cache +from eoreader.exceptions import InvalidProductError from eoreader.stac import StacCommonNames, stac_utils from eoreader.stac._stac_keywords import ( DESCRIPTION, @@ -56,7 +57,6 @@ get_media_type, repr_multiline_str, ) -from eoreader.exceptions import InvalidProductError class EoExt: From cf2e8f366693fd136b5fa135e27e9599a62912b7 Mon Sep 17 00:00:00 2001 From: jteulade Date: Thu, 13 Jun 2024 11:00:37 +0200 Subject: [PATCH 3/3] #156: catch all InvalidProductError due to properties not found in metadata --- eoreader/stac/stac_extensions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eoreader/stac/stac_extensions.py b/eoreader/stac/stac_extensions.py index 805b4866..e77e198e 100644 --- a/eoreader/stac/stac_extensions.py +++ b/eoreader/stac/stac_extensions.py @@ -157,7 +157,7 @@ def add_to_item(self, item) -> None: center_wavelength = stac_utils.to_float(band.center_wavelength) solar_illumination = stac_utils.to_float(band.solar_illumination) full_width_half_max = stac_utils.to_float(band.full_width_half_max) - except AttributeError: + except (AttributeError, InvalidProductError): center_wavelength = None solar_illumination = None full_width_half_max = None @@ -338,7 +338,7 @@ def __init__(self, prod, **kwargs): # Convert from numpy dtype (which are not JSON serializable) to standard dtype self.sun_az = stac_utils.to_float(sun_az) self.sun_el = stac_utils.to_float(sun_el) - except AttributeError: + except (AttributeError, InvalidProductError): self.sun_az = None self.sun_el = None @@ -349,7 +349,7 @@ def __init__(self, prod, **kwargs): self.view_az = stac_utils.to_float(view_az) self.off_nadir = stac_utils.to_float(off_nadir) self.incidence_angle = stac_utils.to_float(incidence_angle) - except AttributeError: + except (AttributeError, InvalidProductError): self.view_az = None self.off_nadir = None self.incidence_angle = None