Registry / data / rechunker

rechunker

JSON →
library0.5.4pypypi✓ verified 87d ago

Rechunker is a Python package designed for efficient and scalable manipulation of the chunk structure of chunked array formats, such as Zarr and TileDB. It takes an input array (or group of arrays) from persistent storage and writes out a new array with the same data but a different chunking scheme, often utilizing an intermediate temporary store. It is currently at version 0.5.4 and is actively maintained by the Pangeo community, with regular releases addressing compatibility and bug fixes.

pip install rechunker
INSTALL
IMPORT
SIG · RECHUNKER
R
rechunker
datapythonv0.5.4
Install
10.9s avg
Import
1430ms
Disk
225MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 10.9s · import 1.430s · 205MB
225MB installed
● package 225MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rechunk
from rechunker import rechunk

This quickstart demonstrates how to rechunk a Zarr array from an initial chunking scheme to a new one. It defines source, intermediate, and target Zarr stores, specifies the target chunk size and maximum memory per worker, creates a rechunking plan, and then executes it.

import zarr from rechunker import rechunk import os # Create a source Zarr array source_store = 'source.zarr' if not os.path.exists(source_store): zarr.ones((10, 10, 10), chunks=(2, 2, 2), store=source_store, overwrite=True) source = zarr.open(source_store, mode='r') # Define target and intermediate stores intermediate_store = 'intermediate.zarr' target_store = 'target.zarr' # Define the target chunking scheme (e.g., contiguous in the first dimension) target_chunks = (10, 5, 5) # Define maximum memory for each worker (e.g., 256MB) max_mem = '256MB' # Create the rechunking plan rechunked_plan = rechunk( source, target_chunks, max_mem, target_store, intermediate_store ) # Execute the plan result = rechunked_plan.execute() print(f"Source array chunks: {source.chunks}") print(f"Target array chunks: {result.chunks}") # Clean up example files import shutil shutil.rmtree(source_store) shutil.rmtree(intermediate_store) shutil.rmtree(target_store)
Debug
Known issues
breakingBreaking changes for `xarray` and `dask` compatibility have occurred in some minor versions. For example, `v0.5.4` includes a fix for `xarray>=2025.03.1` and `v0.5.3` for `dask>=2024.12.0` and `xarray>=2024.10.0`.
fix
Always use the latest version of `rechunker` to ensure compatibility with recent `xarray` and `dask` versions, or refer to release notes for specific version requirements.
affects: <0.5.4
gotchaThe `rechunk` function in Dask can run out of memory for 'full rechunk' operations where every source chunk maps to every target chunk. Rechunker specifically addresses this by leveraging persistent intermediate storage, but users often confuse this with Dask's in-memory `rechunk`.
fix
Understand that `rechunker` is designed for disk-to-disk rechunking and explicitly manages intermediate storage to avoid out-of-memory errors on large datasets that Dask's in-memory `rechunk` might encounter. Allocate sufficient `max_mem` and `temp_store`.
affects: All
gotchaRechunker currently assumes uniform chunks for input arrays (except for the last chunk). This can cause issues with Dask arrays that have been filtered or concatenated Zarr arrays, which may result in non-uniform chunk sizes.
fix
Ensure input arrays have uniform chunk sizes before passing them to `rechunker`. If using Dask arrays with non-uniform chunks, consider explicitly rechunking them to a uniform size using `dask.array.rechunk` beforehand, or manually ensure uniformity.
affects: All
Errors
Common errors & fixes
cannot open result of rechunker with xarray
Compatibility issues between `rechunker` and specific `xarray` or `zarr` versions, or incorrect metadata handling during the rechunking process.
fix
Update `rechunker`, `xarray`, and `zarr` to their latest compatible versions. Verify if `consolidated=True` is used when writing to Zarr if applicable, and ensure all attributes are properly copied (addressed in `v0.5.1`).
rechunker object has no attribute 'persist'
Misunderstanding the `Rechunked` object's API. The `Rechunked` object returned by `rechunk()` is a plan that needs to be explicitly executed, not a Dask array that can be `persisted`.
fix
After creating the `rechunked` plan, call its `.execute()` method to perform the rechunking operation: `rechunked_plan = rechunk(...); result_array = rechunked_plan.execute()`.
ZeroDivisionError in L70 of api.py
This error likely indicates an issue with internal calculations related to chunk sizes or memory allocation, potentially occurring when `rechunker` tries to determine the optimal number of chunks or operations.
fix
Review `target_chunks` and `max_mem` parameters to ensure they are valid and sensible for the input array's dimensions and data type. Check GitHub issues for similar reported problems and potential workarounds, especially for edge cases with very small or very large dimensions.
Upgrade
Version history
0.5.4latest on PyPI · released May 1, 2025
Audit
Dependencies
daskrequiredRechunker is designed to be used within a parallel execution framework such as Dask.
zarrrequiredCommon storage format for chunked arrays that Rechunker manipulates.
xarrayoptionalOften used for creating and manipulating labeled multi-dimensional arrays, which can then be rechunked by Rechunker. Not a direct dependency but common in workflows.
Agent activity
16 hits · last 30 days
node
12
OpenAI (training)
1
Resources
rechunker — pip install rechunker · libregistry