Skip to content

Commit 37cc926

Browse files
committed
maint: support latest pystac==1.12.1
- pystac changed item_assets handling, used to be an extension but it is part of core spec now - fix for calling to stackstac in bench code, current stackstac==0.5.1 can't handle newer version of proj extension, keep stac items from migrating to latest software version
1 parent e903790 commit 37cc926

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

odc/stac/bench/_run.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,13 @@ def load_from_json(geojson, params: BenchLoadParams, **kw):
392392
:param params: data loading configuration
393393
:param kw: passed on to underlying data load function
394394
"""
395-
all_items = [pystac.item.Item.from_dict(f) for f in geojson["features"]]
395+
# Don't migrate items when loading with stackstac. Migration to stac 1.1
396+
# removes `proj:epsg` from the item properties that stackstac (==0.5.1 at
397+
# the time of writing) uses to determine the CRS
398+
migrate = kw.get("migrate", params.method == "odc-stac")
399+
all_items = [
400+
pystac.item.Item.from_dict(f, migrate=migrate) for f in geojson["features"]
401+
]
396402

397403
opts = params.compute_args()
398404
opts.update(**kw)

setup.cfg

+12
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ docs =
6262
ipython
6363
ipykernel
6464

65+
test =
66+
pytest
67+
pytest-cov
68+
pytest-timeout
69+
pystac_client
70+
distributed
71+
geopandas
72+
73+
test-all =
74+
%(test)s
75+
datacube
76+
stackstac
6577

6678
[options.packages.find]
6779
include =

tests/test-env-py310.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ dependencies:
1919
- pandas
2020
- toolz
2121
- odc-geo >=0.4.7
22-
- pystac ==1.9.0
23-
- dask ==2023.12.0
24-
- xarray ==2023.12.0
25-
- rasterio ==1.3.9
22+
- pystac >=1.12.1
23+
- dask
24+
- xarray
25+
- rasterio
2626

2727
# For mypy
2828
- types-python-dateutil
@@ -36,7 +36,7 @@ dependencies:
3636
- mock
3737
- deepdiff
3838
- pystac-client >=0.2.0
39-
- geopandas <1
39+
- geopandas
4040
- stackstac
4141
- zarr
4242

tests/test_eo3converter.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
_ = pytest.importorskip("datacube")
77

88
import uuid
9+
from typing import Any
910

1011
import pystac
1112
import pystac.asset
@@ -55,7 +56,13 @@ def test_infer_product_collection(
5556

5657
# Check unhappy path
5758
collection = sentinel_stac_collection.clone()
58-
collection.stac_extensions.remove(ItemAssetsExtension.get_schema_uri())
59+
item_assets = getattr(collection, "item_assets", None)
60+
if item_assets is not None:
61+
# newer pystac
62+
item_assets.clear()
63+
else:
64+
collection.stac_extensions.remove(ItemAssetsExtension.get_schema_uri())
65+
5966
with pytest.raises(ValueError):
6067
infer_dc_product(collection)
6168

@@ -161,6 +168,7 @@ def test_item_to_ds_no_proj(sentinel_stac_ms: pystac.item.Item):
161168

162169
product = infer_dc_product(item, STAC_CFG)
163170

171+
assert item.geometry is not None
164172
geom = Geometry(item.geometry, "EPSG:4326")
165173
ds = _item_to_ds(item, product, STAC_CFG)
166174
assert ds.crs == "EPSG:4326"
@@ -196,7 +204,7 @@ def test_item_uuid():
196204
assert id1 != id2
197205

198206

199-
def test_issue_n6(usgs_landsat_stac_v1):
207+
def test_issue_n6(usgs_landsat_stac_v1: pystac.Item):
200208
expected_bands = {
201209
"blue",
202210
"coastal",
@@ -213,12 +221,12 @@ def test_issue_n6(usgs_landsat_stac_v1):
213221
assert set(p.measurements) == expected_bands
214222

215223

216-
def test_partial_proj(partial_proj_stac):
224+
def test_partial_proj(partial_proj_stac: pystac.Item):
217225
(ds,) = list(stac2ds([partial_proj_stac]))
218226
assert ds.metadata_doc["grids"]["default"]["shape"] == (1, 1)
219227

220228

221-
def test_noassets_case(no_bands_stac):
229+
def test_noassets_case(no_bands_stac: Any):
222230
(ds,) = stac2ds([no_bands_stac])
223231
assert len(ds.measurements) == 0
224232

0 commit comments

Comments
 (0)