Metadata-Version: 2.4
Name: chili-sauce
Version: 0.11.5
License-File: LICENSE
Summary: Python bindings for the Chili engine (EngineState)
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# Chili Sauce 🌶️

Python bindings for [Chili](https://purple-chili.github.io/)'s `EngineState`, powered by [PyO3](https://pyo3.rs/).

## Installation

```bash
pip install chili-sauce
```

Requires Python ≥ 3.10.

## Quick Start

```python
from chili import ChiliEngine

engine = ChiliEngine()

# Evaluate expressions
engine.eval("1 + 2")  # => 3

# Variable management
engine.set_var("x", 42)
engine.get_var("x")  # => 42

# Work with Polars DataFrames
import polars as pl

df = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
engine.set_var("df", df)
engine.get_var("df")
```

## IPC / Remote Queries

```python
# Open a handle to a remote Chili process
h = engine.open_handle("chili://:1800")

# Send synchronous queries
engine.sync(h, b"1+1")                # bytes  — sent as a raw string query
engine.sync(h, ["set", "a", 2])       # list   — sent as a function call (func, args…)
```

## Features

- **Evaluate** Chili or Pepper expressions from Python
- **Variable management** — get, set, delete, and list variables
- **Polars integration** — pass DataFrames bidirectionally between Python and Chili
- **Partitioned storage** — write and load date-partitioned Parquet tables
- **IPC / TCP** — start a TCP listener for remote connections
- **Tick plant** — built-in pub/sub infrastructure for real-time data

## Type Mapping

| Python type         | Chili type  |
| ------------------- | ----------- |
| `int`               | `Int`       |
| `float`             | `Float`     |
| `bool`              | `Bool`      |
| `str`               | `Symbol`    |
| `bytes`             | `String`    |
| `None`              | `Null`      |
| `list`              | `MixedList` |
| `dict`              | `Dict`      |
| `datetime.date`     | `Date`      |
| `datetime.time`     | `Time`      |
| `datetime.datetime` | `Datetime`  |
| `polars.DataFrame`  | `DataFrame` |

## Development

For buffers read or flushed concurrently, symbol-form `vstack` enables automatic
compaction by default. Configure it with
`engine.set_auto_compaction(interval_ms=250, target_rows=65536)`; a zero interval
disables future passes. Frequent table-replacing trims can prevent compaction
from completing. Empty-batch `upsertn` is an atomic retention option, but can copy
retained numeric data under the variable write lock. Parquet bytes also depend
on the snapshot's chunk layout, so identical dataframe values need not produce
identical files. See the [buffer and retention documentation](https://purple-chili.github.io/built-in-functions/df/#vstack)
and [Parquet writer documentation](https://purple-chili.github.io/built-in-functions/io/#wparquet).

```bash
# Build and install in development mode
maturin develop --release --manifest-path crates/chili-py/Cargo.toml

# Run tests
pytest crates/chili-py/tests/
```

In 0.11.4, `fsync_handle` raises the first non-interruption sync error without
reopening the log; durability is unknown after a failure. Bundled tickerplants
and subscribers use a separate message replay bound, supporting row stamping.
Upgrade both peers and update custom tickerplants to the four-field handshake;
new subscribers reject legacy replies. Previously duplicated or skipped data
requires rebuilding subscriber state from retained logs.

In 0.11.5, macOS wheels use Rust's system allocator; other platforms retain
mimalloc. This addresses the allocator-recursion path reported in mixed macOS
parallel tests; confirmation with the affected full suite is pending. The CLI
allocator is unchanged. Log paths in subscription replies are Python `str`
again (0.11.4 returned `bytes`), while the message replay bound remains intact.

