From 2636ace21d9cf05cc03e4c71b1801ff2b5f974e2 Mon Sep 17 00:00:00 2001 From: Sylvain Brunato <61419125+sbrunato@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:22:17 +0200 Subject: [PATCH 1/3] fix: use regex to exactly match asset band (#61) --- eodag_cube/api/product/_assets.py | 3 ++- tests/units/test_eoproduct_driver_stac_assets.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/eodag_cube/api/product/_assets.py b/eodag_cube/api/product/_assets.py index 521ba12..d175c96 100644 --- a/eodag_cube/api/product/_assets.py +++ b/eodag_cube/api/product/_assets.py @@ -95,8 +95,9 @@ def get_data( array if unable to get the data :rtype: xarray.DataArray """ + band_pattern = rf"^{self.key}$" return self.product.get_data( - band=self.key, + band=band_pattern, crs=crs, resolution=resolution, extent=extent, diff --git a/tests/units/test_eoproduct_driver_stac_assets.py b/tests/units/test_eoproduct_driver_stac_assets.py index 3c84af2..2bf5969 100644 --- a/tests/units/test_eoproduct_driver_stac_assets.py +++ b/tests/units/test_eoproduct_driver_stac_assets.py @@ -25,6 +25,7 @@ from tests import TEST_RESOURCES_PATH, EODagTestCase from tests.context import AddressNotFound, EOProduct, StacAssets +from tests.utils import mock class TestEOProductDriverStacAssets(EODagTestCase): @@ -121,6 +122,20 @@ def test_asset_get_data(self): ) self.assertIsInstance(data, DataArray) + @mock.patch("eodag_cube.api.product._product.EOProduct.get_data", autospec=True) + def test_asset_get_data_pattern(self, mock_get_data): + """get_data on asset should use a pattern to match exactly its band""" + + self.product.assets["T31TDH_20180101T124911_B01.jp2"].get_data() + mock_get_data.assert_called_once_with( + self.product, + band=r"^T31TDH_20180101T124911_B01.jp2$", + crs=None, + resolution=None, + extent=None, + resampling=None, + ) + @contextmanager def _filesystem_product(self): original = self.product.location From 04bcc980c74fa29251c353c02c1ae94d3a35ab2e Mon Sep 17 00:00:00 2001 From: Sylvain Brunato <61419125+sbrunato@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:29:27 +0200 Subject: [PATCH 2/3] fix: support zipped bands in s3 (#62) --- eodag_cube/api/product/_product.py | 2 +- tests/units/test_eoproduct.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/eodag_cube/api/product/_product.py b/eodag_cube/api/product/_product.py index 24359d6..bd20022 100644 --- a/eodag_cube/api/product/_product.py +++ b/eodag_cube/api/product/_product.py @@ -222,7 +222,7 @@ def _get_rio_env(self, dataset_address: str) -> Dict[str, Any]: :rtype: Dict[str, Any] """ product_location_scheme = dataset_address.split("://")[0] - if product_location_scheme == "s3" and hasattr( + if "s3" in product_location_scheme and hasattr( self.downloader, "get_product_bucket_name_and_prefix" ): bucket_name, prefix = self.downloader.get_product_bucket_name_and_prefix( diff --git a/tests/units/test_eoproduct.py b/tests/units/test_eoproduct.py index f17544e..435d9d9 100644 --- a/tests/units/test_eoproduct.py +++ b/tests/units/test_eoproduct.py @@ -219,3 +219,11 @@ def test_get_rio_env(self): self.assertEqual(rio_env["AWS_HTTPS"], "YES") self.assertEqual(rio_env["AWS_S3_ENDPOINT"], "some.where") self.assertEqual(rio_env["AWS_VIRTUAL_HOSTING"], "FALSE") + + # aws s3 with custom endpoint and band in zip + rio_env = product._get_rio_env("zip+s3://path/to/asset.zip!band.tiff") + self.assertEqual(len(rio_env), 4) + self.assertIsInstance(rio_env["session"], AWSSession) + self.assertEqual(rio_env["AWS_HTTPS"], "YES") + self.assertEqual(rio_env["AWS_S3_ENDPOINT"], "some.where") + self.assertEqual(rio_env["AWS_VIRTUAL_HOSTING"], "FALSE") From 67984af68baccb21ea090bbeb17d84f1a688bb0e Mon Sep 17 00:00:00 2001 From: Sylvain Brunato <61419125+sbrunato@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:31:45 +0200 Subject: [PATCH 3/3] build: bump version (#63) --- CHANGES.rst | 7 +++++++ eodag_cube/__init__.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 7d81bb7..e713cb0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,13 @@ Release history --------------- +0.5.0 (2024-10-10) +++++++++++++++++++ + +- Support zipped bands in s3 (#62) +- Regex fix in band selection using `StacAssets` driver (#61) +- [0.5.0b1] Adapt to `eodag v3` search API (#59) + 0.5.0b1 (2024-06-25) ++++++++++++++++++++ diff --git a/eodag_cube/__init__.py b/eodag_cube/__init__.py index 6cfae26..e03c472 100644 --- a/eodag_cube/__init__.py +++ b/eodag_cube/__init__.py @@ -19,8 +19,8 @@ __title__ = "eodag-cube" __description__ = "Data access for EODAG" -__version__ = "0.5.0b1" -__author__ = "CS GROUP - France (CSSI)" +__version__ = "0.5.0" +__author__ = "CS GROUP - France" __author_email__ = "eodag@csgroup.space" __url__ = "https://github.com/CS-SI/eodag-cube" __license__ = "Apache 2.0"