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
6 changes: 0 additions & 6 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ def pytest_collection_modifyitems(items):
item.add_marker(pytest.mark.mypy)


@pytest.fixture(autouse=True)
def set_zarr_v3_api(monkeypatch):
"""Set ZARR_V3_EXPERIMENTAL_API environment variable for all tests."""
monkeypatch.setenv("ZARR_V3_EXPERIMENTAL_API", "1")


@pytest.fixture(autouse=True)
def add_standard_imports(doctest_namespace, tmpdir):
import numpy as np
Expand Down
16 changes: 16 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ Breaking Changes
* - numbagg
- 0.8
- 0.9
* - numpy
- 1.26
- 2.1
* - packaging
- 24.1
- 24.2
Expand Down Expand Up @@ -96,6 +99,15 @@ Breaking Changes
``open_dataset`` and ``open_datatree`` the default behavior of fsspec is now to
use block caching with a 4MB block size (:pull:`11216`). By `Julia Signell
<https://github.com/jsignell>`_.
- The minimum zarr version is now 3.0. All zarr-python 2.x compatibility code
has been removed from the zarr backend. The following parameters have been
removed:

- ``zarr_version``: Use ``zarr_format`` instead (was deprecated since 2024.9.1).
- ``synchronizer``: Not supported in zarr-python 3.x.
- ``chunk_store``: Not supported in zarr-python 3.x.

By `Joe Hamman <https://github.com/jhamman>`_ (:pull:`11232`).

