A blazing fast, Rust-backed streaming data profiler.
Project description
Dalga (🌊)
A blazing-fast, O(1) memory streaming data profiler. Written in Rust, built for Python.
Dalga acts as an in-stream observability layer and circuit breaker. It sits natively inside your existing data pipelines (Kafka, FastAPI, Pandas, Polars) and calculates statistical sketches of your data in real-time. It intercepts silent data corruption before it reaches your data warehouse, all without adding latency to your workers.
Why Dalga?
- Zero Compute Cost: Stop querying multi-terabyte warehouse tables just to monitor null rates or cardinality. Dalga profiles the data before it lands.
- Lock-Free Concurrency: Built on a double-buffered
ArcSwapand atomic counters. Multiple threads can hammer the engine simultaneously with zero lock contention. - Bounded O(1) Memory: Utilizes 14-bit
HyperLogLogPlusalgorithms to estimate cardinality. Whether you process 100 rows or 10 billion, Dalga uses exactly ~16KB of memory per column. - Fail-Open & Safe: Designed for mission-critical pipelines. If the telemetry fails, or if it encounters malformed bytes, Dalga gracefully drops the bad data and keeps your pipeline running.
- Framework Agnostic: First-class adapters for Pandas, Polars, FastAPI, and
confluent-kafka.
Installation
Dalga is available on PyPI. You can install it using uv, pip, or your preferred package manager:
uv add dalga-core
# or
pip install dalga-core
(Note: The package name is dalga-core, but the import namespace is dalga)
Quickstart
Dalga processes data locally in an isolated Rust memory space. It automatically flushes metadata payloads in the background without blocking your host application.
1. The Core Engine (Batch Processing)
For standard lists of dictionaries or JSON payloads, use the universal .flow() method. The Rust engine natively processes batches for maximum throughput.
from dalga.core import DalgaClient
dalga = DalgaClient()
# Pass batches directly to bypass Python iteration overhead
batch_data = [
{"user_id": 1, "status": "active"},
{"user_id": 2, "status": "banned"}
]
dalga.flow(batch_data)
2. The Circuit Breaker (Data Quality Gates)
Dalga actively protects your database from silent corruption. Evaluate incoming batches against strict Expectation rules. If a batch violates the rules, Dalga rejects it before it pollutes your global state or warehouse.
from dalga.core import DalgaClient, Expectation
dalga = DalgaClient()
rules = [
Expectation("price").min_value(0.0), # No negative prices
Expectation("user_id").to_not_be_null(), # User ID is required
Expectation("category").max_null_ratio(0.50) # Category can be null up to 50%
]
batch = fetch_kafka_messages()
# Evaluates the batch in an isolated Rust memory space
if dalga.validate(batch, rules):
insert_to_snowflake(batch)
else:
send_to_dead_letter_queue(batch)
3. The Kafka Adapter
Drop Dalga directly into your consumer poll() loop to profile high-throughput streams natively.
from dalga.core import DalgaClient
from dalga.adapters.kafka import DalgaKafka
dalga = DalgaClient(max_records=10_000)
kafka_adapter = DalgaKafka(dalga)
while True:
messages = consumer.consume(num_messages=2000, timeout=1.0)
if not messages:
continue
# Parses raw bytes and profiles the entire micro-batch instantly in Rust
kafka_adapter.profile_batch(messages)
# ... your normal DB insertion logic ...
4. DataFrames (Pandas & Polars)
Monitor batch transformations instantly. Importing the adapters automatically registers the .dalga namespace to your DataFrames.
import pandas as pd
import polars as pl
from dalga.core import DalgaClient
import dalga.adapters.pandas
import dalga.adapters.polars
dalga = DalgaClient()
# Pandas
df_pd = pd.read_csv("daily_users.csv")
df_pd.dalga.profile(dalga)
# Polars
df_pl = pl.read_parquet("daily_users.parquet")
df_pl.dalga.profile(dalga)
5. The FastAPI Middleware
Monitor the shape of incoming JSON payloads asynchronously without starving your endpoint streams.
from fastapi import FastAPI
from dalga.core import DalgaClient
from dalga.adapters.fastapi import DalgaMiddleware
dalga = DalgaClient()
app = FastAPI()
# Profile specific endpoints (or all traffic) safely
app.add_middleware(DalgaMiddleware, client=dalga, endpoints_to_monitor=["/ingest"])
@app.post("/ingest")
async def ingest_data(payload: dict):
return {"status": "success"}
Architecture (Under the Hood)
Dalga leverages PyO3 to bridge Python directly to a highly optimized Rust engine.
- Zero-Copy Extraction: Python dictionaries are evaluated at the FFI boundary, extracting types (Int, Float, Str, Null) without expensive string parsing allocations.
- Lock-Free Aggregation: The Rust core calculates Min, Max, and Nulls using atomic counters. Thread contention is virtually eliminated, even on extremely hot columns.
- Double-Buffered Flushes: Background flushes utilize
ArcSwapto atomically swap the activeDashMapin O(1) time. Ingestion threads never block waiting for serialization. - Absolute Memory Bounds: Unique values are hashed into a
HyperLogLogPlussketch, ensuring memory utilization remains flat regardless of dataset size.
Local Development
Dalga uses nix, uv, and maturin for reproducible builds.
# Enter the reproducible dev environment
nix develop
# Sync dependencies and compile the Rust extension
uv sync
uv run maturin develop --release
# Run the test suite
uv run pytest tests/ -v
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dalga_core-0.1.0.tar.gz.
File metadata
- Download URL: dalga_core-0.1.0.tar.gz
- Upload date:
- Size: 50.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
824c69082ace94c85a2f74a6c52a8b15072b0988f13c0a1082669af824b69eef
|
|
| MD5 |
c859c9de67e9163468ac7059ea34527c
|
|
| BLAKE2b-256 |
ef953bb7e93af982b10bd3706924c6625b86811f198b22c63d66b28224106a68
|
Provenance
The following attestation bundles were made for dalga_core-0.1.0.tar.gz:
Publisher:
cd.yml on dalga-org/dalga
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dalga_core-0.1.0.tar.gz -
Subject digest:
824c69082ace94c85a2f74a6c52a8b15072b0988f13c0a1082669af824b69eef - Sigstore transparency entry: 1573415542
- Sigstore integration time:
-
Permalink:
dalga-org/dalga@b4f295d7bba3150084ac999ce5648439ba2f6d35 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dalga-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@b4f295d7bba3150084ac999ce5648439ba2f6d35 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dalga_core-0.1.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: dalga_core-0.1.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 213.9 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0aaba67834c72c2885edc88bb5424366ec7c0fb3261883fa537b3445ffa84d85
|
|
| MD5 |
1bc958cb528551e6b5043aa2498e6b66
|
|
| BLAKE2b-256 |
4bd4e3a6b00c63477df8d9fa3121c5f3bc344e2cb70726b862893905ef0247ac
|
Provenance
The following attestation bundles were made for dalga_core-0.1.0-cp38-abi3-win_amd64.whl:
Publisher:
cd.yml on dalga-org/dalga
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dalga_core-0.1.0-cp38-abi3-win_amd64.whl -
Subject digest:
0aaba67834c72c2885edc88bb5424366ec7c0fb3261883fa537b3445ffa84d85 - Sigstore transparency entry: 1573415550
- Sigstore integration time:
-
Permalink:
dalga-org/dalga@b4f295d7bba3150084ac999ce5648439ba2f6d35 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dalga-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@b4f295d7bba3150084ac999ce5648439ba2f6d35 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dalga_core-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: dalga_core-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 369.1 kB
- Tags: CPython 3.8+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7979eefa762549ab55b31cf05052477b6030cf3500c1037b8bb5080f25029556
|
|
| MD5 |
6b319ea99d3a3a974712e18a378b7184
|
|
| BLAKE2b-256 |
372b9125457543a46b77af69c1d89211f2a5bf96c4405360d1c94c04028ebdcf
|
Provenance
The following attestation bundles were made for dalga_core-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl:
Publisher:
cd.yml on dalga-org/dalga
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dalga_core-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
7979eefa762549ab55b31cf05052477b6030cf3500c1037b8bb5080f25029556 - Sigstore transparency entry: 1573415558
- Sigstore integration time:
-
Permalink:
dalga-org/dalga@b4f295d7bba3150084ac999ce5648439ba2f6d35 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dalga-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@b4f295d7bba3150084ac999ce5648439ba2f6d35 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dalga_core-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: dalga_core-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 627.1 kB
- Tags: CPython 3.8+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33fbc78d64e80671f7d056d70cd0793f26c8fd16e367f95bd203e84f32b67caf
|
|
| MD5 |
3feb119e54b9a88e56a7fa325d48cb9e
|
|
| BLAKE2b-256 |
efd2c961eb2a0874d150cce3e25958d2292bc2ed963d71eeb733d0a6575e34b8
|
Provenance
The following attestation bundles were made for dalga_core-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
cd.yml on dalga-org/dalga
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dalga_core-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
33fbc78d64e80671f7d056d70cd0793f26c8fd16e367f95bd203e84f32b67caf - Sigstore transparency entry: 1573415580
- Sigstore integration time:
-
Permalink:
dalga-org/dalga@b4f295d7bba3150084ac999ce5648439ba2f6d35 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dalga-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@b4f295d7bba3150084ac999ce5648439ba2f6d35 -
Trigger Event:
push
-
Statement type: