Skip to main content

Rainbear

Python + Rust experiment for lazy Zarr scanning into Polars, with an API inspired by xarray’s coordinate-based selection.

This repo currently contains:

  • A first-pass scan_zarr(...) that streams a Zarr store using Rust zarrs and yields Polars LazyFrames.
  • A test suite that compares rainbear against xarray for various Zarr datasets and filter conditions.

Status / caveats

  • Zarr v3: the Rust backend uses zarrs. Note that zarrs-v2 is not likely to work for this reason.
  • Tidy table output: scan_zarr currently emits a “tidy” DataFrame with one row per element and columns:
    • dimension/coord columns (e.g. time, lat)
    • variable columns (e.g. temp)
  • Predicate pushdown:
    • Rust attempts to compile a limited subset of predicates (simple comparisons on coord columns combined with &) for chunk pruning.
    • If Polars Expr deserialization fails (typically because Python Polars and the Rust-side Polars ABI/serde don’t match), scan_zarr automatically falls back to Python-side filtering (correct but slower).

Quickstart (uv)

The project is configured as a maturin extension module.

  • Run a quick import check:
uv run --with polars python -c "import rainbear; print(rainbear.print_extension_info())"

Using scan_zarr

import polars as pl
import rainbear

lf = rainbear.scan_zarr("/path/to/data.zarr")

# Filter the LazyFrame (predicate's are pushed down and used for chunk pruning)
lf = lf.filter((pl.col("lat") >= 32.0) & (pl.col("lat") <= 52.0))

df = lf.collect()
print(df)

Caching Backends

Rainbear provides three backend classes that own the store connection and cache metadata and coordinate chunks across multiple scans. This dramatically improves performance for repeated queries on the same dataset.

ZarrBackend (Async)

The async caching backend for standard Zarr stores. Best for cloud storage (S3, GCS, Azure) where async I/O provides significant performance benefits.

Features:

  • Persistent caching of coordinate array chunks and metadata across scans
  • Async I/O with configurable concurrency for parallel chunk reads
  • Compatible with any ObjectStore (S3, GCS, Azure, HTTP, local filesystem)
  • Cache statistics and management (clear cache, view stats)

When to use:

  • Cloud-based Zarr stores where network latency dominates
  • Applications already using async/await patterns
  • High-concurrency workloads with many simultaneous chunk reads
import polars as pl
from datetime import datetime
import rainbear

# Create backend from URL
backend = rainbear.ZarrBackend.from_url("s3://bucket/dataset.zarr")

# First scan - reads and caches coordinates
df1 = await backend.scan_zarr_async(pl.col("time") > datetime(2024, 1, 1))

# Second scan - reuses cached coordinates (much faster!)
df2 = await backend.scan_zarr_async(pl.col("time") > datetime(2024, 6, 1))

# Check what's cached
stats = await backend.cache_stats()
print(f"Cached {stats['coord_entries']} coordinate chunks")

# Clear cache if needed
await backend.clear_coord_cache()

ZarrBackendSync (Sync)

The synchronous caching backend for standard Zarr stores. Best for local filesystem access or simpler synchronous codebases.

Features:

  • Same persistent caching as ZarrBackend (coordinates and metadata)
  • Synchronous API - no async/await required
  • Blocking I/O suitable for local or low-latency stores
  • Additional options: column selection, row limits, batch size control

When to use:

  • Local filesystem Zarr stores
  • Synchronous applications or scripts
  • Interactive data exploration (notebooks, REPL)
  • When you don't need async concurrency
import polars as pl
from datetime import datetime
import rainbear

# Create backend from URL
backend = rainbear.ZarrBackendSync.from_url("/path/to/local/dataset.zarr")

# Scan with column selection and row limit
df1 = backend.scan_zarr_sync(
    predicate=pl.col("time") > datetime(2024, 1, 1),
    with_columns=["temp", "pressure"],
    n_rows=1000
)

# Second scan reuses cached coordinates
df2 = backend.scan_zarr_sync(pl.col("time") > datetime(2024, 6, 1))

# No await needed for cache operations in sync backend
stats = backend.cache_stats()
backend.clear_coord_cache()

IcechunkBackend (Async, Version Control)

The async-only caching backend for Icechunk-backed Zarr stores. Icechunk adds Git-like version control to Zarr datasets, enabling branches, commits, and time-travel queries.

Features:

  • Same persistent caching as ZarrBackend (coordinates and metadata)
  • Access to versioned Zarr data with branch/snapshot support
  • Direct integration with icechunk-python Session objects
  • Async-only (Icechunk operations are inherently async)

When to use:

  • Working with version-controlled Zarr datasets
  • Need to query specific branches or historical snapshots
  • Collaborative workflows with multiple dataset versions
  • Reproducible analysis requiring exact dataset versions
import polars as pl
from datetime import datetime
import rainbear

