|
7 | 7 | import pytest |
8 | 8 | import xarray as xr |
9 | 9 | import xarray.testing as xrt |
10 | | -from obstore.store import LocalStore |
| 10 | +from obstore.store import LocalStore, from_url |
11 | 11 |
|
12 | 12 | from conftest import ARRAYBYTES_CODEC, ZLIB_CODEC |
13 | 13 | from virtualizarr import open_virtual_dataset |
|
25 | 25 | has_icechunk, |
26 | 26 | has_kerchunk, |
27 | 27 | requires_kerchunk, |
| 28 | + requires_network, |
28 | 29 | requires_zarr_python, |
| 30 | + slow_test, |
29 | 31 | ) |
30 | 32 |
|
31 | 33 | icechunk = pytest.importorskip("icechunk") |
@@ -519,3 +521,35 @@ def test_convert_relative_paths_to_urls(self, netcdf4_file, local_registry): |
519 | 521 | path = manifest["0.0.0"]["path"] |
520 | 522 |
|
521 | 523 | assert path == expected_path |
| 524 | + |
| 525 | + |
| 526 | +@requires_kerchunk |
| 527 | +@requires_network |
| 528 | +@slow_test |
| 529 | +def test_roundtrip_dataset_with_multiple_compressors(): |
| 530 | + # Regression test to make sure we can load data with a compression and a shuffle codec |
| 531 | + # TODO: Simplify this test to not require network access |
| 532 | + import s3fs |
| 533 | + |
| 534 | + bucket = "s3://nex-gddp-cmip6" |
| 535 | + path = "NEX-GDDP-CMIP6/ACCESS-CM2/ssp126/r1i1p1f1/tasmax/tasmax_day_ACCESS-CM2_ssp126_r1i1p1f1_gn_2015_v2.0.nc" |
| 536 | + url = f"{bucket}/{path}" |
| 537 | + store = from_url(bucket, region="us-west-2", skip_signature=True) |
| 538 | + registry = ObjectStoreRegistry({bucket: store}) |
| 539 | + parser = HDFParser() |
| 540 | + vds = open_virtual_dataset( |
| 541 | + url=url, parser=parser, registry=registry, loadable_variables=[] |
| 542 | + ) |
| 543 | + |
| 544 | + ds_refs = vds.vz.to_kerchunk(format="dict") |
| 545 | + fs = s3fs.S3FileSystem(anon=True) |
| 546 | + with ( |
| 547 | + xr.open_dataset(fs.open(url), engine="h5netcdf", decode_times=True) as expected, |
| 548 | + xr.open_dataset( |
| 549 | + ds_refs, |
| 550 | + decode_times=True, |
| 551 | + engine="kerchunk", |
| 552 | + storage_options={"remote_options": {"anon": True}}, |
| 553 | + ) as observed, |
| 554 | + ): |
| 555 | + xr.testing.assert_allclose(expected, observed) |
0 commit comments