|
5 | 5 | import os
|
6 | 6 | import warnings
|
7 | 7 | from collections.abc import Callable, Iterable
|
8 |
| -from typing import TYPE_CHECKING, Any |
| 8 | +from typing import TYPE_CHECKING, Any, Literal |
9 | 9 |
|
10 | 10 | import numpy as np
|
11 | 11 | import packaging.version
|
@@ -56,6 +56,7 @@ def _zarr_v3() -> bool:
|
56 | 56 |
|
57 | 57 | # need some special secret attributes to tell us the dimensions
|
58 | 58 | DIMENSION_KEY = "_ARRAY_DIMENSIONS"
|
| 59 | +ZarrFormat = Literal[2, 3] |
59 | 60 |
|
60 | 61 |
|
61 | 62 | def encode_zarr_attr_value(value):
|
@@ -1436,30 +1437,18 @@ def _get_open_params(
|
1436 | 1437 | if isinstance(store, os.PathLike):
|
1437 | 1438 | store = os.fspath(store)
|
1438 | 1439 |
|
1439 |
| - if zarr_version is None: |
1440 |
| - # default to 2 if store doesn't specify it's version (e.g. a path) |
1441 |
| - zarr_version = getattr(store, "_store_version", 2) |
1442 |
| - |
1443 | 1440 | open_kwargs = dict(
|
1444 | 1441 | # mode='a-' is a handcrafted xarray specialty
|
1445 | 1442 | mode="a" if mode == "a-" else mode,
|
1446 | 1443 | synchronizer=synchronizer,
|
1447 | 1444 | path=group,
|
1448 | 1445 | )
|
1449 | 1446 | open_kwargs["storage_options"] = storage_options
|
1450 |
| - if zarr_version > 2: |
1451 |
| - open_kwargs["zarr_version"] = zarr_version |
1452 |
| - |
1453 |
| - if consolidated or consolidate_on_close: |
1454 |
| - raise ValueError( |
1455 |
| - "consolidated metadata has not been implemented for zarr " |
1456 |
| - f"version {zarr_version} yet. Set consolidated=False for " |
1457 |
| - f"zarr version {zarr_version}. See also " |
1458 |
| - "https://github.com/zarr-developers/zarr-specs/issues/136" |
1459 |
| - ) |
1460 | 1447 |
|
1461 |
| - if consolidated is None: |
1462 |
| - consolidated = False |
| 1448 | + if _zarr_v3(): |
| 1449 | + open_kwargs["zarr_format"] = zarr_version |
| 1450 | + else: |
| 1451 | + open_kwargs["zarr_version"] = zarr_version |
1463 | 1452 |
|
1464 | 1453 | if chunk_store is not None:
|
1465 | 1454 | open_kwargs["chunk_store"] = chunk_store
|
|
0 commit comments