Skip to content

Commit f62fe31

Browse files
committed
fail on discovery of consolidated metadata
1 parent 5c05c0c commit f62fe31

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/zarr/metadata/migrate_v3.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ async def remove_metadata(
154154

155155

156156
def _convert_group(zarr_v2: Group, output_path: StorePath, dry_run: bool) -> None:
157+
if zarr_v2.metadata.consolidated_metadata is not None:
158+
raise NotImplementedError("Migration of consolidated metadata isn't supported.")
159+
157160
# process members of the group
158161
for key in zarr_v2:
159162
migrate_to_v3(zarr_v2[key], output_path=output_path / key, dry_run=dry_run)

tests/test_cli/test_migrate_v3.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,19 @@ def test_migrate_v3(local_store: LocalStore, node_type: str) -> None:
448448
assert str(result.exception) == "Only arrays / groups with zarr v2 metadata can be converted"
449449

450450

451+
def test_migrate_consolidated_metadata(local_store: LocalStore) -> None:
452+
"""Attempting to convert a group with consolidated metadata should always fail"""
453+
454+
group = zarr.create_group(store=local_store, zarr_format=2)
455+
group.create_array(shape=(1,), name="a", dtype="uint8")
456+
zarr.consolidate_metadata(local_store)
457+
458+
result = runner.invoke(cli.app, ["migrate", "v3", str(local_store.root)])
459+
assert result.exit_code == 1
460+
assert isinstance(result.exception, NotImplementedError)
461+
assert str(result.exception) == "Migration of consolidated metadata isn't supported."
462+
463+
451464
def test_migrate_unknown_codec(local_store: LocalStore) -> None:
452465
"""Attempting to convert a codec without a v3 equivalent should always fail"""
453466

0 commit comments

Comments
 (0)