Skip to content

Commit cca0392

Browse files
authored
Merge branch 'main' into fix-set-if-not-exists-test
2 parents ae770eb + ab1a7b3 commit cca0392

File tree

7 files changed

+42
-40
lines changed

7 files changed

+42
-40
lines changed

docs/release.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Dependency Changes
3939
fsspec and any relevant implementations (e.g. s3fs) before using the ``RemoteStore``.
4040
By :user:`Joe Hamman <jhamman>` :issue:`2391`.
4141

42+
* ``RemoteStore`` was renamed to ``FsspecStore``.
43+
By :user:`Joe Hamman <jhamman>` :issue:`2557`.
4244

4345
.. release_3.0.0-alpha:
4446

src/zarr/storage/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
from zarr.storage.common import StoreLike, StorePath, make_store_path
2+
from zarr.storage.fsspec import FsspecStore
23
from zarr.storage.local import LocalStore
34
from zarr.storage.logging import LoggingStore
45
from zarr.storage.memory import MemoryStore
5-
from zarr.storage.remote import RemoteStore
66
from zarr.storage.wrapper import WrapperStore
77
from zarr.storage.zip import ZipStore
88

99
__all__ = [
10+
"FsspecStore",
1011
"LocalStore",
1112
"LoggingStore",
1213
"MemoryStore",
13-
"RemoteStore",
1414
"StoreLike",
1515
"StorePath",
1616
"WrapperStore",

src/zarr/storage/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ async def make_store_path(
281281
TypeError
282282
If the StoreLike object is not one of the supported types.
283283
"""
284-
from zarr.storage.remote import RemoteStore # circular import
284+
from zarr.storage.fsspec import FsspecStore # circular import
285285

286286
used_storage_options = False
287287
path_normalized = normalize_path(path)
@@ -302,7 +302,7 @@ async def make_store_path(
302302

303303
if _is_fsspec_uri(store_like):
304304
used_storage_options = True
305-
store = RemoteStore.from_url(
305+
store = FsspecStore.from_url(
306306
store_like, storage_options=storage_options, read_only=_read_only
307307
)
308308
else:

src/zarr/storage/remote.py renamed to src/zarr/storage/fsspec.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323

2424

25-
class RemoteStore(Store):
25+
class FsspecStore(Store):
2626
"""
2727
A remote Store based on FSSpec
2828
@@ -61,8 +61,8 @@ class RemoteStore(Store):
6161
6262
See Also
6363
--------
64-
RemoteStore.from_upath
65-
RemoteStore.from_url
64+
FsspecStore.from_upath
65+
FsspecStore.from_url
6666
"""
6767

6868
# based on FSSpec
@@ -96,17 +96,17 @@ def __init__(
9696
if "://" in path and not path.startswith("http"):
9797
# `not path.startswith("http")` is a special case for the http filesystem (¯\_(ツ)_/¯)
9898
scheme, _ = path.split("://", maxsplit=1)
99-
raise ValueError(f"path argument to RemoteStore must not include scheme ({scheme}://)")
99+
raise ValueError(f"path argument to FsspecStore must not include scheme ({scheme}://)")
100100

101101
@classmethod
102102
def from_upath(
103103
cls,
104104
upath: Any,
105105
read_only: bool = False,
106106
allowed_exceptions: tuple[type[Exception], ...] = ALLOWED_EXCEPTIONS,
107-
) -> RemoteStore:
107+
) -> FsspecStore:
108108
"""
109-
Create a RemoteStore from an upath object.
109+
Create a FsspecStore from an upath object.
110110
111111
Parameters
112112
----------
@@ -120,7 +120,7 @@ def from_upath(
120120
121121
Returns
122122
-------
123-
RemoteStore
123+
FsspecStore
124124
"""
125125
return cls(
126126
fs=upath.fs,
@@ -136,9 +136,9 @@ def from_url(
136136
storage_options: dict[str, Any] | None = None,
137137
read_only: bool = False,
138138
allowed_exceptions: tuple[type[Exception], ...] = ALLOWED_EXCEPTIONS,
139-
) -> RemoteStore:
139+
) -> FsspecStore:
140140
"""
141-
Create a RemoteStore from a URL.
141+
Create a FsspecStore from a URL.
142142
143143
Parameters
144144
----------
@@ -154,7 +154,7 @@ def from_url(
154154
155155
Returns
156156
-------
157-
RemoteStore
157+
FsspecStore
158158
"""
159159
try:
160160
from fsspec import url_to_fs
@@ -185,7 +185,7 @@ async def clear(self) -> None:
185185
pass
186186

187187
def __repr__(self) -> str:
188-
return f"<RemoteStore({type(self.fs).__name__}, {self.path})>"
188+
return f"<FsspecStore({type(self.fs).__name__}, {self.path})>"
189189

190190
def __eq__(self, other: object) -> bool:
191191
return (

tests/conftest.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from zarr.abc.store import Store
1414
from zarr.core.sync import sync
1515
from zarr.storage import LocalStore, MemoryStore, StorePath, ZipStore
16-
from zarr.storage.remote import RemoteStore
16+
from zarr.storage.fsspec import FsspecStore
1717

1818
if TYPE_CHECKING:
1919
from collections.abc import Generator
@@ -25,14 +25,14 @@
2525

2626

2727
async def parse_store(
28-
store: Literal["local", "memory", "remote", "zip"], path: str
29-
) -> LocalStore | MemoryStore | RemoteStore | ZipStore:
28+
store: Literal["local", "memory", "fsspec", "zip"], path: str
29+
) -> LocalStore | MemoryStore | FsspecStore | ZipStore:
3030
if store == "local":
3131
return await LocalStore.open(path)
3232
if store == "memory":
3333
return await MemoryStore.open()
34-
if store == "remote":
35-
return await RemoteStore.open(url=path)
34+
if store == "fsspec":
35+
return await FsspecStore.open(url=path)
3636
if store == "zip":
3737
return await ZipStore.open(path + "/zarr.zip", mode="w")
3838
raise AssertionError
@@ -56,8 +56,8 @@ async def local_store(tmpdir: LEGACY_PATH) -> LocalStore:
5656

5757

5858
@pytest.fixture
59-
async def remote_store(url: str) -> RemoteStore:
60-
return await RemoteStore.open(url)
59+
async def remote_store(url: str) -> FsspecStore:
60+
return await FsspecStore.open(url)
6161

6262

6363
@pytest.fixture
@@ -87,7 +87,7 @@ def sync_store(request: pytest.FixtureRequest, tmp_path: LEGACY_PATH) -> Store:
8787
@dataclass
8888
class AsyncGroupRequest:
8989
zarr_format: ZarrFormat
90-
store: Literal["local", "remote", "memory", "zip"]
90+
store: Literal["local", "fsspec", "memory", "zip"]
9191
attributes: dict[str, Any] = field(default_factory=dict)
9292

9393

tests/test_store/test_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from zarr.core.common import AccessModeLiteral
88
from zarr.storage._utils import normalize_path
99
from zarr.storage.common import StoreLike, StorePath, make_store_path
10+
from zarr.storage.fsspec import FsspecStore
1011
from zarr.storage.local import LocalStore
1112
from zarr.storage.memory import MemoryStore
12-
from zarr.storage.remote import RemoteStore
1313

1414

1515
@pytest.mark.parametrize("path", [None, "", "bar"])
@@ -73,7 +73,7 @@ async def test_make_store_path_invalid() -> None:
7373
async def test_make_store_path_fsspec(monkeypatch) -> None:
7474
pytest.importorskip("fsspec")
7575
store_path = await make_store_path("http://foo.com/bar")
76-
assert isinstance(store_path.store, RemoteStore)
76+
assert isinstance(store_path.store, FsspecStore)
7777

7878

7979
@pytest.mark.parametrize(

tests/test_store/test_remote.py renamed to tests/test_store/test_fsspec.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import zarr.api.asynchronous
1111
from zarr.core.buffer import Buffer, cpu, default_buffer_prototype
1212
from zarr.core.sync import _collect_aiterator, sync
13-
from zarr.storage import RemoteStore
13+
from zarr.storage import FsspecStore
1414
from zarr.testing.store import StoreTests
1515

1616
if TYPE_CHECKING:
@@ -84,7 +84,7 @@ def s3(s3_base: None) -> Generator[s3fs.S3FileSystem, None, None]:
8484

8585

8686
async def test_basic() -> None:
87-
store = RemoteStore.from_url(
87+
store = FsspecStore.from_url(
8888
f"s3://{test_bucket_name}/foo/spam/",
8989
storage_options={"endpoint_url": endpoint_url, "anon": False},
9090
)
@@ -102,8 +102,8 @@ async def test_basic() -> None:
102102
assert out[0].to_bytes() == data[1:]
103103

104104

105-
class TestRemoteStoreS3(StoreTests[RemoteStore, cpu.Buffer]):
106-
store_cls = RemoteStore
105+
class TestFsspecStoreS3(StoreTests[FsspecStore, cpu.Buffer]):
106+
store_cls = FsspecStore
107107
buffer_cls = cpu.Buffer
108108

109109
@pytest.fixture
@@ -114,36 +114,36 @@ def store_kwargs(self, request) -> dict[str, str | bool]:
114114
return {"fs": fs, "path": path}
115115

116116
@pytest.fixture
117-
def store(self, store_kwargs: dict[str, str | bool]) -> RemoteStore:
117+
def store(self, store_kwargs: dict[str, str | bool]) -> FsspecStore:
118118
return self.store_cls(**store_kwargs)
119119

120-
async def get(self, store: RemoteStore, key: str) -> Buffer:
120+
async def get(self, store: FsspecStore, key: str) -> Buffer:
121121
# make a new, synchronous instance of the filesystem because this test is run in sync code
122122
new_fs = fsspec.filesystem(
123123
"s3", endpoint_url=store.fs.endpoint_url, anon=store.fs.anon, asynchronous=False
124124
)
125125
return self.buffer_cls.from_bytes(new_fs.cat(f"{store.path}/{key}"))
126126

127-
async def set(self, store: RemoteStore, key: str, value: Buffer) -> None:
127+
async def set(self, store: FsspecStore, key: str, value: Buffer) -> None:
128128
# make a new, synchronous instance of the filesystem because this test is run in sync code
129129
new_fs = fsspec.filesystem(
130130
"s3", endpoint_url=store.fs.endpoint_url, anon=store.fs.anon, asynchronous=False
131131
)
132132
new_fs.write_bytes(f"{store.path}/{key}", value.to_bytes())
133133

134-
def test_store_repr(self, store: RemoteStore) -> None:
135-
assert str(store) == "<RemoteStore(S3FileSystem, test)>"
134+
def test_store_repr(self, store: FsspecStore) -> None:
135+
assert str(store) == "<FsspecStore(S3FileSystem, test)>"
136136

137-
def test_store_supports_writes(self, store: RemoteStore) -> None:
137+
def test_store_supports_writes(self, store: FsspecStore) -> None:
138138
assert store.supports_writes
139139

140-
def test_store_supports_partial_writes(self, store: RemoteStore) -> None:
140+
def test_store_supports_partial_writes(self, store: FsspecStore) -> None:
141141
assert not store.supports_partial_writes
142142

143-
def test_store_supports_listing(self, store: RemoteStore) -> None:
143+
def test_store_supports_listing(self, store: FsspecStore) -> None:
144144
assert store.supports_listing
145145

146-
async def test_remote_store_from_uri(self, store: RemoteStore):
146+
async def test_fsspec_store_from_uri(self, store: FsspecStore) -> None:
147147
storage_options = {
148148
"endpoint_url": endpoint_url,
149149
"anon": False,
@@ -188,7 +188,7 @@ def test_from_upath(self) -> None:
188188
anon=False,
189189
asynchronous=True,
190190
)
191-
result = RemoteStore.from_upath(path)
191+
result = FsspecStore.from_upath(path)
192192
assert result.fs.endpoint_url == endpoint_url
193193
assert result.fs.asynchronous
194194
assert result.path == f"{test_bucket_name}/foo/bar"
@@ -197,7 +197,7 @@ def test_init_raises_if_path_has_scheme(self, store_kwargs) -> None:
197197
# regression test for https://github.com/zarr-developers/zarr-python/issues/2342
198198
store_kwargs["path"] = "s3://" + store_kwargs["path"]
199199
with pytest.raises(
200-
ValueError, match="path argument to RemoteStore must not include scheme .*"
200+
ValueError, match="path argument to FsspecStore must not include scheme .*"
201201
):
202202
self.store_cls(**store_kwargs)
203203

0 commit comments

Comments
 (0)