Skip to content

Commit

Permalink
docs for config
Browse files Browse the repository at this point in the history
  • Loading branch information
normanrz committed Dec 19, 2024
1 parent ebbb67a commit 71ff5e7
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
2 changes: 0 additions & 2 deletions docs/user-guide/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ useful for providing specialized implementations, such as GPU-based codecs. In c
multiple codecs, the :mod:`zarr.core.config` mechanism can be used to select the preferred
implementation.

TODO: Link to documentation of :mod:`zarr.core.config`

.. note::
This sections explains how custom codecs can be created for Zarr version 3. For Zarr
version 2, codecs should subclass the
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/v3_migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Configuration
~~~~~~~~~~~~~

There is a new configuration system based on `donfig <https://github.com/pytroll/donfig>`_,
which can be accessed via :data:`zarr.config`.
which can be accessed via :mod:`zarr.core.config`.
Configuration values can be set using code like the following:

.. code-block:: python
Expand Down
61 changes: 61 additions & 0 deletions src/zarr/core/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
"""
The config module is responsible for managing the configuration of zarr
and is based on the `donfig <https://github.com/pytroll/donfig>`_ Python library.
Configuration values can be set using code like the following:
.. code-block:: python
import zarr
zarr.config.set({"array.order": "F"})
Alternatively, configuration values can be set using environment variables, e.g.
``ZARR_ARRAY__ORDER=F``.
The configuration can also be read from a YAML file in standard locations.
For more information, see the
`donfig documentation <https://donfig.readthedocs.io/en/latest/>`_.
Configuration options include the following:
- Default Zarr format ``default_zarr_version``
- Default array order in memory ``array.order``
- Async and threading options, e.g. ``async.concurrency`` and ``threading.max_workers``
- Selections of implementations of codecs, codec pipelines and buffers
For selecting custom implementations of codecs, pipelines, buffers and ndbuffers,
first register the implementations in the registry and then select them in the config.
For example, an implementation of the bytes codec in a class "custompackage.NewBytesCodec",
requires the value of ``codecs.bytes.name`` to be "custompackage.NewBytesCodec".
This is the current default configuration:
.. code-block:: python
{
"default_zarr_version": 3,
"array": {"order": "C"},
"async": {"concurrency": 10, "timeout": None},
"threading": {"max_workers": None},
"json_indent": 2,
"codec_pipeline": {
"path": "zarr.core.codec_pipeline.BatchedCodecPipeline",
"batch_size": 1,
},
"codecs": {
"blosc": "zarr.codecs.blosc.BloscCodec",
"gzip": "zarr.codecs.gzip.GzipCodec",
"zstd": "zarr.codecs.zstd.ZstdCodec",
"bytes": "zarr.codecs.bytes.BytesCodec",
"endian": "zarr.codecs.bytes.BytesCodec",
"crc32c": "zarr.codecs.crc32c_.Crc32cCodec",
"sharding_indexed": "zarr.codecs.sharding.ShardingCodec",
"transpose": "zarr.codecs.transpose.TransposeCodec",
"vlen-utf8": "zarr.codecs.vlen_utf8.VLenUTF8Codec",
"vlen-bytes": "zarr.codecs.vlen_utf8.VLenBytesCodec",
},
"buffer": "zarr.core.buffer.cpu.Buffer",
"ndbuffer": "zarr.core.buffer.cpu.NDBuffer",
}
"""

from __future__ import annotations

from typing import Any, Literal, cast
Expand Down

0 comments on commit 71ff5e7

Please sign in to comment.