Skip to content

Commit 71ff5e7

Browse files
committed
docs for config
1 parent ebbb67a commit 71ff5e7

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

docs/user-guide/extending.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ useful for providing specialized implementations, such as GPU-based codecs. In c
6868
multiple codecs, the :mod:`zarr.core.config` mechanism can be used to select the preferred
6969
implementation.
7070

71-
TODO: Link to documentation of :mod:`zarr.core.config`
72-
7371
.. note::
7472
This sections explains how custom codecs can be created for Zarr version 3. For Zarr
7573
version 2, codecs should subclass the

docs/user-guide/v3_migration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Configuration
138138
~~~~~~~~~~~~~
139139

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

144144
.. code-block:: python

src/zarr/core/config.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,64 @@
1+
"""
2+
The config module is responsible for managing the configuration of zarr
3+
and is based on the `donfig <https://github.com/pytroll/donfig>`_ Python library.
4+
5+
Configuration values can be set using code like the following:
6+
7+
.. code-block:: python
8+
9+
import zarr
10+
zarr.config.set({"array.order": "F"})
11+
12+
Alternatively, configuration values can be set using environment variables, e.g.
13+
``ZARR_ARRAY__ORDER=F``.
14+
15+
The configuration can also be read from a YAML file in standard locations.
16+
For more information, see the
17+
`donfig documentation <https://donfig.readthedocs.io/en/latest/>`_.
18+
19+
Configuration options include the following:
20+
21+
- Default Zarr format ``default_zarr_version``
22+
- Default array order in memory ``array.order``
23+
- Async and threading options, e.g. ``async.concurrency`` and ``threading.max_workers``
24+
- Selections of implementations of codecs, codec pipelines and buffers
25+
26+
For selecting custom implementations of codecs, pipelines, buffers and ndbuffers,
27+
first register the implementations in the registry and then select them in the config.
28+
For example, an implementation of the bytes codec in a class "custompackage.NewBytesCodec",
29+
requires the value of ``codecs.bytes.name`` to be "custompackage.NewBytesCodec".
30+
31+
This is the current default configuration:
32+
33+
.. code-block:: python
34+
35+
{
36+
"default_zarr_version": 3,
37+
"array": {"order": "C"},
38+
"async": {"concurrency": 10, "timeout": None},
39+
"threading": {"max_workers": None},
40+
"json_indent": 2,
41+
"codec_pipeline": {
42+
"path": "zarr.core.codec_pipeline.BatchedCodecPipeline",
43+
"batch_size": 1,
44+
},
45+
"codecs": {
46+
"blosc": "zarr.codecs.blosc.BloscCodec",
47+
"gzip": "zarr.codecs.gzip.GzipCodec",
48+
"zstd": "zarr.codecs.zstd.ZstdCodec",
49+
"bytes": "zarr.codecs.bytes.BytesCodec",
50+
"endian": "zarr.codecs.bytes.BytesCodec",
51+
"crc32c": "zarr.codecs.crc32c_.Crc32cCodec",
52+
"sharding_indexed": "zarr.codecs.sharding.ShardingCodec",
53+
"transpose": "zarr.codecs.transpose.TransposeCodec",
54+
"vlen-utf8": "zarr.codecs.vlen_utf8.VLenUTF8Codec",
55+
"vlen-bytes": "zarr.codecs.vlen_utf8.VLenBytesCodec",
56+
},
57+
"buffer": "zarr.core.buffer.cpu.Buffer",
58+
"ndbuffer": "zarr.core.buffer.cpu.NDBuffer",
59+
}
60+
"""
61+
162
from __future__ import annotations
263

364
from typing import Any, Literal, cast

0 commit comments

Comments
 (0)