Skip to content

Commit cef4552

Browse files
authored
fix(RemoteStore): avoid listing all objects in remote store in empty() method (#2312)
* fix(RemoteStore): avoid listing all objects in remote store in empty() method * use ls instead of walk
1 parent b8f6cb9 commit cef4552

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/zarr/storage/remote.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ async def clear(self) -> None:
9494
pass
9595

9696
async def empty(self) -> bool:
97-
return not await self.fs._find(self.path, withdirs=True)
97+
# TODO: it would be nice if we didn't have to list all keys here
98+
# it should be possible to stop after the first key is discovered
99+
return not await self.fs._ls(self.path)
98100

99101
def with_mode(self, mode: AccessModeLiteral) -> Self:
100102
return type(self)(

tests/v3/test_store/test_remote.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,13 @@ def test_store_repr(self, store: RemoteStore) -> None:
135135
assert str(store) == "<RemoteStore(S3FileSystem, test)>"
136136

137137
def test_store_supports_writes(self, store: RemoteStore) -> None:
138-
assert True
138+
assert store.supports_writes
139139

140-
@pytest.mark.xfail
141140
def test_store_supports_partial_writes(self, store: RemoteStore) -> None:
142-
raise AssertionError
141+
assert not store.supports_partial_writes
143142

144143
def test_store_supports_listing(self, store: RemoteStore) -> None:
145-
assert True
144+
assert store.supports_listing
146145

147146
async def test_remote_store_from_uri(
148147
self, store: RemoteStore, store_kwargs: dict[str, str | bool]

0 commit comments

Comments
 (0)