Skip to content

Commit bed2ef0

Browse files
committed
Remove all wrapping of stackstac and odc-stac
1 parent 839c57d commit bed2ef0

File tree

8 files changed

+54
-318
lines changed

8 files changed

+54
-318
lines changed

README.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,6 @@ xr.open_dataset(asset, patch_url=planetary_computer.sign)
9696

9797
Note that this zarr asset uses the xarray-assets extension to store `open_kwargs` and `storage_options` which xpystac can then pass along to `xr.open_dataset`.
9898

99-
### Open a single item
100-
101-
A single item containing many COGs:
102-
103-
```python
104-
import pystac
105-
import xarray as xr
106-
107-
108-
item = pystac.Item.from_file(
109-
"https://earth-search.aws.element84.com/v1/collections/landsat-c2-l2/items/LC09_L2SR_081108_20250311_02_T2"
110-
)
111-
112-
xr.open_dataset(item)
113-
```
114-
This takes advantage of a stacking library (either
115-
[odc-stac](https://github.com/opendatacube/odc-stac) or [stackstac](https://github.com/gjoseph92/stackstac) - configurable via the `stacking_library` option)
11699

117100
### Open many items
118101

@@ -152,9 +135,8 @@ xr.open_dataset(item_collection)
152135
## How it works
153136

154137
When you call ``xarray.open_dataset(object, engine="stac")`` this library maps that `open` call to the correct library.
155-
Depending on the ``type`` of ``object`` that might be a stacking library (either
156-
[odc-stac](https://github.com/opendatacube/odc-stac) or [stackstac](https://github.com/gjoseph92/stackstac))
157-
or back to ``xarray.open_dataset`` itself but with the engine and other options pulled from the pystac object.
138+
Depending on the ``type`` of ``object`` that might be
139+
back to ``xarray.open_dataset`` itself but with the engine and other options pulled from the pystac object.
158140

159141
## Prior Art
160142

environment.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@ Repository = "https://github.com/stac-utils/xpystac"
2828
dev = [
2929
"adlfs>=2024.12.0",
3030
"aiohttp>=3.12.15",
31+
"dask>=2025.9.1",
3132
"fsspec>=2025.3.0",
3233
"icechunk>=1.1.5",
34+
"ipdb>=0.13.13",
3335
"ipython>=9.5.0",
3436
"kerchunk>=0.2.7",
35-
"odc-stac>=0.3.11",
3637
"planetary-computer>=1.0.0",
3738
"pre-commit>=4.0.1",
3839
"pystac<1.12",
3940
"pystac-client>=0.8.6",
4041
"pytest>=8.3.3",
4142
"pytest-cov>=6.0.0",
43+
"pytest-xdist>=3.8.0",
4244
"requests>=2.32.3",
4345
"rioxarray>=0.18.2",
44-
"stackstac>=0.5.1",
4546
"urllib3>=2.3.0",
4647
"zarr>2",
4748
]

tests/test_core.py

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import dask.array
21
import pystac_client
32
import pytest
4-
import xarray as xr
53

64
from tests.utils import STAC_URLS, requires_icechunk, requires_planetary_computer
75
from xpystac.core import to_xarray
@@ -12,30 +10,6 @@ def test_to_xarray_with_cog_asset(simple_cog):
1210
assert ds
1311

1412

15-
def test_to_xarray_with_pystac_client_search(simple_search):
16-
ds = to_xarray(simple_search)
17-
assert ds
18-
19-
20-
def test_to_xarray_returns_dask_backed_object(simple_search):
21-
ds = to_xarray(simple_search)
22-
assert isinstance(ds.blue.data, dask.array.Array)
23-
assert ds.blue.data.npartitions > 1
24-
25-
26-
def test_to_xarray_with_pystac_client_search_passes_kwargs_through(simple_search):
27-
ds = to_xarray(simple_search, bands=["red", "green", "blue"], chunks={})
28-
assert list(ds.data_vars) == ["red", "green", "blue"]
29-
assert ds.blue.data.npartitions == 1
30-
31-
32-
@pytest.mark.parametrize("stacking_library", ["odc.stac", "stackstac"])
33-
def test_to_xarray_with_different_stacking_library(simple_search, stacking_library):
34-
ds = to_xarray(simple_search, stacking_library=stacking_library)
35-
assert isinstance(ds, xr.Dataset)
36-
assert "band" not in ds.dims
37-
38-
3913
@requires_planetary_computer
4014
def test_to_xarray_with_pystac_client_search_with_patch_url():
4115
import planetary_computer as pc
@@ -47,24 +21,13 @@ def test_to_xarray_with_pystac_client_search_with_patch_url():
4721
collections=["sentinel-2-l2a"],
4822
datetime="2020-05-01",
4923
)
50-
51-
ds = to_xarray(search, assets=["B4", "B3", "B2"], stacking_library="odc.stac")
24+
item = next(search.items())
25+
asset = item.assets["B04"]
5226

5327
with pytest.raises(RasterioIOError, match="HTTP response code: 409"):
54-
ds.B01.max().compute()
28+
to_xarray(asset)
5529

56-
ds = to_xarray(
57-
search,
58-
assets=["B4", "B3", "B2"],
59-
stacking_library="odc.stac",
60-
patch_url=pc.sign,
61-
)
62-
assert ds.B01.max().compute() == 11080
63-
64-
65-
def test_to_xarray_with_drop_variables_raises(simple_search):
66-
with pytest.raises(KeyError, match="not implemented for pystac items"):
67-
to_xarray(simple_search, drop_variables=["blue"])
30+
to_xarray(asset, patch_url=pc.sign)
6831

6932

7033
def test_to_xarray_with_bad_type():
@@ -145,20 +108,6 @@ def test_to_xarray_zarr_with_zarr_extension():
145108
to_xarray(zarr_asset)
146109

147110

148-
@pytest.mark.skip(reason="not yet supported with kerchunk >=0.2.8")
149-
def test_to_xarray_with_item_collection_with_kerchunk_attrs_in_data_cube(
150-
data_cube_kerchunk,
151-
):
152-
ds = to_xarray(data_cube_kerchunk)
153-
assert ds
154-
155-
156-
@pytest.mark.skip(reason="not yet supported with kerchunk >=0.2.8")
157-
def test_to_xarray_with_list_with_kerchunk_attrs_in_data_cube(data_cube_kerchunk):
158-
ds = to_xarray([i for i in data_cube_kerchunk])
159-
assert ds
160-
161-
162111
@pytest.mark.skip(reason="not yet supported with kerchunk >=0.2.8")
163112
def test_to_xarray_with_item_with_kerchunk_attrs_in_data_cube(data_cube_kerchunk):
164113
ds = to_xarray([i for i in data_cube_kerchunk][-1])

tests/test_xarray_plugin.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
import pytest
21
import xarray
32

43

54
def test_xarray_open_dataset_can_guess_for_pystac_objects(simple_cog):
65
ds = xarray.open_dataset(simple_cog)
76
assert ds
8-
9-
10-
def test_xarray_open_dataset_can_guess_for_pystac_client_searchs(simple_search):
11-
ds = xarray.open_dataset(simple_search, assets=["blue", "green", "red"])
12-
assert ds
13-
14-
15-
def test_xarray_open_dataset_with_drop_variables_raises(simple_search):
16-
with pytest.raises(KeyError, match="not implemented for pystac items"):
17-
xarray.open_dataset(simple_search, engine="stac", drop_variables=["B0"])

0 commit comments

Comments
 (0)