Skip to content
Draft
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
33 changes: 33 additions & 0 deletions changes/3325.removal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
The deprecated ``zarr.convenience`` sub-module has been removed.
All functions are available in the top-level `zarr` namespace.

The following deprecated methods have been removed:

- ``AsyncArray.create`` - use `zarr.api.asynchronous.create_array` instead.
- ``Array.create`` - use `zarr.create_array` instead.

The ``codecs`` argument on the removed methods corresponds to a combination of the ``compressors`` and ``serializer`` arguments on their replacements,
and the ``chunk_shape`` argument on the removed methods corresponds to the ``chunks`` argument on their replacements.

The following deprecated properties have been removed:

- ``AsyncArray.compressor`` - use ``AsyncArray.compressors[0]`` instead for Zarr format 2 arrays.
- ``Array.compressor`` - use ``Array.compressors[0]`` instead for Zarr format 2 arrays.
- ``AsyncGroup.create_dataset`` - use `AsyncGroup.create_array` instead
- ``AsyncGroup.require_dataset`` - use `AsyncGroup.require_array` instead
- ``Group.create_dataset`` - use `Group.create_array` instead
- ``Group.require_dataset`` - use `Group.require_array` instead
- ``Group.array`` - use `Group.create_array` instead

The following deprecated functions have been removed:

- ``zarr.api.asynchronous.tree`` - use `AsyncGroup.tree` instead
- ``zarr.api.synchronous.tree`` - use `Group.tree` instead
- ``zarr.tree`` - use `Group.tree` instead


Setting ``zarr.storage.default_compressor`` is deprecated, use `zarr.config` to configure ``array.v2_default_compressor``
e.g. ``zarr.config.set({'codecs.zstd':'numcodecs.Zstd', 'array.v2_default_compressor.numeric': 'zstd'})``

The ``zarr_version`` argument has been removed throughout the library.
Use the equivalent ``zarr_format`` argument instead.
1 change: 0 additions & 1 deletion docs/api/convenience.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ title: convenience
::: zarr.copy_all
::: zarr.copy_store
::: zarr.print_debug_info
::: zarr.tree
1 change: 0 additions & 1 deletion docs/api/deprecated/convenience.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/api/deprecated/creation.md

This file was deleted.

8 changes: 0 additions & 8 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ The ABC module defines interfaces for extending Zarr:
- **[Errors](errors.md)** - Exception classes and error handling
- **[Testing](testing.md)** - Utilities for testing Zarr-based code


## Migration and Compatibility

- **[Deprecated Functions](deprecated/convenience.md)** - Legacy convenience functions
- **[Deprecated Creation](deprecated/creation.md)** - Legacy array creation functions

These deprecated modules are maintained for backward compatibility but should be avoided in new code.

## Getting Help

- Check the [User Guide](../user-guide/index.md) for tutorials and examples
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ For more information, see the

Configuration options include the following:

- Default Zarr format `default_zarr_version`
- Default Zarr format `default_zarr_format`
- Default array order in memory `array.order`
- Whether empty chunks are written to storage `array.write_empty_chunks`
- Async and threading options, e.g. `async.concurrency` and `threading.max_workers`
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/v3_migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The following sections provide details on breaking changes in Zarr-Python 3.

2. Defaulting to `zarr_format=3` - newly created arrays will use the version 3 of the
Zarr specification. To continue using version 2, set `zarr_format=2` when creating arrays
or set `default_zarr_version=2` in Zarr's runtime configuration.
or set `default_zarr_format=2` in Zarr's runtime configuration.

### The Group class

Expand Down
3 changes: 0 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ nav:
- api/abc/codec.md
- api/abc/metadata.md
- api/abc/store.md
- deprecated:
- Convenience sub-module: api/deprecated/convenience.md
- Creation sub-module: api/deprecated/creation.md
- release-notes.md
- contributing.md
watch:
Expand Down
2 changes: 0 additions & 2 deletions src/zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
save,
save_array,
save_group,
tree,
zeros,
zeros_like,
)
Expand Down Expand Up @@ -177,7 +176,6 @@ def set_format(log_format: str) -> None:
"save",
"save_array",
"save_group",
"tree",
"zeros",
"zeros_like",
]
84 changes: 4 additions & 80 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import numpy as np
import numpy.typing as npt
from typing_extensions import deprecated

