Skip to content

Commit

Permalink
Move imports, skip tests on old fsspec and add changes note
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant committed Jan 22, 2025
1 parent ad38c05 commit 616e9b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/2533.bigfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wrap sync fsspec filesystems with AsyncFileSystemWrapper in xarray.to_zarr
14 changes: 13 additions & 1 deletion tests/test_store/test_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 616e9b2

Please sign in to comment.