Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/zarr/storage/_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def __init__(
category=ZarrUserWarning,
stacklevel=2,
)
if "://" in path and not path.startswith("http"):
# `not path.startswith("http")` is a special case for the http filesystem (¯\_(ツ)_/¯)
if "://" in path and not path.startswith("http") and not path.startswith("swift"):
# special cases for the http(s) and swift filesystem, which need the protocol leaving in the path.
scheme, _ = path.split("://", maxsplit=1)
raise ValueError(f"path argument to FsspecStore must not include scheme ({scheme}://)")

Expand Down Expand Up @@ -249,11 +249,7 @@ def from_url(
if not fs.async_impl:
fs = _make_async(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
if "://" in path and not path.startswith("http"):
# `not path.startswith("http")` is a special case for the http filesystem (¯\_(ツ)_/¯)
path = fs._strip_protocol(path)
path = fs._strip_protocol(path)

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

Expand Down
6 changes: 6 additions & 0 deletions tests/test_store/test_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,9 @@ async def test_with_read_only_auto_mkdir(tmp_path: Path) -> None:

store_w = FsspecStore.from_url(f"file://{tmp_path}", storage_options={"auto_mkdir": False})
_ = store_w.with_read_only()

def test_swift_store() -> None:
"""
Test creating an FsspecStore with a SWIFT URL.
"""
store = FsspecStore.from_url("swift://swift.dkrz.de/dkrz_xxx/testcontainer/test.zarr")
Loading