Skip to content

Commit 339ab38

Browse files
authored
Merge branch 'main' into benchmark-smoke-test
2 parents 5fefea8 + a4c4404 commit 339ab38

File tree

7 files changed

+41
-5
lines changed

7 files changed

+41
-5
lines changed

.github/workflows/releases.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Wheels
22

33
on:
4+
release:
5+
types:
6+
- published
47
push:
58
branches: [main]
69
pull_request:
@@ -64,7 +67,7 @@ jobs:
6467
name: Upload to PyPI
6568
needs: [build_artifacts, test_dist_pypi]
6669
runs-on: ubuntu-latest
67-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
70+
if: github.event_name == 'release'
6871
environment:
6972
name: releases
7073
url: https://pypi.org/p/zarr

TEAM.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- @dstansby (David Stansby)
1111
- @dcherian (Deepak Cherian)
1212
- @TomAugspurger (Tom Augspurger)
13+
- @maxrjones (Max Jones)
1314

1415
## Emeritus core-developers
1516
- @alimanfoo (Alistair Miles)

changes/3846.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix `ZipStore.list()`, `list_dir()`, and `exists()` to auto-open the zip file when called before `open()`, consistent with the existing behavior of `get()` and `set()`.

docs/release-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@
461461
- Test that a `ValueError` is raised for invalid byte range syntax in `StoreTests`. ([#2693](https://github.com/zarr-developers/zarr-python/issues/2693))
462462
- Separate instantiating and opening a store in `StoreTests`. ([#2693](https://github.com/zarr-developers/zarr-python/issues/2693))
463463
- Add a test for using Stores as a context managers in `StoreTests`. ([#2693](https://github.com/zarr-developers/zarr-python/issues/2693))
464-
- Implemented `LogingStore.open()`. ([#2693](https://github.com/zarr-developers/zarr-python/issues/2693))
464+
- Implemented `LoggingStore.open()`. ([#2693](https://github.com/zarr-developers/zarr-python/issues/2693))
465465
- `LoggingStore` is now a generic class. ([#2693](https://github.com/zarr-developers/zarr-python/issues/2693))
466466
- Change StoreTest's `test_store_repr`, `test_store_supports_writes`,
467467
`test_store_supports_partial_writes`, and `test_store_supports_listing`

src/zarr/storage/_zip.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ async def delete(self, key: str) -> None:
245245

246246
async def exists(self, key: str) -> bool:
247247
# docstring inherited
248+
if not self._is_open:
249+
self._sync_open()
248250
with self._lock:
249251
try:
250252
self._zf.getinfo(key)
@@ -255,6 +257,8 @@ async def exists(self, key: str) -> bool:
255257

256258
async def list(self) -> AsyncIterator[str]:
257259
# docstring inherited
260+
if not self._is_open:
261+
self._sync_open()
258262
with self._lock:
259263
for key in self._zf.namelist():
260264
yield key
@@ -267,6 +271,8 @@ async def list_prefix(self, prefix: str) -> AsyncIterator[str]:
267271

268272
async def list_dir(self, prefix: str) -> AsyncIterator[str]:
269273
# docstring inherited
274+
if not self._is_open:
275+
self._sync_open()
270276
prefix = prefix.rstrip("/")
271277

272278
keys = self._zf.namelist()

tests/test_array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,19 @@ def test_array_name_properties_with_group(
209209

210210
@pytest.mark.filterwarnings("ignore::zarr.core.dtype.common.UnstableSpecificationWarning")
211211
@pytest.mark.parametrize("store", ["memory"], indirect=True)
212-
@pytest.mark.parametrize("specifiy_fill_value", [True, False])
212+
@pytest.mark.parametrize("specify_fill_value", [True, False])
213213
@pytest.mark.parametrize(
214214
"zdtype", zdtype_examples, ids=tuple(str(type(v)) for v in zdtype_examples)
215215
)
216216
def test_array_fill_value_default(
217-
store: MemoryStore, specifiy_fill_value: bool, zdtype: ZDType[Any, Any]
217+
store: MemoryStore, specify_fill_value: bool, zdtype: ZDType[Any, Any]
218218
) -> None:
219219
"""
220220
Test that creating an array with the fill_value parameter set to None, or unspecified,
221221
results in the expected fill_value attribute of the array, i.e. the default value of the dtype
222222
"""
223223
shape = (10,)
224-
if specifiy_fill_value:
224+
if specify_fill_value:
225225
arr = zarr.create_array(
226226
store=store,
227227
shape=shape,

tests/test_store/test_zip.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,31 @@ def test_externally_zipped_store(self, tmp_path: Path) -> None:
139139
assert isinstance(group := zipped["foo"], Group)
140140
assert list(group.keys()) == list(group.keys())
141141

142+
async def test_list_without_explicit_open(self, tmp_path: Path) -> None:
143+
# ZipStore.list(), list_dir(), and exists() should auto-open
144+
# the zip file just like _get() and _set() do.
145+
zip_path = tmp_path / "data.zip"
146+
zarr_path = tmp_path / "foo.zarr"
147+
root = zarr.open_group(store=zarr_path, mode="w")
148+
root["x"] = np.array([1, 2, 3])
149+
shutil.make_archive(str(zarr_path), "zip", zarr_path)
150+
shutil.move(str(zarr_path) + ".zip", zip_path)
151+
152+
store = ZipStore(zip_path, mode="r")
153+
assert not store._is_open
154+
155+
keys = [k async for k in store.list()]
156+
assert len(keys) > 0
157+
158+
store2 = ZipStore(zip_path, mode="r")
159+
assert not store2._is_open
160+
assert await store2.exists(keys[0])
161+
162+
store3 = ZipStore(zip_path, mode="r")
163+
assert not store3._is_open
164+
dir_keys = [k async for k in store3.list_dir("")]
165+
assert len(dir_keys) > 0
166+
142167
async def test_move(self, tmp_path: Path) -> None:
143168
origin = tmp_path / "origin.zip"
144169
destination = tmp_path / "some_folder" / "destination.zip"

0 commit comments

Comments
 (0)