Skip to content

Commit 86c00fd

Browse files
Change async in test based on zarr version - we can make this default behaviour too I think
1 parent bb27a9c commit 86c00fd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

intake_esm/source.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pandas as pd
77
import pydantic
88
import xarray as xr
9+
import zarr
910
from intake.source.base import DataSource, Schema
1011

1112
from .cat import Aggregation, DataFormat
@@ -20,6 +21,15 @@ class ESMDataSourceError(Exception):
2021
pass
2122

2223

24+
def _zarr_async() -> bool:
25+
"""
26+
Zarr went all async in version 3.0.0. This sets the async flag based on
27+
the zarr version in storage options
28+
"""
29+
30+
return int(zarr.__version__.split('.')[0]) > 2
31+
32+
2333
def _get_xarray_open_kwargs(data_format, xarray_open_kwargs=None, storage_options=None):
2434
xarray_open_kwargs = (xarray_open_kwargs or {}).copy()
2535
_default_open_kwargs = {

tests/test_source.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
_get_xarray_open_kwargs,
1515
_open_dataset,
1616
_update_attrs,
17+
_zarr_async,
1718
)
1819

1920
dask.config.set(scheduler='single-threaded')
@@ -86,9 +87,10 @@ def test_open_dataset_kerchunk(kerchunk_file=kerchunk_file):
8687
dict(engine='zarr', consolidated=False),
8788
storage_options={
8889
'remote_protocol': 's3',
89-
'remote_options': {'anon': True, 'asynchronous': True},
90+
'remote_options': {'anon': True, 'asynchronous': _zarr_async()},
9091
},
9192
)
93+
9294
ds = _open_dataset(
9395
data_format='reference',
9496
urlpath=kerchunk_file,

0 commit comments

Comments
 (0)