Skip to main content

Nairobi OS: Heavy Iron Data Science Infrastructure with Lagos Vision (Hardware-Accelerated Zero-Copy Rendering)

Project description

English | 简体中文 | Español | Deutsch

Nairobi Python

Overview

Nairobi Python provides the high-level bridge to the Nairobi OS infrastructure. It enables data scientists to harness the power of Rust-based, hardware-accelerated analytics through a familiar, Pythonic interface. The package handles daemon management, IPC coordination, and memory-mapping, allowing users to focus on data analysis.

Key Features

  • SovereignFrame: A fluent, Pandas-like interface for managing remote data handles.
  • Lazy Ignition: Automatically starts and configures the refinery daemon upon first data access.
  • Jupyter Integration: First-class support for interactive visualizations using the Lagos Vision widget.
  • Zero-Copy Bridge: Directly consumes memfd handles from the Rust refinery with sub-millisecond overhead.

Installation

From PyPI

pip install nairobi-os

From Source

cd crates/nairobi-python
pip install -e .

Note: Building from source requires the Rust toolchain and maturin to be installed.

Usage

Quick Start

import nairobi_os

# Connect to the refinery (automatically handles D-Bus and daemon startup)
nairobi_os.connect()

# Ingest a CSV file
df = nairobi_os.read_csv("data.csv")

# Fluent API for statistics
mean_val = df.column_name.mean()
p99_val = df.column_name.p99()

# Run SQL queries directly on the engine
tall_players = df.query("SELECT * FROM dataset WHERE height > 80")

# Plot using Lagos Vision
tall_players.plot()

API Reference

nairobi_os.connect()

Initializes the environment, starts the D-Bus session if necessary, and ignites the refinery daemon.

nairobi_os.read_csv(path, delimiter=",", encoding="utf-8")

Ingests a CSV file using the refinery's zero-copy pipeline. Returns a SovereignFrame.

SovereignFrame Methods

  • df.column.mean(): Compute the arithmetic mean.
  • df.column.std_dev(): Compute the standard deviation.
  • df.column.p95(), df.column.p99(): Compute percentiles.
  • df.column.skewness(), df.column.kurtosis(): Compute statistical moments.
  • df.query(sql_string): Execute Polars-SQL on the dataset.
  • df.correlate("col1,col2"): Compute Pearson and Spearman correlation.
  • df.plot(width, height): Display an interactive anywidget visualization.

Development

Adding New Python Bindings

Nairobi Python uses PyO3 to interface with Rust. New core functions should be added to crates/nairobi-python/src/lib.rs and exposed through the nairobi_os._core.data module.

Testing

Integration tests for the Python package can be run using pytest (if configured) or the provided test script:

python3 test_nairobi.py

To test in isolation without the full refinery, you can mock the _core.data module or use the SovereignFrame with pre-existing handles.

Troubleshooting

  • Refinery Failed to Register on D-Bus: This often happens in headless environments. Ensure dbus-launch is available or call nairobi_os.connect() which attempts to fix the environment.
  • Handle Not Found: Data handles are session-bound. If the refinery restarts, previous SovereignFrame handles will become invalid.

License

This project is licensed under the Apache License 2.0.


© 2026 Kevin Chege. All Rights Reserved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nairobi_os-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

File details

Details for the file nairobi_os-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nairobi_os-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1312758c9b7a6357f7b2b35235c7ab365847caf872a26dd9fbaf6abec308b779
MD5 d0fd1cbb524e253f445134c53c5b2f90
BLAKE2b-256 2adcc69a71d166c08b64b7363429c2a72a94ec3f8fadeb61d808fe610c635c9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page