Skip to content

Commit 0378530

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 0378530

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/zarr/storage/_fsspec.py

Lines changed: 4 additions & 5 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 filesystems (¯\_(ツ)_/¯)
144144
scheme, _ = path.split("://", maxsplit=1)
145145
raise ValueError(f"path argument to FsspecStore must not include scheme ({scheme}://)")
146146

@@ -249,9 +249,8 @@ def from_url(
249249

250250
# fsspec is not consistent about removing the scheme from the path, so check and strip it here
251251
# 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)
252+
# for http(s) and swift, _strip_protocol() does nothing, since they need the protocol in the path
253+
path = fs._strip_protocol(path)
255254

256255
return cls(fs=fs, path=path, read_only=read_only, allowed_exceptions=allowed_exceptions)
257256

0 commit comments

Comments
 (0)