Deprecations
~~~~~~~~~~~~
Expand All @@ -108,6 +120,10 @@ Bug Fixes
By `Kristian Kollsgård <https://github.com/kkollsga>`_.
- Fix ``Source`` link in api docs (:pull:`11187`)
By `Ian Hunt-Isaak <https://github.com/ianhi>`_
- Fix async zarr tests using ``wraps`` with ``autospec=True`` on async methods,
which caused ``AsyncMock`` objects to leak through instead of real array data
(:pull:`11232`).
By `Joe Hamman <https://github.com/jhamman>`_.
- Coerce masked dask arrays to filled (:issue:`9374` :pull:`11157`).
By `Julia Signell <https://github.com/jsignell>`_
- Fix :py:meth:`Dataset.interp` silently dropping datetime64 and timedelta64
Expand Down
30 changes: 2 additions & 28 deletions xarray/backends/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import importlib
import io
import os
from collections.abc import Callable, Hashable, Iterable, Mapping, MutableMapping
from collections.abc import Callable, Hashable, Iterable, Mapping
from io import IOBase
from itertools import starmap
from numbers import Number
Expand Down Expand Up @@ -634,26 +634,21 @@ def save_mfdataset(
def get_writable_zarr_store(
store: ZarrStoreLike | None = None,
*,
chunk_store: MutableMapping | str | os.PathLike | None = None,
mode: ZarrWriteModes | None = None,
synchronizer=None,
group: str | None = None,
consolidated: bool | None = None,
append_dim: Hashable | None = None,
region: Mapping[str, slice | Literal["auto"]] | Literal["auto"] | None = None,
safe_chunks: bool = True,
align_chunks: bool = False,
storage_options: dict[str, str] | None = None,
zarr_version: int | None = None,
zarr_format: int | None = None,
write_empty_chunks: bool | None = None,
) -> backends.ZarrStore:
"""Create a store for writing to Zarr."""
from xarray.backends.zarr import _choose_default_mode, _get_mappers

kwargs, mapper, chunk_mapper = _get_mappers(
storage_options=storage_options, store=store, chunk_store=chunk_store
)
kwargs, mapper = _get_mappers(storage_options=storage_options, store=store)
mode = _choose_default_mode(mode=mode, append_dim=append_dim, region=region)

if mode == "r+":
Expand All @@ -666,16 +661,13 @@ def get_writable_zarr_store(
return backends.ZarrStore.open_group(
store=mapper,
mode=mode,
synchronizer=synchronizer,
group=group,
consolidated=already_consolidated,
consolidate_on_close=consolidate_on_close,
chunk_store=chunk_mapper,
append_dim=append_dim,
write_region=region,
safe_chunks=safe_chunks,
align_chunks=align_chunks,
zarr_version=zarr_version,
zarr_format=zarr_format,
write_empty=write_empty_chunks,
**kwargs,
Expand All @@ -687,9 +679,7 @@ def get_writable_zarr_store(
def to_zarr(
dataset: Dataset,
store: ZarrStoreLike | None = None,
chunk_store: MutableMapping | str | os.PathLike | None = None,
mode: ZarrWriteModes | None = None,
synchronizer=None,
group: str | None = None,
encoding: Mapping | None = None,
*,
Expand All @@ -700,7 +690,6 @@ def to_zarr(
safe_chunks: bool = True,
align_chunks: bool = False,
storage_options: dict[str, str] | None = None,
zarr_version: int | None = None,
write_empty_chunks: bool | None = None,
chunkmanager_store_kwargs: dict[str, Any] | None = None,
) -> backends.ZarrStore: ...
Expand All @@ -711,9 +700,7 @@ def to_zarr(
def to_zarr(
dataset: Dataset,
store: ZarrStoreLike | None = None,
chunk_store: MutableMapping | str | os.PathLike | None = None,
mode: ZarrWriteModes | None = None,
synchronizer=None,
group: str | None = None,
encoding: Mapping | None = None,
*,
Expand All @@ -724,7 +711,6 @@ def to_zarr(
safe_chunks: bool = True,
align_chunks: bool = False,
storage_options: dict[str, str] | None = None,
zarr_version: int | None = None,
write_empty_chunks: bool | None = None,
chunkmanager_store_kwargs: dict[str, Any] | None = None,
) -> Delayed: ...
Expand All @@ -733,9 +719,7 @@ def to_zarr(
def to_zarr(
dataset: Dataset,
store: ZarrStoreLike | None = None,
chunk_store: MutableMapping | str | os.PathLike | None = None,
mode: ZarrWriteModes | None = None,
synchronizer=None,
group: str | None = None,
encoding: Mapping | None = None,
*,
Expand All @@ -746,7 +730,6 @@ def to_zarr(
safe_chunks: bool = True,
align_chunks: bool = False,
storage_options: dict[str, str] | None = None,
zarr_version: int | None = None,
zarr_format: int | None = None,
write_empty_chunks: bool | None = None,
chunkmanager_store_kwargs: dict[str, Any] | None = None,
Expand All @@ -772,17 +755,14 @@ def to_zarr(

zstore = get_writable_zarr_store(
store,
chunk_store=chunk_store,
mode=mode,
synchronizer=synchronizer,
group=group,
consolidated=consolidated,
append_dim=append_dim,
region=region,
safe_chunks=safe_chunks,
align_chunks=align_chunks,
storage_options=storage_options,
zarr_version=zarr_version,
zarr_format=zarr_format,
write_empty_chunks=write_empty_chunks,
)
Expand Down Expand Up @@ -930,19 +910,16 @@ def _datatree_to_zarr(
store: ZarrStoreLike,
mode: ZarrWriteModes = "w-",
encoding: Mapping[str, Any] | None = None,
synchronizer=None,
group: str | None = None,
write_inherited_coords: bool = False,
*,
chunk_store: MutableMapping | str | PathLike | None = None,
compute: bool = True,
consolidated: bool | None = None,
append_dim: Hashable | None = None,
region: Mapping[str, slice | Literal["auto"]] | Literal["auto"] | None = None,
safe_chunks: bool = True,
align_chunks: bool = False,
storage_options: dict[str, str] | None = None,
zarr_version: int | None = None,
zarr_format: int | None = None,
write_empty_chunks: bool | None = None,
chunkmanager_store_kwargs: dict[str, Any] | None = None,
Expand Down Expand Up @@ -972,17 +949,14 @@ def _datatree_to_zarr(

root_store = get_writable_zarr_store(
store,
chunk_store=chunk_store,
mode=mode,
synchronizer=synchronizer,
group=group,
consolidated=consolidated,
append_dim=append_dim,
region=region,
safe_chunks=safe_chunks,
align_chunks=align_chunks,
storage_options=storage_options,
zarr_version=zarr_version,
zarr_format=zarr_format,
write_empty_chunks=write_empty_chunks,
)
Expand Down
Loading
Loading