# Create backend from Icechunk filesystem repository
backend = await rainbear.IcechunkBackend.from_filesystem(
    path="/path/to/icechunk/repo",
    branch="main"  # or specific branch name
)

# Scan like normal - caching works the same
df1 = await backend.scan_zarr_async(pl.col("time") > datetime(2024, 1, 1))
df2 = await backend.scan_zarr_async(pl.col("time") > datetime(2024, 6, 1))

# Or use existing Icechunk session directly
from icechunk import Repository, local_filesystem_storage

storage = local_filesystem_storage("/path/to/repo")
repo = Repository.open(storage)
session = repo.readonly_session("experimental-branch")

# No manual serialization needed!
backend = await rainbear.IcechunkBackend.from_session(session)
df = await backend.scan_zarr_async(pl.col("lat") < 45.0)

Backend Comparison

Feature ZarrBackend ZarrBackendSync IcechunkBackend
API Style Async Sync Async
Caching ✓ Coordinates & metadata ✓ Coordinates & metadata ✓ Coordinates & metadata
Best For Cloud storage (S3, GCS, Azure) Local filesystem Version-controlled datasets
Concurrency High (configurable) Single-threaded High (configurable)
Version Control ✗ ✗ ✓ (branches, snapshots)
Column Selection ✗ ✓ ✗
Row Limits ✗ ✓ ✗

Running the smoke tests

The Python tests create some local Zarr stores and then scan them.

From the workspace root:

cd rainbear-tests
uv run pytest

Development

To run the Rust tests:

cargo test

To run the Python tests:

uv run pytest

Profiling:

samply record -- uv run python -m pytest tests/test_benchmark_novel_queries.py -m 'benchmark' --no-header -rN

Roadmap

Near Term

  • Geospatial support via ewkb and polars-st
  • Interpolation support
  • Tests against cloud storage backends
  • Benchmarks
  • Documentation

Longer Term

  • Improved manner of application to take full advantage of Polars' lazy engine
  • Caching Support?
  • Writing to zarr?
  • Capability to work with datatrees
  • Allow output to arrow/pandas/etc.
  • Icechunk support
  • Zarr V2 support (backwards compatibility)

Code map

  • Rust extension module: rainbear/src/lib.rs exports _core
  • Zarr store opener (multi-backend URLs): rainbear/src/zarr_store.rs
  • Metadata loader (dims/coords/vars + schema): rainbear/src/zarr_meta.rs
  • Streaming IO source: rainbear/src/zarr_source.rs (exposed to Python as ZarrBackendSync)
  • Python API: rainbear/src/rainbear/__init__.py (scan_random, scan_zarr, ZarrBackendSync)
  • Tests: rainbear-tests/tests/ (separate workspace package)

Metadata

Release files for rainbear 3.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for rainbear 3.1.1
File Actions
rainbear-3.1.1-cp314-cp314t-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 Details for rainbear-3.1.1-cp314-cp314t-macosx_10_12_x86_64.whl
rainbear-3.1.1-cp312-abi3-win_arm64.whl CPython 3.12 abi3 Windows ARM64 Details for rainbear-3.1.1-cp312-abi3-win_arm64.whl
rainbear-3.1.1-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for rainbear-3.1.1-cp312-abi3-win_amd64.whl
rainbear-3.1.1-cp312-abi3-win32.whl CPython 3.12 abi3 Windows x86-32 Details for rainbear-3.1.1-cp312-abi3-win32.whl
rainbear-3.1.1-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details for rainbear-3.1.1-cp312-abi3-musllinux_1_2_x86_64.whl
rainbear-3.1.1-cp312-abi3-musllinux_1_2_i686.whl CPython 3.12 abi3 Linux musl 1.2+ x86-32 Details for rainbear-3.1.1-cp312-abi3-musllinux_1_2_i686.whl
rainbear-3.1.1-cp312-abi3-musllinux_1_2_aarch64.whl CPython 3.12 abi3 Linux musl 1.2+ ARM64 Details for rainbear-3.1.1-cp312-abi3-musllinux_1_2_aarch64.whl
rainbear-3.1.1-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details for rainbear-3.1.1-cp312-abi3-manylinux_2_28_x86_64.whl
rainbear-3.1.1-cp312-abi3-manylinux_2_28_i686.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-32 Details for rainbear-3.1.1-cp312-abi3-manylinux_2_28_i686.whl
rainbear-3.1.1-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details for rainbear-3.1.1-cp312-abi3-manylinux_2_28_aarch64.whl
rainbear-3.1.1-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for rainbear-3.1.1-cp312-abi3-macosx_11_0_arm64.whl
rainbear-3.1.1-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for rainbear-3.1.1-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 557.3 MB

Release files / rainbear-3.1.1-cp314-cp314t-macosx_10_12_x86_64.whl

