Skip to content

fix: honor use_consolidated_for_children, merge async attribute updates, cancel timed-out sync coroutines - #4343

Draft
d-v-b wants to merge 3 commits into
zarr-developers:mainfrom
d-v-b:group-sync-misc-bugfixes
Draft

fix: honor use_consolidated_for_children, merge async attribute updates, cancel timed-out sync coroutines#4343
d-v-b wants to merge 3 commits into
zarr-developers:mainfrom
d-v-b:group-sync-misc-bugfixes

Conversation

@d-v-b

@d-v-b d-v-b commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Summary

Five small, independent, backwards-compatible bugfixes in Group, sync, storage and the GPU buffer, each with a regression test where CI can run one. Originally prototyped as d-v-b#190 and rebased onto current main.

members ignored use_consolidated_for_children when the root has consolidated metadata

AsyncGroup._members short-circuited to _members_consolidated() whenever self.metadata.consolidated_metadata is not None, so the flag had no effect. Group.members (sync) also did not forward the flag, and _iter_members_deep did not pass it on recursive calls. All three now honor and forward it. The docstrings previously stated that root consolidated metadata is "always used"; they now describe the new behaviour.

  • src/zarr/core/group.py

Group.update_attributes_async replaced attributes instead of merging

It called replace(self.metadata, attributes=new_attributes) while AsyncGroup.update_attributes and Group.update_attributes both merge. It now merges. An existing test that asserted the replace behaviour was updated.

  • src/zarr/core/group.py

sync() timeout left the coroutine running

On timeout, wait() returned the future in unfinished but nothing cancelled it, so the coroutine kept running on the IO thread. future.cancel() is now called before raising TimeoutError.

  • src/zarr/core/sync.py

Deprecation warning for zarr.storage.default_compressor pointed at a removed config key

The message recommended array.v2_default_compressor.numeric, which was removed in 3.1.0. It now points at the compressors= argument to zarr.create_array().

  • src/zarr/storage/__init__.py

GPU NDBuffer.create(fill_value=None) diverged from CPU

The GPU buffer used cp.empty (uninitialised) when no fill value was given, while the CPU buffer uses np.zeros. It now zero-fills to match. cupy is not available in standard CI; GPU CI should validate this.

  • src/zarr/core/buffer/gpu.py

Dropped from the original prototype

The require_array(dtype=None) change was dropped: #4189 deliberately kept the float64 default and tests it.

Test results

uv run pytest tests/test_group.py tests/test_sync.py tests/test_metadata/test_consolidated.py -q
914 passed, 207 skipped in 4.89s

Pre-commit (ruff, mypy, numpydoc-validation, codespell) passes.

TODO

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md (not applicable, bugfixes only)
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

🤖 Generated with Claude Code

…ribute updates, cancel timed-out sync coroutines

- `AsyncGroup.members`, `Group.members` and `_iter_members_deep` now honor
  and forward `use_consolidated_for_children`, instead of unconditionally
  short-circuiting to consolidated metadata when the root has it.
- `Group.update_attributes_async` merges new attributes into the existing
  ones, matching `Group.update_attributes` and `AsyncGroup.update_attributes`.
- `sync()` cancels the pending future when it times out instead of leaving
  the coroutine running on the IO thread.
- The `zarr.storage.default_compressor` deprecation warning no longer points
  at the removed `array.v2_default_compressor` config key.
- GPU `NDBuffer.create` zero-fills when no fill value is given, matching the
  CPU buffer.

Addresses B11, B12, B14, B15 and B16 of #181. B13
(`require_array(dtype=None)`) was dropped: zarr-developers#4189
deliberately kept the float64 default.

Assisted-by: ClaudeCode:claude-fable-5-1
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.34%. Comparing base (ba883a5) to head (dfd2a2d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4343   +/-   ##
=======================================
  Coverage   94.34%   94.34%           
=======================================
  Files          92       92           
  Lines       12935    12941    +6     
=======================================
+ Hits        12203    12209    +6     
  Misses        732      732           
Files with missing lines Coverage Δ
src/zarr/core/buffer/gpu.py 90.47% <100.00%> (+0.11%) ⬆️
src/zarr/core/group.py 95.54% <100.00%> (+0.01%) ⬆️
src/zarr/core/sync.py 94.28% <100.00%> (+0.05%) ⬆️
src/zarr/storage/__init__.py 95.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

d-v-b and others added 2 commits September 12, 2026 18:22
Also specify Zarr format 2 in the deprecated compressor migration example.

Assisted-by: Codex:GPT-6
…xercise the recursion fix

Address roborev findings on eff4c60:

- Rebuild the members-recursion test so a nested group really carries
  stale consolidated metadata (consolidate at a/b, then create a/b/c).
  The previous version passed with the `_iter_members_deep` change
  reverted.
- Rename the changelog fragment to the upstream PR number (4343).
- Narrow the `update_attributes_async` docstring: merge semantics match
  `Group.update_attributes`, but it returns a new `Group`.
- Reword the GPU zero-fill comment and assert zero-fill in the existing
  GPU buffer test.

Assisted-by: ClaudeCode:claude-fable-5-1
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant