Sibi Toolkit: A collection of tools for Data Analysis/Engineering.
Project description
SibiFlux
SibiFlux is a production-grade resilient data engineering ecosystem designed to bridge the gap between local development, distributed computing, and agentic AI workflows. It provides a unified engine for hybrid data loading (batch + streaming), self-healing distributed operations, and native interfaces for AI agents via the Model Context Protocol (MCP).
graph TD
subgraph "Agentic Interface (MCP)"
Agent["AI Agent / Claude"] <--> Router["MCP Router"]
Router <--> Resources["SibiFlux Resources"]
end
subgraph "Solutions Layer (Business Logic)"
Logistics["Logistics Solutions"]
Enrichment["Enrichment Pipelines"]
Cubes["DataCubes"]
end
subgraph "SibiFlux Core Engine"
DfHelper["DfHelper (Unified Loader)"]
Cluster["Resilient Dask Cluster"]
Managed["ManagedResource Lifecycle"]
end
Resources --> Cubes
Logistics --> DfHelper
Cubes --> DfHelper
DfHelper --> Cluster
Core Architecture
1. The Flux Engine (sibi_flux)
The foundational library providing resilient distributed primitives.
DfHelper: A unified API for loading data from SQLAlchemy, Parquet, or HTTP sources into Pandas or Dask DataFrames.Dataset: A high-level abstraction for hybrid data loading, seamlessly merging historical (Parquet) and live (SQL) data sources.DfValidator: A robust schema enforcement tool that validates DataFrames against strict type maps and generates ClickHouse DDL.ArtifactOrchestrator: An async engine for managing concurrent artifact updates with retries, backoff, and worker isolation.ManagedResource: A rigorous lifecycle management system for async resources, ensuring clean shutdown, signal handling, and observability.Dask Cluster: A self-healing distributed runtime that detects worker failures, manages re-connection, and enforces "The Nuclear Option" for test isolation.
2. Agentic Interface (mcp)
Native support for the Model Context Protocol (MCP), allowing AI agents to directly interact with SibiFlux data structures.
- Expose DataCubes: Automatically turn any
DataCubeinto a queryable MCP Resource. - Tooling: Register Python functions as tools callable by agents.
Key Capabilities
Hybrid Data Loading
SibiFlux implements a "Hot/Cold" architecture for seamless data access:
- Historical Data: Read efficiently from partitioned Parquet archives (S3/Local).
- Live Data: Query operational SQL databases for real-time changes.
- Automatic Merge:
DfHelperandDatasetautomatically stitch these sources together, handling schema evolution and deduplication.
Resilient Distributed Compute
The SibiFlux Dask wrapper provides:
- Auto-Healing: Clients that automatically reconnect if the scheduler dies.
- Safe Persistence: Wrappers like
safe_persistthat retry operations on network jitter. - Smart Partitioning: Automated repartitioning to prevent "small file problem" in Parquet outputs.
Observability
Built-in integration with OpenTelemetry (OTel):
- structured logging with correlation IDs.
- distributed tracing across async boundaries.
Quick Start
Installation
# Base installation (Core Engine only)
pip install sibi-flux
# For Distributed Computing (Dask Cluster support)
pip install "sibi-flux[distributed]"
# For Geospatial capabilities (OSMnx, GeoPandas, etc.)
pip install "sibi-flux[geospatial]"
# For MCP Agentic Interface support
pip install "sibi-flux[mcp]"
# Complete installation (Simulates the "All-in-One" environment)
pip install "sibi-flux[complete]"
API Examples
1. Data Loading (Dataset)
The Dataset class provides a high-level abstraction for hybrid loading.
from sibi_flux import Dataset
from solutions.logistics.readers.products import ProductsParquetReader, ProductsSqlReader
class ProductsDataset(Dataset):
historical_reader = ProductsParquetReader
live_reader = ProductsSqlReader
date_field = "created_at"
# Load hybrid data (merges Parquet + SQL)
ds = ProductsDataset(start_date="2023-01-01", end_date="2023-01-31")
df = await ds.aload() # Returns a Dask DataFrame
2. Schema Validation (DfValidator)
Ensure your data meets strict type requirements and generate DDL for ClickHouse.
from sibi_flux import DfValidator
# Define expected schema
SCHEMA = {
"product_id": "Int64[pyarrow]",
"price": "Float64[pyarrow]",
"name": "string[pyarrow]"
}
validator = DfValidator(df)
validator.validate_schema(SCHEMA)
validator.standardize_data_quality()
# Generate ClickHouse DDL
ddl = validator.generate_clickhouse_ddl("products_table")
print(ddl)
3. Data Enrichment (AsyncDfEnricher)
Enrich a base DataFrame with data from other sources using AttachmentSpec.
from sibi_flux.df_enricher import AsyncDfEnricher, AttachmentSpec
specs = [
AttachmentSpec(
key="customer_info",
required_cols={"customer_id"},
attachment_fn=fetch_customer_data, # Async function returning DF
left_on=["customer_id"],
right_on=["id"],
drop_cols=["id"]
)
]
enricher = AsyncDfEnricher(base_df=orders_df, specs=specs)
enriched_df = await enricher.enrich()
4. Orchestration (ArtifactOrchestrator)
Manage concurrent updates of multiple artifacts with retries and worker isolation.
from sibi_flux.orchestration import ArtifactOrchestrator
orchestrator = ArtifactOrchestrator(
wrapped_classes={"daily": [ProductsDataset, OrdersDataset]},
max_workers=3,
retry_attempts=3
)
# Updates all 'daily' artifacts concurrently
results = await orchestrator.update_data("daily")
5. Distributed Compute (Dask Cluster)
Execute resilient operations that survive scheduler restarts.
from sibi_flux.dask_cluster import safe_compute, get_persistent_client
client = get_persistent_client()
# Safe compute with auto-retry logic
result = safe_compute(df.groupby("category").sum())
6. Resource Management (ManagedResource)
Create lifecycle-safe components.
from sibi_flux.core import ManagedResource
class MyResource(ManagedResource):
async def _acleanup(self):
await self.db_connection.close()
self.logger.info("Cleaned up!")
async with MyResource() as res:
await res.do_work()
# Automatically cleaned up here
7. Agentic Interface (sibi_flux.mcp)
Seamlessly bridge your data with AI Agents.
Server Side (Expose Resources)
from sibi_flux.mcp import BaseMCPRouter
from products import ProductsDataset
# Create an MCP Router compatible with FastAPI
router = BaseMCPRouter(name="data-server")
# Automatically register a Dataset as an MCP Resource
# Agent can now read `sibi://ProductsDataset`
router.register_cube_resource(ProductsDataset)
# Register a custom tool
@router.tool()
def calculate_vat(amount: float) -> float:
return amount * 0.2
Client Side (Consume Resources)
from sibi_flux.mcp import GenericMcpClient
# Connect to the MCP Server
async with GenericMcpClient(url="http://localhost:8000/sse") as client:
# Read the resource (returns JSON data from the Dataset)
data = await client.read_resource("sibi://ProductsDataset")
# Call a tool
vat = await client.call_tool("calculate_vat", arguments={"amount": 100.0})
8. Datacube Generation (gen_dc.py)
Automate the creation of Datacube classes and Field Maps from your database schema.
Configuration (discovery_params.yaml)
Define your generation rules in a hierarchical configuration file:
defaults:
backend: sqlalchemy
class_suffix: Dc
discovery:
whitelist_file: whitelist.yaml
rules_file: discovery_rules.yaml
generation:
enable_field_maps: true
Commands
-
Discover: Introspects the database and updates your whitelist/registry.
uv run poe dc-discover
- Whitelist: Explicitly define tables to generate. Support
custom_nameto override class names. - Rules: Regex-based patterns to match tables.
- Whitelist: Explicitly define tables to generate. Support
-
Sync: Generates Python code (Datacubes and Field Maps) based on the registry.
uv run poe dc-sync --force
Key Features
- Custom Naming: Add
custom_name: MyCubetowhitelist.yamlto override generated names. - Hierarchical Config: Strict validation of generation parameters.
- Field Maps: Auto-generates type-safe mapping files for every table.
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 Distribution
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 sibi_flux-2026.1.3.tar.gz.
File metadata
- Download URL: sibi_flux-2026.1.3.tar.gz
- Upload date:
- Size: 191.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cb27e49eb6c917ef3654a29fff4b2fbaa020a5885a98d3b24332d85ed586f33
|
|
| MD5 |
c1bc71e0a1df9570d7354a0f740af225
|
|
| BLAKE2b-256 |
e8af76903d9dc1c34dbbbcaa43f1b592c80902b0409f878c9accff7866f9533d
|
File details
Details for the file sibi_flux-2026.1.3-py3-none-any.whl.
File metadata
- Download URL: sibi_flux-2026.1.3-py3-none-any.whl
- Upload date:
- Size: 243.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7271b1210a4688cbb2bed7d8f9663bdf5147bc974ff6ab439f2fcbd6f69fdc6e
|
|
| MD5 |
2150557245c794f639817790a5ad1b07
|
|
| BLAKE2b-256 |
bee8052739e9c10ff4f4ab50af5e9a2d4aea26af5e893e58f7ed43d6cae9840c
|