from zarr.abc.store import Store
from zarr.core.array import (
Expand Down Expand Up @@ -42,7 +41,6 @@
ArrayNotFoundError,
GroupNotFoundError,
NodeTypeValidationError,
ZarrDeprecationWarning,
ZarrRuntimeWarning,
ZarrUserWarning,
)
Expand Down Expand Up @@ -89,7 +87,6 @@
"save",
"save_array",
"save_group",
"tree",
"zeros",
"zeros_like",
]
Expand Down Expand Up @@ -168,22 +165,6 @@ def _like_args(a: ArrayLike) -> _LikeArgs:
return new


def _handle_zarr_version_or_format(
*, zarr_version: ZarrFormat | None, zarr_format: ZarrFormat | None
) -> ZarrFormat | None:
"""Handle the deprecated zarr_version kwarg and return zarr_format"""
if zarr_format is not None and zarr_version is not None and zarr_format != zarr_version:
raise ValueError(
f"zarr_format {zarr_format} does not match zarr_version {zarr_version}, please only set one"
)
if zarr_version is not None:
warnings.warn(
"zarr_version is deprecated, use zarr_format", ZarrDeprecationWarning, stacklevel=2
)
return zarr_version
return zarr_format


async def consolidate_metadata(
store: StoreLike,
path: str | None = None,
Expand Down Expand Up @@ -288,7 +269,6 @@ async def load(
store: StoreLike,
path: str | None = None,
zarr_format: ZarrFormat | None = None,
zarr_version: ZarrFormat | None = None,
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
"""Load data from an array or group into memory.

Expand Down Expand Up @@ -317,8 +297,6 @@ async def load(
If loading data from a group of arrays, data will not be immediately loaded into
memory. Rather, arrays will be loaded into memory as they are requested.
"""
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)

obj = await open(store=store, path=path, zarr_format=zarr_format)
if isinstance(obj, AsyncArray):
return await obj.getitem(slice(None))
Expand All @@ -330,7 +308,6 @@ async def open(
*,
store: StoreLike | None = None,
mode: AccessModeLiteral | None = None,
zarr_version: ZarrFormat | None = None, # deprecated
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
Expand Down Expand Up @@ -358,15 +335,14 @@ async def open(
If using an fsspec URL to create the store, these will be passed to
the backend implementation. Ignored otherwise.
**kwargs
Additional parameters are passed through to [`zarr.creation.open_array`][] or
Additional parameters are passed through to [`zarr.api.asynchronous.open_array`][] or
[`open_group`][zarr.api.asynchronous.open_group].

Returns
-------
z : array or group
Return type depends on what exists in the given store.
"""
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
if mode is None:
if isinstance(store, (Store, StorePath)) and store.read_only:
mode = "r"
Expand Down Expand Up @@ -417,7 +393,6 @@ async def open_consolidated(
async def save(
store: StoreLike,
*args: NDArrayLike,
zarr_version: ZarrFormat | None = None, # deprecated
zarr_format: ZarrFormat | None = None,
path: str | None = None,
**kwargs: Any, # TODO: type kwargs as valid args to save
Expand All @@ -439,7 +414,6 @@ async def save(
**kwargs
NumPy arrays with data to save.
"""
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)

if len(args) == 0 and len(kwargs) == 0:
raise ValueError("at least one array must be provided")
Expand All @@ -453,7 +427,6 @@ async def save_array(
store: StoreLike,
arr: NDArrayLike,
*,
zarr_version: ZarrFormat | None = None, # deprecated
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
Expand Down Expand Up @@ -481,10 +454,7 @@ async def save_array(
**kwargs
Passed through to [`create`][zarr.api.asynchronous.create], e.g., compressor.
"""
zarr_format = (
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
or _default_zarr_format()
)
zarr_format = zarr_format or _default_zarr_format()
if not isinstance(arr, NDArrayLike):
raise TypeError("arr argument must be numpy or other NDArrayLike array")

Expand All @@ -511,7 +481,6 @@ async def save_array(
async def save_group(
store: StoreLike,
*args: NDArrayLike,
zarr_version: ZarrFormat | None = None, # deprecated
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
Expand Down Expand Up @@ -541,13 +510,7 @@ async def save_group(

store_path = await make_store_path(store, path=path, mode="w", storage_options=storage_options)

zarr_format = (
_handle_zarr_version_or_format(
zarr_version=zarr_version,
zarr_format=zarr_format,
)
or _default_zarr_format()
)
zarr_format = zarr_format or _default_zarr_format()

for arg in args:
if not isinstance(arg, NDArrayLike):
Expand Down Expand Up @@ -576,31 +539,6 @@ async def save_group(
await asyncio.gather(*aws)


@deprecated("Use AsyncGroup.tree instead.", category=ZarrDeprecationWarning)
async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any:
"""Provide a rich display of the hierarchy.

!!! warning "Deprecated"
`zarr.tree()` is deprecated since v3.0.0 and will be removed in a future release.
Use `group.tree()` instead.

Parameters
----------
grp : Group
Zarr or h5py group.
expand : bool, optional
Only relevant for HTML representation. If True, tree will be fully expanded.
level : int, optional
Maximum depth to descend into hierarchy.

Returns
-------
TreeRepr
A pretty-printable object displaying the hierarchy.
"""
return await grp.tree(expand=expand, level=level)


async def array(
data: npt.ArrayLike | Array, **kwargs: Any
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
Expand Down Expand Up @@ -663,7 +601,6 @@ async def group(
cache_attrs: bool | None = None, # not used, default changed
synchronizer: Any | None = None, # not used
path: str | None = None,
zarr_version: ZarrFormat | None = None, # deprecated
zarr_format: ZarrFormat | None = None,
meta_array: Any | None = None, # not used
attributes: dict[str, JSON] | None = None,
Expand Down Expand Up @@ -716,7 +653,6 @@ async def group(
cache_attrs=cache_attrs,
synchronizer=synchronizer,
path=path,
zarr_version=zarr_version,
zarr_format=zarr_format,
meta_array=meta_array,
attributes=attributes,
Expand Down Expand Up @@ -785,7 +721,6 @@ async def open_group(
path: str | None = None,
chunk_store: StoreLike | None = None, # not used
storage_options: dict[str, Any] | None = None,
zarr_version: ZarrFormat | None = None, # deprecated
zarr_format: ZarrFormat | None = None,
meta_array: Any | None = None, # not used
attributes: dict[str, JSON] | None = None,
Expand Down Expand Up @@ -847,8 +782,6 @@ async def open_group(
The new group.
"""

zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)

if cache_attrs is not None:
warnings.warn("cache_attrs is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
if synchronizer is not None:
Expand Down Expand Up @@ -902,7 +835,6 @@ async def create(
object_codec: Codec | None = None, # TODO: type has changed
dimension_separator: Literal[".", "/"] | None = None,
write_empty_chunks: bool | None = None,
zarr_version: ZarrFormat | None = None, # deprecated
zarr_format: ZarrFormat | None = None,
meta_array: Any | None = None, # TODO: need type
attributes: dict[str, JSON] | None = None,
Expand Down Expand Up @@ -1044,10 +976,7 @@ async def create(
z : array
The array.
"""
zarr_format = (
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
or _default_zarr_format()
)
zarr_format = zarr_format or _default_zarr_format()

if synchronizer is not None:
warnings.warn("synchronizer is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
Expand Down Expand Up @@ -1251,7 +1180,6 @@ async def ones_like(
async def open_array(
*, # note: this is a change from v2
store: StoreLike | None = None,
zarr_version: ZarrFormat | None = None, # deprecated
zarr_format: ZarrFormat | None = None,
path: PathLike = "",
storage_options: dict[str, Any] | None = None,
Expand All @@ -1265,8 +1193,6 @@ async def open_array(
StoreLike object to open. See the
[storage documentation in the user guide][user-guide-store-like]
for a description of all valid StoreLike values.
zarr_version : {2, 3, None}, optional
The zarr format to use when saving. Deprecated in favor of zarr_format.
zarr_format : {2, 3, None}, optional
The zarr format to use when saving.
path : str, optional
Expand All @@ -1286,8 +1212,6 @@ async def open_array(
mode = kwargs.pop("mode", None)
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)

zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)

if "write_empty_chunks" in kwargs:
_warn_write_empty_chunks_kwarg()

Expand Down
Loading