py-mando
PyO3-based Python extension module for the Mando workspace. Exposes high-performance Rust components to Python for algorithm execution, data processing, and service integration.
Structure
py-mando/
├── Cargo.toml
├── pyproject.toml # Maturin + Poetry config
├── src/
│ ├── lib.rs # Module registration
│ ├── adapter.rs # Backend service impls
│ ├── algo.rs # Algorithm params (1,143 lines)
│ ├── algo_runner.rs # HTTP algo runner/server
│ ├── polars.rs # DataFrame ops (1,185 lines)
│ ├── data_point.rs # DataPoint config/metadata
│ ├── validation.rs # Input validation
│ ├── test.rs # Test utilities
│ ├── util.rs # General utilities
│ ├── bess_util.rs # BESS-specific utils
│ ├── codegen.rs # Client code generation
│ └── execution.rs # Execution context
├── test/ # Python tests
└── example/notebooks/ # Jupyter notebooks (nbval)
Python API
Initialization
from py_mando import init, version
init() # Sets up tracing, rustls
print(version()) # Returns Rust crate versionKey Classes
| PyClass | Module | Purpose |
|---|---|---|
AlgoParamsConfig | algo | Wraps JSON algorithm configuration |
DataPointConfig | data_point | Data point metadata |
PyMandoDataPointCalculation | data_point | Calculation definitions |
AlgoRunner | algo_runner | HTTP service for running algorithms |
ServerConfig | algo_runner | Server configuration |
Re-exported from mando-lib
from py_mando import (
DataPointId,
DataPointFilter,
FlowFilter,
MandoRestConfig,
)Adapters
Backend service implementations exposed to Python:
- Polars adapter — DataFrame-based operations
- PostgreSQL adapter — Direct DB access
- REST adapter — HTTP client for mando-bess API
Polars Operations
The polars module (1,185 lines) provides:
- Filtering and grouping
- Joins
- Time functions
- Resolution conversion
- DataFrame transformations
Algorithm Parameters
The algo module (1,143 lines) defines:
- Algorithm parameter configurations
- MOL (Machine Operations Learning) params
- Market aggregate definitions
Build Configuration
| Setting | Value |
|---|---|
| Build tool | Maturin 1.9.2 |
| Python ABI | abi3-py38 (stable across versions) |
| Python requirement | >= 3.10 |
| Crate type | cdylib (shared library) |
Python Dependencies
| Package | Version |
|---|---|
| pandas | 2.3.1 |
| polars | 1.31.0 |
| PyArrow | 21.0.0 |
| PyYAML | 6.0.2 |
Building
cd py-mando
maturin develop # Dev build
maturin build --release # Release wheelTesting
cd py-mando
pytest test/
pytest --nbval example/notebooks/ # Notebook validationData Bridge
Zero-copy data exchange between Rust and Python using:
pyo3-polars— Polars DataFrame bridgepyo3-arrow— Arrow array bridgepyo3-async-runtimes— Tokio async integration
This allows Python algorithms to operate on Rust-managed data without serialization overhead.