Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/4684.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`zarr.consolidate_metadata` now picks up arrays that were resized or added inside a nested group that carries its own consolidated metadata. Before, the groups below the first level were listed from the consolidated metadata that they carried instead of from the store. The result kept the old shape of a resized array and missed an array that was added.
6 changes: 5 additions & 1 deletion src/zarr/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -3691,7 +3691,11 @@ async def _iter_members_deep(
if is_group and do_recursion:
node = cast("AsyncGroup", node)
to_recurse[name] = _iter_members_deep(
node, max_depth=new_depth, skip_keys=skip_keys, semaphore=semaphore
node,
max_depth=new_depth,
skip_keys=skip_keys,
semaphore=semaphore,
use_consolidated_for_children=use_consolidated_for_children,
)

for prefix, subgroup_iter in to_recurse.items():
Expand Down
20 changes: 20 additions & 0 deletions tests/test_metadata/test_consolidated.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,26 @@ async def test_use_consolidated_for_children_members(
expected = ["b", "b/c"]
assert result == expected

async def test_use_consolidated_for_children_members_nested(
self, memory_store: zarr.storage.MemoryStore
) -> None:
# As the test above, but the child group with consolidated metadata is
# two levels below the group whose members are listed.

root = await zarr.api.asynchronous.create_group(store=memory_store)
await root.create_group("a/b")
# Consolidate metadata at "a/b"
await zarr.api.asynchronous.consolidate_metadata(memory_store, path="a/b")

# Add a new group a/b/c, that's not present in the CM at "a/b"
await root.create_group("a/b/c")

result = sorted(
[x[0] async for x in root.members(max_depth=None, use_consolidated_for_children=False)]
)
expected = ["a", "a/b", "a/b/c"]
assert result == expected

async def test_absolute_path_for_subgroup(self, memory_store: zarr.storage.MemoryStore) -> None:
root = await zarr.api.asynchronous.create_group(store=memory_store)
await root.create_group("a/b")
Expand Down