From 18bc6f7b0c6ccc217d454e299122ea2b6309ac7f Mon Sep 17 00:00:00 2001 From: Nathan Zimmerman Date: Wed, 4 Dec 2024 12:17:44 -0600 Subject: [PATCH 1/2] Wrap sync fs for xarray.to_zarr --- src/zarr/storage/remote.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/zarr/storage/remote.py b/src/zarr/storage/remote.py index 2b8329c9fa..7f307ccd1e 100644 --- a/src/zarr/storage/remote.py +++ b/src/zarr/storage/remote.py @@ -166,6 +166,9 @@ def from_url( opts = {"asynchronous": True, **opts} fs, path = url_to_fs(url, **opts) + if not fs.async_impl: + from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper + fs = AsyncFileSystemWrapper(fs) # fsspec is not consistent about removing the scheme from the path, so check and strip it here # https://github.com/fsspec/filesystem_spec/issues/1722 From ab52b8c42c6a0540017e4f0e2786e6e3513360be Mon Sep 17 00:00:00 2001 From: Nathan Zimmerman Date: Wed, 4 Dec 2024 13:01:58 -0600 Subject: [PATCH 2/2] Move import to the top --- src/zarr/storage/remote.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zarr/storage/remote.py b/src/zarr/storage/remote.py index 7f307ccd1e..95b0ebd99b 100644 --- a/src/zarr/storage/remote.py +++ b/src/zarr/storage/remote.py @@ -3,6 +3,7 @@ import warnings from typing import TYPE_CHECKING, Any +from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper from zarr.abc.store import ByteRangeRequest, Store from zarr.storage.common import _dereference_path @@ -167,7 +168,6 @@ def from_url( fs, path = url_to_fs(url, **opts) if not fs.async_impl: - from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper fs = AsyncFileSystemWrapper(fs) # fsspec is not consistent about removing the scheme from the path, so check and strip it here