diff --git a/mapchete_eo/base.py b/mapchete_eo/base.py index eb9bdec..225b593 100644 --- a/mapchete_eo/base.py +++ b/mapchete_eo/base.py @@ -500,12 +500,6 @@ def __init__( self.area = self._init_area(input_params) self.time = self.params.time - self.eo_bands = [ - eo_band - for source in self.params.source - for eo_band in source.eo_bands(base_dir=self.conf_dir) - ] - if self.readonly: # pragma: no cover return # don't use preprocessing tasks for Sentinel-2 products: @@ -533,6 +527,17 @@ def __init__( ] ) + @cached_property + def eo_bands(self) -> List[str]: + if self.area.is_empty: + logger.debug("Input area is empty, nothing to be found here.") + return [] + return [ + eo_band + for source in self.params.source + for eo_band in source.eo_bands(base_dir=self.conf_dir) + ] + def _init_area(self, input_params: dict) -> BaseGeometry: """Returns valid driver area for this process.""" process_area = input_params["delimiters"]["effective_area"] @@ -556,6 +561,9 @@ def _init_area(self, input_params: dict) -> BaseGeometry: return process_area def source_items(self) -> Generator[Item, None, None]: + if self.area.is_empty: + logger.debug("Input area is empty, nothing to be found here.") + return already_returned = set() for source in self.params.source: area = reproject_geometry( diff --git a/tests/conftest.py b/tests/conftest.py index 2448d61..19d89db 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,6 @@ import os +from httpx import Client import numpy as np import numpy.ma as ma from pystac import Item @@ -20,6 +21,14 @@ from mapchete_eo.types import TimeRange +def check_cdse_endpoint(): + response = Client().get( + "https://stac.dataspace.copernicus.eu/v1/collections/sentinel-2-l2a" + ) + if response.is_error: + pytest.skip(f"CDSE endpoint is experiencing issues: {response.text}") + + @pytest.fixture def tmp_mpath(tmp_path): return MPath.from_inp(tmp_path) @@ -131,6 +140,7 @@ def s2_stac_item_jp2(): @pytest.fixture def s2_stac_item_cdse_jp2(): + check_cdse_endpoint() item = Item.from_file( "https://stac.dataspace.copernicus.eu/v1/collections/sentinel-2-l2a/items/S2B_MSIL2A_20230810T094549_N0509_R079_T33TWM_20230810T130104" ) @@ -173,6 +183,7 @@ def stac_mapchete(tmp_path, testdata_dir): @pytest.fixture def stac_cdse_copernicus_dem_mapchete(tmp_path, testdata_dir): + check_cdse_endpoint() with ProcessFixture( testdata_dir / "stac_cdse_copernicus_dem.mapchete", output_tempdir=tmp_path, @@ -218,6 +229,7 @@ def sentinel2_mapchete(tmp_path, testdata_dir): @pytest.fixture def sentinel2_aws_cdse_mapchete(tmp_path, testdata_dir): + check_cdse_endpoint() with ProcessFixture( testdata_dir / "sentinel2_aws_cdse.mapchete", output_tempdir=tmp_path, @@ -227,6 +239,7 @@ def sentinel2_aws_cdse_mapchete(tmp_path, testdata_dir): @pytest.fixture def sentinel2_cdse_mapchete(tmp_path, testdata_dir): + check_cdse_endpoint() with ProcessFixture( testdata_dir / "sentinel2_cdse.mapchete", output_tempdir=tmp_path, diff --git a/tests/platforms/sentinel2/test_base.py b/tests/platforms/sentinel2/test_base.py index 4ea7e2c..fb7e5e3 100644 --- a/tests/platforms/sentinel2/test_base.py +++ b/tests/platforms/sentinel2/test_base.py @@ -90,6 +90,7 @@ def test_remote_s2_read_xarray(mapchete_config): "mapchete_config", [lazy_fixture("sentinel2_cdse_mapchete")], ) +@pytest.mark.xfail(reason="CDSE endpoint is flaky") def test_remote_s2_read_xarray_cdse(mapchete_config): with mapchete_config.process_mp().open("inp") as cube: assert isinstance(cube.read(assets=["coastal"]), xr.Dataset) @@ -487,6 +488,7 @@ def test_footprint_buffer(sentinel2_stac_mapchete, test_edge_tile): @pytest.mark.remote +@pytest.mark.xfail(reason="CDSE endpoint is flaky") def test_multiple_sources(sentinel2_multiple_sources_mapchete): mp = sentinel2_multiple_sources_mapchete.mp() input_data = list(mp.config.inputs.values())[0] diff --git a/tests/platforms/sentinel2/test_sources.py b/tests/platforms/sentinel2/test_sources.py index ab0e3c1..323bd2c 100644 --- a/tests/platforms/sentinel2/test_sources.py +++ b/tests/platforms/sentinel2/test_sources.py @@ -34,5 +34,7 @@ def test_known_sources(collection): @pytest.mark.remote @pytest.mark.use_cdse_test_env @pytest.mark.parametrize("collection", ["CDSE"]) -def test_known_sources_cdse(collection): +@pytest.mark.xfail(reason="CDSE endpoint is flaky") +def test_known_sources_cdse(collection, sentinel2_cdse_mapchete): + # using sentinel2_cdse_mapchete fixture to trigger CDSE endpoint check test_known_sources(collection) diff --git a/tests/test_eostac.py b/tests/test_eostac.py index 5c5e197..07ee525 100644 --- a/tests/test_eostac.py +++ b/tests/test_eostac.py @@ -41,6 +41,7 @@ def test_preprocessing(stac_mapchete): @pytest.mark.remote @pytest.mark.use_cdse_test_env +@pytest.mark.xfail(reason="CDSE endpoint is flaky") def test_stac_read_xarray_dem(stac_cdse_copernicus_dem_mapchete, test_tile): with stac_cdse_copernicus_dem_mapchete.process_mp(tile=test_tile).open( "inp"