|
3 | 3 | import json |
4 | 4 | from asyncio import gather |
5 | 5 | from dataclasses import dataclass, field, replace |
| 6 | +from logging import getLogger |
6 | 7 | from typing import TYPE_CHECKING, Any, Literal, cast |
7 | 8 |
|
8 | 9 | import numpy as np |
|
80 | 81 | # Array and AsyncArray are defined in the base ``zarr`` namespace |
81 | 82 | __all__ = ["create_codec_pipeline", "parse_array_metadata"] |
82 | 83 |
|
| 84 | +logger = getLogger(__name__) |
| 85 | + |
83 | 86 |
|
84 | 87 | def parse_array_metadata(data: Any) -> ArrayV2Metadata | ArrayV3Metadata: |
85 | 88 | if isinstance(data, ArrayV2Metadata | ArrayV3Metadata): |
@@ -636,6 +639,8 @@ async def _save_metadata(self, metadata: ArrayMetadata, ensure_parents: bool = F |
636 | 639 | # To enable zarr.create(store, path="a/b/c"), we need to create all the intermediate groups. |
637 | 640 | parents = _build_parents(self) |
638 | 641 |
|
| 642 | + logger.debug("Ensure parents: %s", parents) |
| 643 | + |
639 | 644 | for parent in parents: |
640 | 645 | awaitables.extend( |
641 | 646 | [ |
@@ -2385,11 +2390,9 @@ def chunks_initialized(array: Array | AsyncArray) -> tuple[str, ...]: |
2385 | 2390 | def _build_parents(node: AsyncArray | AsyncGroup) -> list[AsyncGroup]: |
2386 | 2391 | from zarr.core.group import AsyncGroup, GroupMetadata |
2387 | 2392 |
|
2388 | | - if "/" in node.store_path.path: |
2389 | | - required_parts = node.store_path.path.split("/")[:-1] |
2390 | | - else: |
2391 | | - required_parts = [] |
| 2393 | + required_parts = node.store_path.path.split("/")[:-1] |
2392 | 2394 | parents = [ |
| 2395 | + # the root group |
2393 | 2396 | AsyncGroup( |
2394 | 2397 | metadata=GroupMetadata(zarr_format=node.metadata.zarr_format), |
2395 | 2398 | store_path=StorePath(store=node.store_path.store, path=""), |
|
0 commit comments