File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 33import warnings
44from typing import TYPE_CHECKING , Any
55
6+ from fsspec import AbstractFileSystem
7+
68from zarr .abc .store import (
79 ByteRequest ,
810 OffsetByteRequest ,
1618if TYPE_CHECKING :
1719 from collections .abc import AsyncIterator , Iterable
1820
19- from fsspec import AbstractFileSystem
2021 from fsspec .asyn import AsyncFileSystem
2122 from fsspec .mapping import FSMap
2223
@@ -43,9 +44,9 @@ def _make_async(fs: AbstractFileSystem) -> AsyncFileSystem:
4344 if fs .async_impl and fs .asynchronous :
4445 return fs
4546 if fs .async_impl :
46- raise NotImplementedError (
47- f"The filesystem ' { fs } ' is synchronous and wrapping synchronous filesystems using from_mapper has not been implemented. See https://github.com/zarr-developers/zarr-python/issues/2706 for more details."
48- )
47+ fs_dict = fs . to_dict ()
48+ fs_dict [ "asynchronous" ] = True
49+ return AbstractFileSystem . from_dict ( fs_dict )
4950 try :
5051 from fsspec .implementations .asyn_wrapper import AsyncFileSystemWrapper
5152
@@ -187,7 +188,7 @@ def from_mapper(
187188 -------
188189 FsspecStore
189190 """
190- if not fs_map .fs .asynchronous :
191+ if not fs_map .fs .async_impl or not fs_map . fs . asynchronous :
191192 fs_map .fs = _make_async (fs_map .fs )
192193 return cls (
193194 fs = fs_map .fs ,
Original file line number Diff line number Diff line change @@ -106,8 +106,11 @@ async def test_basic() -> None:
106106 assert out [0 ].to_bytes () == data [1 :]
107107
108108
109- def test_open_s3map () -> None :
110- s3_filesystem = s3fs .S3FileSystem (asynchronous = True , endpoint_url = endpoint_url , anon = False )
109+ @pytest .mark .parametrize ("asynchronous" , [True , False ])
110+ def test_open_s3map (asynchronous : bool ) -> None :
111+ s3_filesystem = s3fs .S3FileSystem (
112+ asynchronous = asynchronous , endpoint_url = endpoint_url , anon = False
113+ )
111114 mapper = s3_filesystem .get_mapper (f"s3://{ test_bucket_name } /map/foo/" )
112115 arr = zarr .open (store = mapper , mode = "w" , shape = (3 , 3 ))
113116 assert isinstance (arr , Array )
You can’t perform that action at this time.
0 commit comments