Skip to content

Commit e9a9b12

Browse files
committed
Add exception for swift in fsspec path handling
http(s) and swift filesystems need the scheme in the path. This commit adds a special case for the swift filesystem, when checking for the scheme presence. Also remove one if for the http(s) schemes. Here all schemes can call fs._strip_protocol(path). For the filesystems that need the scheme in the path, this function will not remove it.
1 parent a0c56fb commit e9a9b12

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/zarr/storage/_fsspec.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def __init__(
139139
f"fs ({fs}) was not created with `asynchronous=True`, this may lead to surprising behavior",
140140
stacklevel=2,
141141
)
142-
if "://" in path and not path.startswith("http"):
143-
# `not path.startswith("http")` is a special case for the http filesystem (¯\_(ツ)_/¯)
142+
if "://" in path and not path.startswith("http") and not path.startswith("swift"):
143+
# special cases for the http(s) and swift filesystem, which need the protocol leaving in the path.
144144
scheme, _ = path.split("://", maxsplit=1)
145145
raise ValueError(f"path argument to FsspecStore must not include scheme ({scheme}://)")
146146

@@ -247,11 +247,7 @@ def from_url(
247247
if not fs.async_impl:
248248
fs = _make_async(fs)
249249

250-
# fsspec is not consistent about removing the scheme from the path, so check and strip it here
251-
# https://github.com/fsspec/filesystem_spec/issues/1722
252-
if "://" in path and not path.startswith("http"):
253-
# `not path.startswith("http")` is a special case for the http filesystem (¯\_(ツ)_/¯)
254-
path = fs._strip_protocol(path)
250+
path = fs._strip_protocol(path)
255251

256252
return cls(fs=fs, path=path, read_only=read_only, allowed_exceptions=allowed_exceptions)
257253

0 commit comments

Comments
 (0)