Download URL rainbear-3.1.1-cp314-cp314t-macosx_10_12_x86_64.whl
Size 41.1 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
896bace2409ebb8b71ae176f3090971939cbf7d2dea7b7ed9927c7cf5e12dab6
BLAKE2b-256 checksum
How to use checksums
fa2faa71b113a58634b4191ad3b05b43e324a3418dbc7a9192a0991865e27431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-win_arm64.whl

Download URL rainbear-3.1.1-cp312-abi3-win_arm64.whl
Size 31.3 MB
Tags CPython 3.12 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
f1f6f6393c94b804924f8d3a6eca9ed13ea8a1aa9062379b1bf69439de2caf34
BLAKE2b-256 checksum
How to use checksums
7f479fd324e2352b5fecef5431b6fa0e26b42d97e36c982c6a0cec907bf61dce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-win_amd64.whl

Download URL rainbear-3.1.1-cp312-abi3-win_amd64.whl
Size 34.1 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0c78922e653a758d37d575bd8c717e6b641749c0b0ca56ba800006e9901accec
BLAKE2b-256 checksum
How to use checksums
c081180febdd21f4a928c17f2aa3c29e1af257d0e23e5977b33ef284ae03ad8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-win32.whl

Download URL rainbear-3.1.1-cp312-abi3-win32.whl
Size 28.6 MB
Tags CPython 3.12 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
c1e49326bb2b73c398bf55eb42423638f634f450e1f91a7c3271ec09afa352e4
BLAKE2b-256 checksum
How to use checksums
6293611af0d30824022c1e491fcb0891695008859a428d09bb062c6aa8b7598e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL rainbear-3.1.1-cp312-abi3-musllinux_1_2_x86_64.whl
Size 63.0 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
bfb342cab8e0d119813ab0e2c8c0f8a69dd38c20a7559d0c820334c27acad824
BLAKE2b-256 checksum
How to use checksums
dcac2c505e8f1be9fd145b771496a5e6ae3706c91d5731fbd48252d8cf68a2cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-musllinux_1_2_i686.whl

Download URL rainbear-3.1.1-cp312-abi3-musllinux_1_2_i686.whl
Size 62.1 MB
Tags CPython 3.12 Linux musl 1.2+ x86-32 abi3
SHA-256 checksum
How to use checksums
af73064076d21d647d225196d2c9b9182064bef2d1a5dd81ce77e8b08df5c802
BLAKE2b-256 checksum
How to use checksums
d195518187c46fa1d7dd30beb8517ebad10b9c303bd3c100e159856b91b50719
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL rainbear-3.1.1-cp312-abi3-musllinux_1_2_aarch64.whl
Size 60.9 MB
Tags CPython 3.12 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
cf7f8e7c9eba89455f596f95a351a55a460af3227957eab13e86747ce680da86
BLAKE2b-256 checksum
How to use checksums
c1309ea26536a9de34109e722cfb8f987b2a62232393ab93512d93905a19172e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL rainbear-3.1.1-cp312-abi3-manylinux_2_28_x86_64.whl
Size 43.2 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
09479664a9b5650466a9852c7e84351b98b87b96df73b41fa83344b8d747f52f
BLAKE2b-256 checksum
How to use checksums
d9b6e793d9abe28f7c609653fcf7f839b4d0cccdd069588f3da9975026c61f61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-manylinux_2_28_i686.whl

Download URL rainbear-3.1.1-cp312-abi3-manylinux_2_28_i686.whl
Size 57.8 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-32 abi3
SHA-256 checksum
How to use checksums
ba2202ab00225337773021778c25357c9ca76b91bafc67449ca3f3358da341f6
BLAKE2b-256 checksum
How to use checksums
e261159e0b0ed99096019c85d4aa53a57e7088fcef4e472f589fae1423a81293
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL rainbear-3.1.1-cp312-abi3-manylinux_2_28_aarch64.whl
Size 54.4 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
5141fc4f7b594d5131d121969dbb23ec54c94cd023ec57ad29232bbc9eafdb0e
BLAKE2b-256 checksum
How to use checksums
13eddd1a2af0fa7c7465dac260b110ab2d7f246ac87b5d132fdc3269128a12bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-macosx_11_0_arm64.whl

Download URL rainbear-3.1.1-cp312-abi3-macosx_11_0_arm64.whl
Size 39.7 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2bbe1a92a474f0f714901d7d8a0d3c8fed7d66c03f0403a71e58ae72447cc7b7
BLAKE2b-256 checksum
How to use checksums
cfc5f24902be1efc6dc05bf0a6b67df73c05b06b869cd0200dcef307a3759559
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rainbear-3.1.1-cp312-abi3-macosx_10_12_x86_64.whl

Download URL rainbear-3.1.1-cp312-abi3-macosx_10_12_x86_64.whl
Size 41.1 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a3d1a545bf334d16415b8694c85cb192d625e0c7c75fb3d56588186d3359e3b3
BLAKE2b-256 checksum
How to use checksums
ce01886cee54cdf244d93ea0d37cadc5437248aa1a3a245c11b639ee9f5908fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for rainbear 3.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page