Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions mapchete_eo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"]
Expand All @@ -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(
Expand Down
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

from httpx import Client
import numpy as np
import numpy.ma as ma
from pystac import Item
Expand All @@ -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)
Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions tests/platforms/sentinel2/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion tests/platforms/sentinel2/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions tests/test_eostac.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down