Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunato committed Oct 10, 2024
2 parents 799fa13 + 67984af commit 9056eef
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
++++++++++++++++++++

Expand Down
4 changes: 2 additions & 2 deletions eodag_cube/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = "[email protected]"
__url__ = "https://github.com/CS-SI/eodag-cube"
__license__ = "Apache 2.0"
Expand Down
3 changes: 2 additions & 1 deletion eodag_cube/api/product/_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion eodag_cube/api/product/_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions tests/units/test_eoproduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
15 changes: 15 additions & 0 deletions tests/units/test_eoproduct_driver_stac_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9056eef

Please sign in to comment.