Skip to content

Runtime configuration

zarr.config is responsible for managing the configuration of zarr and is based on the donfig Python library.

Configuration values can be set using code like the following:

import zarr

print(zarr.config.get('array.order'))
C
zarr.config.set({'array.order': 'F'})

print(zarr.config.get('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.

Configuration options include the following:

  • Default Zarr format default_zarr_version
  • 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
  • Selections of implementations of codecs, codec pipelines and buffers
  • Enabling GPU support with zarr.config.enable_gpu(). See GPU support for more.

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:

from pprint import pprint
import io
output = io.StringIO()
zarr.config.pprint(stream=output, width=60)
print(output.getvalue())
{'array': {'order': 'F', 'write_empty_chunks': False},
 'async': {'concurrency': 10, 'timeout': None},
 'buffer': 'zarr.buffer.cpu.Buffer',
 'codec_pipeline': {'batch_size': 1,
                    'path': 'zarr.core.codec_pipeline.BatchedCodecPipeline'},
 'codecs': {'blosc': 'zarr.codecs.blosc.BloscCodec',
            'bytes': 'zarr.codecs.bytes.BytesCodec',
            'crc32c': 'zarr.codecs.crc32c_.Crc32cCodec',
            'endian': 'zarr.codecs.bytes.BytesCodec',
            'gzip': 'zarr.codecs.gzip.GzipCodec',
            'numcodecs.adler32': 'zarr.codecs.numcodecs.Adler32',
            'numcodecs.astype': 'zarr.codecs.numcodecs.AsType',
            'numcodecs.bitround': 'zarr.codecs.numcodecs.BitRound',
            'numcodecs.blosc': 'zarr.codecs.numcodecs.Blosc',
            'numcodecs.bz2': 'zarr.codecs.numcodecs.BZ2',
            'numcodecs.crc32': 'zarr.codecs.numcodecs.CRC32',
            'numcodecs.crc32c': 'zarr.codecs.numcodecs.CRC32C',
            'numcodecs.delta': 'zarr.codecs.numcodecs.Delta',
            'numcodecs.fixedscaleoffset': 'zarr.codecs.numcodecs.FixedScaleOffset',
            'numcodecs.fletcher32': 'zarr.codecs.numcodecs.Fletcher32',
            'numcodecs.gzip': 'zarr.codecs.numcodecs.GZip',
            'numcodecs.jenkins_lookup3': 'zarr.codecs.numcodecs.JenkinsLookup3',
            'numcodecs.lz4': 'zarr.codecs.numcodecs.LZ4',
            'numcodecs.lzma': 'zarr.codecs.numcodecs.LZMA',
            'numcodecs.packbits': 'zarr.codecs.numcodecs.PackBits',
            'numcodecs.pcodec': 'zarr.codecs.numcodecs.PCodec',
            'numcodecs.quantize': 'zarr.codecs.numcodecs.Quantize',
            'numcodecs.shuffle': 'zarr.codecs.numcodecs.Shuffle',
            'numcodecs.zfpy': 'zarr.codecs.numcodecs.ZFPY',
            'numcodecs.zlib': 'zarr.codecs.numcodecs.Zlib',
            'numcodecs.zstd': 'zarr.codecs.numcodecs.Zstd',
            'sharding_indexed': 'zarr.codecs.sharding.ShardingCodec',
            'transpose': 'zarr.codecs.transpose.TransposeCodec',
            'vlen-bytes': 'zarr.codecs.vlen_utf8.VLenBytesCodec',
            'vlen-utf8': 'zarr.codecs.vlen_utf8.VLenUTF8Codec',
            'zstd': 'zarr.codecs.zstd.ZstdCodec'},
 'default_zarr_format': 3,
 'json_indent': 2,
 'ndbuffer': 'zarr.buffer.cpu.NDBuffer',
 'threading': {'max_workers': None}}