Skip to content

Commit b438ba8

Browse files
authored
Merge branch 'main' into deterministic-chunk-padding
2 parents 3741122 + 037adf6 commit b438ba8

File tree

14 files changed

+139
-23
lines changed

14 files changed

+139
-23
lines changed

.github/workflows/hypothesis.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ jobs:
6969
path: .hypothesis/
7070
key: cache-hypothesis-${{ runner.os }}-${{ github.run_id }}
7171

72+
- name: Upload coverage
73+
uses: codecov/codecov-action@v5
74+
with:
75+
token: ${{ secrets.CODECOV_TOKEN }}
76+
verbose: true # optional (default = false)
77+
7278
- name: Generate and publish the report
7379
if: |
7480
failure()

changes/2778.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use removeprefix rather than replace when removing filename prefixes in `FsspecStore.list`

changes/2801.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ensure utf8 compliant strings are used to construct numpy arrays in property-based tests

changes/2804.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:py:class:`LocalStore` learned to ``delete_dir``. This makes array and group deletes more efficient.

changes/2807.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix pickling for ZipStore

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ run = "run-coverage --no-cov"
161161
run-pytest = "run"
162162
run-verbose = "run-coverage --verbose"
163163
run-mypy = "mypy src"
164-
run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*"
164+
run-hypothesis = "run-coverage --hypothesis-profile ci --run-slow-hypothesis tests/test_properties.py tests/test_store/test_stateful*"
165165
list-env = "pip list"
166166

167167
[tool.hatch.envs.doctest]
@@ -398,7 +398,8 @@ filterwarnings = [
398398
"ignore:.*is currently not part in the Zarr format 3 specification.*:UserWarning",
399399
]
400400
markers = [
401-
"gpu: mark a test as requiring CuPy and GPU"
401+
"gpu: mark a test as requiring CuPy and GPU",
402+
"slow_hypothesis: slow hypothesis tests",
402403
]
403404

404405
[tool.repo-review]

src/zarr/storage/_fsspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ async def set_partial_values(
341341
async def list(self) -> AsyncIterator[str]:
342342
# docstring inherited
343343
allfiles = await self.fs._find(self.path, detail=False, withdirs=False)
344-
for onefile in (a.replace(self.path + "/", "") for a in allfiles):
344+
for onefile in (a.removeprefix(self.path + "/") for a in allfiles):
345345
yield onefile
346346

347347
async def list_dir(self, prefix: str) -> AsyncIterator[str]:

src/zarr/storage/_local.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ async def delete(self, key: str) -> None:
208208
else:
209209
await asyncio.to_thread(path.unlink, True) # Q: we may want to raise if path is missing
210210

211+
async def delete_dir(self, prefix: str) -> None:
212+
# docstring inherited
213+
self._check_writable()
214+
path = self.root / prefix
215+
if path.is_dir():
216+
shutil.rmtree(path)
217+
elif path.is_file():
218+
raise ValueError(f"delete_dir was passed a {prefix=!r} that is a file")
219+
else:
220+
# Non-existent directory
221+
# This path is tested by test_group:test_create_creates_parents for one
222+
pass
223+
211224
async def exists(self, key: str) -> bool:
212225
# docstring inherited
213226
path = self.root / key

src/zarr/storage/_zip.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ async def _open(self) -> None:
108108
self._sync_open()
109109

110110
def __getstate__(self) -> dict[str, Any]:
111-
state = self.__dict__
111+
# We need a copy to not modify the state of the original store
112+
state = self.__dict__.copy()
112113
for attr in ["_zf", "_lock"]:
113114
state.pop(attr, None)
114115
return state

src/zarr/testing/stateful.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def can_add(self, path: str) -> bool:
6868
# -------------------- store operations -----------------------
6969
@rule(name=node_names, data=st.data())
7070
def add_group(self, name: str, data: DataObject) -> None:
71+
# Handle possible case-insensitive file systems (e.g. MacOS)
72+
if isinstance(self.store, LocalStore):
73+
name = name.lower()
7174
if self.all_groups:
7275
parent = data.draw(st.sampled_from(sorted(self.all_groups)), label="Group parent")
7376
else:
@@ -90,6 +93,9 @@ def add_array(
9093
name: str,
9194
array_and_chunks: tuple[np.ndarray[Any, Any], tuple[int, ...]],
9295
) -> None:
96+
# Handle possible case-insensitive file systems (e.g. MacOS)
97+
if isinstance(self.store, LocalStore):
98+
name = name.lower()
9399
array, chunks = array_and_chunks
94100
fill_value = data.draw(npst.from_dtype(array.dtype))
95101
if self.all_groups:
@@ -135,6 +141,7 @@ def add_array(
135141
# self.model.rename(from_group, new_path)
136142
# self.repo.store.rename(from_group, new_path)
137143

144+
@precondition(lambda self: self.store.supports_deletes)
138145
@precondition(lambda self: len(self.all_arrays) >= 1)
139146
@rule(data=st.data())
140147
def delete_array_using_del(self, data: DataObject) -> None:
@@ -149,6 +156,7 @@ def delete_array_using_del(self, data: DataObject) -> None:
149156
del group[array_name]
150157
self.all_arrays.remove(array_path)
151158

159+
@precondition(lambda self: self.store.supports_deletes)
152160
@precondition(lambda self: len(self.all_groups) >= 2) # fixme don't delete root
153161
@rule(data=st.data())
154162
def delete_group_using_del(self, data: DataObject) -> None:
@@ -284,6 +292,10 @@ def supports_partial_writes(self) -> bool:
284292
def supports_writes(self) -> bool:
285293
return self.store.supports_writes
286294

295+
@property
296+
def supports_deletes(self) -> bool:
297+
return self.store.supports_deletes
298+
287299

288300
class ZarrStoreStateMachine(RuleBasedStateMachine):
289301
""" "
@@ -366,6 +378,7 @@ def get_partial_values(self, data: DataObject) -> None:
366378
model_vals_ls,
367379
)
368380

381+
@precondition(lambda self: self.store.supports_deletes)
369382
@precondition(lambda self: len(self.model.keys()) > 0)
370383
@rule(data=st.data())
371384
def delete(self, data: DataObject) -> None:

0 commit comments

Comments
 (0)