|
| 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 | + |
1 | 62 | from __future__ import annotations |
2 | 63 |
|
3 | 64 | from typing import Any, Literal, cast |
|
0 commit comments