Skip to content

Commit 658de0e

Browse files
authored
Merge branch 'main' into doc/undocument-deprecated-config
2 parents e4dd7e2 + a830d02 commit 658de0e

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

.github/workflows/check_changelogs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1313

1414
- name: Install uv
15-
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
15+
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
1616

1717
- name: Check changelog entries
1818
run: uv run --no-sync python ci/check_changelog_entries.py

changes/3444.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Trying to open a group at a path were a array already exists now raises a helpful error.

src/zarr/core/group.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from zarr.errors import (
5454
ContainsArrayError,
5555
ContainsGroupError,
56+
GroupNotFoundError,
5657
MetadataValidationError,
5758
ZarrDeprecationWarning,
5859
ZarrUserWarning,
@@ -673,6 +674,13 @@ def from_dict(
673674
store_path: StorePath,
674675
data: dict[str, Any],
675676
) -> AsyncGroup:
677+
node_type = data.pop("node_type", None)
678+
if node_type == "array":
679+
msg = f"An array already exists in store {store_path.store} at path {store_path.path}."
680+
raise ContainsArrayError(msg)
681+
elif node_type not in ("group", None):
682+
msg = f"Node type in metadata ({node_type}) is not 'group'"
683+
raise GroupNotFoundError(msg)
676684
return cls(
677685
metadata=GroupMetadata.from_dict(data),
678686
store_path=store_path,

tests/test_group.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,3 +2234,9 @@ def test_get_roots(roots: tuple[str, ...]):
22342234
}
22352235
data = root_nodes | child_nodes
22362236
assert set(_get_roots(data)) == set(roots)
2237+
2238+
2239+
def test_open_array_as_group():
2240+
z = zarr.create_array(shape=(40, 50), chunks=(10, 10), dtype="f8", store={})
2241+
with pytest.raises(ContainsArrayError):
2242+
zarr.open_group(z.store)

0 commit comments

Comments
 (0)