| 
 | 1 | +3.0 Migration Guide  | 
 | 2 | +===================  | 
 | 3 | + | 
 | 4 | +Zarr-Python 3.0 introduces a number of changes to the API, including a number  | 
 | 5 | +of significant breaking changes and pending deprecations.  | 
 | 6 | + | 
 | 7 | +This page provides a guide highlighting the most notable changes to help you  | 
 | 8 | +migrate your code from version 2 to version 3.  | 
 | 9 | + | 
 | 10 | +Zarr-Python 3 represents a major refactor of the Zarr-Python codebase. Some of the  | 
 | 11 | +goals motivating this refactor included:  | 
 | 12 | + | 
 | 13 | +* adding support for the Zarr V3 specification (alongside the Zarr V2 specification)  | 
 | 14 | +* cleaning up internal and user facing APIs  | 
 | 15 | +* improving performance (particularly in high latency storage environments like  | 
 | 16 | +  cloud object store)  | 
 | 17 | + | 
 | 18 | +Compatibility target  | 
 | 19 | +--------------------  | 
 | 20 | + | 
 | 21 | +The goals described above necessitated some breaking changes to the API (hence the  | 
 | 22 | +major version update), but we have attempted to maintain ~95% backwards compatibility  | 
 | 23 | +in the most widely used parts of the API. This in the :class:`zarr.Array` and  | 
 | 24 | +:class:`zarr.Group` classes and the "top-level API" (e.g. :func:`zarr.open_array` and  | 
 | 25 | +:func:`zarr.open_group`).  | 
 | 26 | + | 
 | 27 | +Getting ready for 3.0  | 
 | 28 | +---------------------  | 
 | 29 | + | 
 | 30 | +Ahead of the 3.0 release, we suggest projects that depend on Zarr-Python take the  | 
 | 31 | +following actions:  | 
 | 32 | + | 
 | 33 | +1. Pin the supported Zarr-Python version to ``zarr>=2,<3``. This is a best practice  | 
 | 34 | +   and will protect your users from any incompatibilities that may arise during the  | 
 | 35 | +   release of Zarr-Python 3.0.  | 
 | 36 | +2. Limit your imports from the Zarr-Python package. Most of the primary API ``zarr.*``  | 
 | 37 | +   will be compatible in 3.0. However, the following breaking API changes are planned:  | 
 | 38 | + | 
 | 39 | +   - ``numcodecs.*`` will no longer be available in ``zarr.*``. To migrate, import codecs  | 
 | 40 | +     directly from ``numcodecs``:  | 
 | 41 | + | 
 | 42 | +     .. code-block:: python  | 
 | 43 | +
  | 
 | 44 | +        from numcodecs import Blosc  | 
 | 45 | +        # instead of:  | 
 | 46 | +        # from zarr import Blosc  | 
 | 47 | +
  | 
 | 48 | +   - The ``zarr.v3_api_available`` feature flag is being removed. In Zarr-Python 3.0  | 
 | 49 | +     the v3 API is always available, so you shouldn't need to use this flag.  | 
 | 50 | +   - The following internal modules are being removed or significantly changed. If  | 
 | 51 | +     your application relies on imports from any of the below modules, you will need  | 
 | 52 | +     to either a) modify your application to no longer rely on these imports or b)  | 
 | 53 | +     vendor the parts of the specific modules that you need.  | 
 | 54 | + | 
 | 55 | +     * ``zarr.attrs``  | 
 | 56 | +     * ``zarr.codecs``  | 
 | 57 | +     * ``zarr.context``  | 
 | 58 | +     * ``zarr.core``  | 
 | 59 | +     * ``zarr.hierarchy``  | 
 | 60 | +     * ``zarr.indexing``  | 
 | 61 | +     * ``zarr.meta``  | 
 | 62 | +     * ``zarr.meta_v1``  | 
 | 63 | +     * ``zarr.storage``  | 
 | 64 | +     * ``zarr.sync``  | 
 | 65 | +     * ``zarr.types``  | 
 | 66 | +     * ``zarr.util``  | 
 | 67 | +     * ``zarr.n5``  | 
 | 68 | + | 
 | 69 | +3. Test that your package works with v3. You can start testing against version 3 now  | 
 | 70 | +   (pre-releases are being published to PyPI weekly).  | 
 | 71 | +4. Update the pin to zarr >=3  | 
 | 72 | + | 
 | 73 | +Continue using Zarr-Python 2  | 
 | 74 | +----------------------------  | 
 | 75 | + | 
 | 76 | +Zarr-Python 2.x is still available, though we recommend migrating to Zarr-Python 3 for  | 
 | 77 | +its improvements and new features. Security and bug fixes will be made to the 2.x series  | 
 | 78 | +for at least 6 months following the first Zarr-Python 3 release.  | 
 | 79 | +If you need to use the latest Zarr-Python 2 release, you can install it with:  | 
 | 80 | + | 
 | 81 | +.. code-block:: console  | 
 | 82 | +
  | 
 | 83 | +    $ pip install "zarr==2.*"  | 
 | 84 | +
  | 
 | 85 | +Migration Guide  | 
 | 86 | +---------------  | 
 | 87 | + | 
 | 88 | +The following sections provide details on the most important changes in Zarr-Python 3.  | 
 | 89 | + | 
 | 90 | +The Array class  | 
 | 91 | +~~~~~~~~~~~~~~~  | 
 | 92 | + | 
 | 93 | +1. Disallow direct construction - use :func:`zarr.open_array` or :func:`zarr.create_array`  | 
 | 94 | +   instead of directly constructing the :class:`zarr.Array` class.  | 
 | 95 | + | 
 | 96 | +The Group class  | 
 | 97 | +~~~~~~~~~~~~~~~  | 
 | 98 | + | 
 | 99 | +1. Disallow direct construction - use :func:`zarr.open_group` or :func:`zarr.create_group`  | 
 | 100 | +   instead of directly constructing the :class:`zarr.Group` class.  | 
 | 101 | +2. Deprecated most of the h5py compatibility methods. The following migration is suggested:  | 
 | 102 | + | 
 | 103 | +   - Use :func:`zarr.Group.create_array` in place of :func:`zarr.Group.create_dataset`  | 
 | 104 | +   - Use :func:`zarr.Group.require_array` in place of :func:`zarr.Group.require_dataset`  | 
 | 105 | + | 
 | 106 | +The Store class  | 
 | 107 | +~~~~~~~~~~~~~~~  | 
 | 108 | + | 
 | 109 | +Some of the biggest changes in Zarr-Python 3 are found in the ``Store`` class. The most notable changes to the Store API are:  | 
 | 110 | + | 
 | 111 | +1. Replaced the ``MutableMapping`` base class in favor of a custom abstract base class (:class:`zarr.abc.store.Store`).  | 
 | 112 | +2. Switched to a primarily Async interface.  | 
 | 113 | + | 
 | 114 | +Beyond the changes store interface, a number of deprecated stores were also removed in Zarr-Python 3:  | 
 | 115 | + | 
 | 116 | +- ``N5Store``  | 
 | 117 | +- ``DBMStore``  | 
 | 118 | +- ``LMDBStore``  | 
 | 119 | +- ``SQLiteStore``  | 
 | 120 | +- ``MongoDBStore``  | 
 | 121 | +- ``RedisStore``  | 
 | 122 | +- ``ABSStore``  | 
 | 123 | + | 
 | 124 | +Dependencies Changes  | 
 | 125 | +~~~~~~~~~~~~~~~~~~~~  | 
 | 126 | + | 
 | 127 | +- The new ``remote`` dependency group can be used to install a supported version of  | 
 | 128 | +  ``fsspec``, required for remote data access.  | 
 | 129 | +- The new ``gpu`` dependency group can be used to install a supported version of  | 
 | 130 | +  ``cuda``, required for GPU functionality.  | 
 | 131 | +- The ``jupyter`` optional dependency group has been removed, since v3 contains no  | 
 | 132 | +  jupyter specific functionality.  | 
 | 133 | + | 
 | 134 | +Miscellaneous  | 
 | 135 | +~~~~~~~~~~~~~  | 
 | 136 | + | 
 | 137 | +- The keyword argument ``zarr_version`` has been deprecated in favor of ``zarr_format``.  | 
 | 138 | + | 
 | 139 | +🚧 Work in Progress 🚧  | 
 | 140 | +~~~~~~~~~~~~~~~~~~~~~~  | 
 | 141 | + | 
 | 142 | +Zarr-Python 3 is still under active development, and is not yet fully complete.  | 
 | 143 | +The following list summarizes areas of the codebase that we expect to build out  | 
 | 144 | +after the 3.0 release:  | 
 | 145 | + | 
 | 146 | +- The following functions / methods have not been ported to Zarr-Python 3 yet:  | 
 | 147 | + | 
 | 148 | +  * :func:`zarr.copy`  | 
 | 149 | +  * :func:`zarr.copy_all`  | 
 | 150 | +  * :func:`zarr.copy_store`  | 
 | 151 | +  * :func:`zarr.Group.move`  | 
 | 152 | + | 
 | 153 | +- The following options in the top-level API have not been ported to Zarr-Python 3 yet.  | 
 | 154 | +  If these options are important to you, please open a  | 
 | 155 | +  `GitHub issue <https://github.com/zarr-developers/zarr-python/issues/new>` describing  | 
 | 156 | +  your use case.  | 
 | 157 | + | 
 | 158 | +  * ``cache_attrs``  | 
 | 159 | +  * ``cache_metadata``  | 
 | 160 | +  * ``chunk_store``  | 
 | 161 | +  * ``meta_array``  | 
 | 162 | +  * ``object_codec``  | 
 | 163 | +  * ``synchronizer``  | 
 | 164 | +  * ``dimension_separator``  | 
 | 165 | + | 
 | 166 | +- The following features have not been ported to Zarr-Python 3 yet:  | 
 | 167 | + | 
 | 168 | +  * Structured arrays / dtypes  | 
 | 169 | +  * Fixed-length strings  | 
 | 170 | +  * Object arrays  | 
 | 171 | +  * Ragged arrays  | 
 | 172 | +  * Datetimes and timedeltas  | 
 | 173 | +  * Groups and Arrays do not implement ``__enter__`` and ``__exit__`` protocols  | 
 | 174 | + | 
0 commit comments