unravel.image_io.zarr_compress module#

Use io_zarr_compress (zc) from UNRAVEL to compress or decompress .zarr directories to/from .zarr.tar.gz archives.

Note

  • .zarr directories can have several subdirectories and files, which can be slow to transfer or index.

  • Compressing to .zarr.tar.gz reduces the size and speeds up transfer.

  • Decompressing restores the original .zarr directory structure.

  • Compression uses tar -I pigz if pigz is installed for fast, parallel gzip compression.

  • If pigz is not available, it falls back to standard gzip compression via tar -czf.

Usage for recursive compression:#

zarr_compress [-i ‘<asterisk>.zarr’] [-m compress] [-l 6] [-f] [-k] [-w 4] [-v]

Usage for recursive decompression:#

zarr_compress -m decompress [-i ‘<asterisk>.zarr.tar.gz’] [-w 4] [-v]

unravel.image_io.zarr_compress.parse_args()[source]#
unravel.image_io.zarr_compress.compress_or_decompress_zarr(zarr_path, mode='compress', compression_level=6, force=False, keep=False)[source]#

Compress or decompress a .zarr directory using gtar and pigz if available.

Parameters:
  • zarr_path (str or Path) – Path to the .zarr directory (for compression) or .zarr.tar.gz file (for decompression).

  • mode ({'compress', 'compress', 'decompress', 'd'}) – Whether to compress or decompress the input.

  • compression_level (int) – Compression level (1-9) for pigz. Default is 6.

  • force (bool) – If True, overwrite existing output files. Default is False.

  • keep (bool) – If True, keep the original .zarr directory or .tar.gz file after processing. Default is False.

unravel.image_io.zarr_compress.run_in_parallel(paths, func, max_workers=1, **kwargs)[source]#

Run a function over a list of paths using a ThreadPoolExecutor.

Parameters:
  • paths (list of Path) – List of input paths to process.

  • func (callable) – Function to apply to each path.

  • max_workers (int) – Number of threads to use. Default is 1.

  • kwargs (dict) – Additional keyword arguments passed to func.

unravel.image_io.zarr_compress.main()[source]#