From 616e9b21628e19f500aa77c07a7dcaf17f21ab15 Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Wed, 22 Jan 2025 11:03:30 -0500 Subject: [PATCH] Move imports, skip tests on old fsspec and add changes note --- changes/2533.bigfix.rst | 1 + tests/test_store/test_fsspec.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 changes/2533.bigfix.rst diff --git a/changes/2533.bigfix.rst b/changes/2533.bigfix.rst new file mode 100644 index 0000000000..dbcdf40e3c --- /dev/null +++ b/changes/2533.bigfix.rst @@ -0,0 +1 @@ +Wrap sync fsspec filesystems with AsyncFileSystemWrapper in xarray.to_zarr \ No newline at end of file diff --git a/tests/test_store/test_fsspec.py b/tests/test_store/test_fsspec.py index 8d13d33dbc..a560ca02e8 100644 --- a/tests/test_store/test_fsspec.py +++ b/tests/test_store/test_fsspec.py @@ -6,7 +6,7 @@ import pytest from botocore.session import Session -from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper +from packaging.version import parse as parse_version import zarr.api.asynchronous from zarr.abc.store import OffsetByteRequest @@ -218,16 +218,28 @@ async def test_empty_nonexistent_path(self, store_kwargs) -> None: assert await store.is_empty("") +@pytest.mark.skipif( + parse_version(fsspec.__version__) < parse_version("2024.12.0"), + reason="No AsyncFileSystemWrapper", +) def test_wrap_sync_filesystem(): """The local fs is not async so we should expect it to be wrapped automatically""" + from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper + store = FsspecStore.from_url("local://test/path") assert isinstance(store.fs, AsyncFileSystemWrapper) assert store.fs.async_impl +@pytest.mark.skipif( + parse_version(fsspec.__version__) < parse_version("2024.12.0"), + reason="No AsyncFileSystemWrapper", +) def test_no_wrap_async_filesystem(): """An async fs should not be wrapped automatically; fsspec's https filesystem is such an fs""" + from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper + store = FsspecStore.from_url("https://test/path") assert not isinstance(store.fs, AsyncFileSystemWrapper)