diff --git a/odc/stac/bench/_run.py b/odc/stac/bench/_run.py index 1f46759..90ae46d 100644 --- a/odc/stac/bench/_run.py +++ b/odc/stac/bench/_run.py @@ -392,7 +392,13 @@ def load_from_json(geojson, params: BenchLoadParams, **kw): :param params: data loading configuration :param kw: passed on to underlying data load function """ - all_items = [pystac.item.Item.from_dict(f) for f in geojson["features"]] + # Don't migrate items when loading with stackstac. Migration to stac 1.1 + # removes `proj:epsg` from the item properties that stackstac (==0.5.1 at + # the time of writing) uses to determine the CRS + migrate = kw.get("migrate", params.method == "odc-stac") + all_items = [ + pystac.item.Item.from_dict(f, migrate=migrate) for f in geojson["features"] + ] opts = params.compute_args() opts.update(**kw) diff --git a/setup.cfg b/setup.cfg index 61074f6..e507fd7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -62,6 +62,18 @@ docs = ipython ipykernel +test = + pytest + pytest-cov + pytest-timeout + pystac_client + distributed + geopandas + +test-all = + %(test)s + datacube + stackstac [options.packages.find] include = diff --git a/tests/test-env-py310.yml b/tests/test-env-py310.yml index 853aa12..3d6ecb1 100644 --- a/tests/test-env-py310.yml +++ b/tests/test-env-py310.yml @@ -19,10 +19,10 @@ dependencies: - pandas - toolz - odc-geo >=0.4.7 - - pystac ==1.9.0 - - dask ==2023.12.0 - - xarray ==2023.12.0 - - rasterio ==1.3.9 + - pystac >=1.12.1 + - dask + - xarray + - rasterio # For mypy - types-python-dateutil @@ -36,7 +36,7 @@ dependencies: - mock - deepdiff - pystac-client >=0.2.0 - - geopandas <1 + - geopandas - stackstac - zarr diff --git a/tests/test_eo3converter.py b/tests/test_eo3converter.py index 0d65546..499b6d4 100644 --- a/tests/test_eo3converter.py +++ b/tests/test_eo3converter.py @@ -6,6 +6,7 @@ _ = pytest.importorskip("datacube") import uuid +from typing import Any import pystac import pystac.asset @@ -55,7 +56,13 @@ def test_infer_product_collection( # Check unhappy path collection = sentinel_stac_collection.clone() - collection.stac_extensions.remove(ItemAssetsExtension.get_schema_uri()) + item_assets = getattr(collection, "item_assets", None) + if item_assets is not None: + # newer pystac + item_assets.clear() + else: + collection.stac_extensions.remove(ItemAssetsExtension.get_schema_uri()) + with pytest.raises(ValueError): infer_dc_product(collection) @@ -161,6 +168,7 @@ def test_item_to_ds_no_proj(sentinel_stac_ms: pystac.item.Item): product = infer_dc_product(item, STAC_CFG) + assert item.geometry is not None geom = Geometry(item.geometry, "EPSG:4326") ds = _item_to_ds(item, product, STAC_CFG) assert ds.crs == "EPSG:4326" @@ -196,7 +204,7 @@ def test_item_uuid(): assert id1 != id2 -def test_issue_n6(usgs_landsat_stac_v1): +def test_issue_n6(usgs_landsat_stac_v1: pystac.Item): expected_bands = { "blue", "coastal", @@ -213,12 +221,12 @@ def test_issue_n6(usgs_landsat_stac_v1): assert set(p.measurements) == expected_bands -def test_partial_proj(partial_proj_stac): +def test_partial_proj(partial_proj_stac: pystac.Item): (ds,) = list(stac2ds([partial_proj_stac])) assert ds.metadata_doc["grids"]["default"]["shape"] == (1, 1) -def test_noassets_case(no_bands_stac): +def test_noassets_case(no_bands_stac: Any): (ds,) = stac2ds([no_bands_stac]) assert len(ds.measurements) == 0