Skip to content

Commit 7517f72

Browse files
committed
Convert older filesystems to async
1 parent 50c18f0 commit 7517f72

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/zarr/storage/_fsspec.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,18 @@ def _make_async(fs: AbstractFileSystem) -> AsyncFileSystem:
4545
if fs.async_impl and fs.asynchronous:
4646
return fs
4747
if fs.async_impl:
48-
fs_dict = fs.to_dict()
49-
fs_dict["asynchronous"] = True
50-
return AbstractFileSystem.from_dict(fs_dict)
48+
try:
49+
fs_dict = fs.to_dict()
50+
fs_dict["asynchronous"] = True
51+
return AbstractFileSystem.from_dict(fs_dict)
52+
except AttributeError:
53+
# Older fsspec specification used to_json rather than to_dict
54+
import json
55+
56+
fs_dict = json.loads(fs.to_json())
57+
fs_dict["asynchronous"] = True
58+
return AbstractFileSystem.from_json(json.dumps(fs_dict))
59+
5160
from fsspec.implementations.local import LocalFileSystem
5261

5362
if type(fs) is LocalFileSystem and not fs.auto_mkdir:

0 commit comments

Comments
 (0)