File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 1+ Removed an unnecessary check from ``_fsspec._make_async `` that would raise an exception when
2+ creating a read-only store backed by a local file system with ``auto_mkdir `` set to ``False ``.
Original file line number Diff line number Diff line change @@ -56,19 +56,15 @@ def _make_async(fs: AbstractFileSystem) -> AsyncFileSystem:
5656 fs_dict ["asynchronous" ] = True
5757 return fsspec .AbstractFileSystem .from_json (json .dumps (fs_dict ))
5858
59- # Wrap sync filesystems with the async wrapper
60- if type (fs ) is fsspec .implementations .local .LocalFileSystem and not fs .auto_mkdir :
61- raise ValueError (
62- f"LocalFilesystem { fs } was created with auto_mkdir=False but Zarr requires the filesystem to automatically create directories"
63- )
6459 if fsspec_version < parse_version ("2024.12.0" ):
6560 raise ImportError (
6661 f"The filesystem '{ fs } ' is synchronous, and the required "
6762 "AsyncFileSystemWrapper is not available. Upgrade fsspec to version "
6863 "2024.12.0 or later to enable this functionality."
6964 )
65+ from fsspec .implementations .asyn_wrapper import AsyncFileSystemWrapper
7066
71- return fsspec . implementations . asyn_wrapper . AsyncFileSystemWrapper (fs , asynchronous = True )
67+ return AsyncFileSystemWrapper (fs , asynchronous = True )
7268
7369
7470class FsspecStore (Store ):
Original file line number Diff line number Diff line change @@ -365,7 +365,7 @@ def test_open_fsmap_file_raises(tmp_path: pathlib.Path) -> None:
365365 fsspec = pytest .importorskip ("fsspec.implementations.local" )
366366 fs = fsspec .LocalFileSystem (auto_mkdir = False )
367367 mapper = fs .get_mapper (tmp_path )
368- with pytest .raises (ValueError , match = "LocalFilesystem .*" ):
368+ with pytest .raises (FileNotFoundError , match = "No such file or directory: .*" ):
369369 array_roundtrip (mapper )
370370
371371
@@ -426,3 +426,17 @@ async def test_delete_dir_wrapped_filesystem(tmp_path: Path) -> None:
426426 assert await store .exists ("foo-bar/zarr.json" )
427427 assert not await store .exists ("foo/zarr.json" )
428428 assert not await store .exists ("foo/c/0" )
429+
430+
431+ @pytest .mark .skipif (
432+ parse_version (fsspec .__version__ ) < parse_version ("2024.12.0" ),
433+ reason = "No AsyncFileSystemWrapper" ,
434+ )
435+ async def test_with_read_only_auto_mkdir (tmp_path : Path ) -> None :
436+ """
437+ Test that creating a read-only copy of a store backed by the local file system does not error
438+ if auto_mkdir is False.
439+ """
440+
441+ store_w = FsspecStore .from_url (f"file://{ tmp_path } " , storage_options = {"auto_mkdir" : False })
442+ _ = store_w .with_read_only ()
You can’t perform that action at this time.
0 commit comments