Python interface for Kalix: hydrological modelling and Pixie (Gorilla-compressed) timeseries I/O
Project description
kalix (Python)
Python interface for Kalix.
Current functionality:
- run simulations from INI model files (in-process, no separate CLI binary)
- run parameter optimisations from config files (in-process)
- read and write Pixie files (
.pxt,.pxb)
Planned:
- programmatic model manipulation and building (a stateful
Modelclass) - richer optimisation control (progress callbacks, in-memory configs)
Design
The package binds the Rust engine directly via PyO3 rather than driving the engine's stdio session protocol (which exists to serve KalixIDE). This keeps the Python surface free to grow in whatever direction suits Python workflows, independent of the GUI's needs.
The current functions are deliberately stateless and mirror the two main
CLI subcommands — simulate and optimise — so that moving from the command
line to Python feels the same: point at files, get results back. A stateful
Model object (load → mutate → run → inspect, all in memory) is the natural
next layer and is planned, but the file-to-result convenience functions are
expected to remain useful indefinitely.
Install
pip install kalix
Usage
Run a simulation
import kalix
kalix.simulate("model.ini", output_file="results.pxb")
df = kalix.read_pixie("results.pxb")
print(df.head())
The Python equivalent of kalix sim model.ini -o results.pxb, but in-process —
no separate CLI binary required. Output format is inferred from the extension
(.pxb for the Pixie pair, .csv for CSV).
Both outputs are keyword-only, and at least one is required:
# Outputs + mass-balance report
kalix.simulate("model.ini", output_file="results.pxb", mass_balance="mb.txt")
# Mass-balance only
kalix.simulate("model.ini", mass_balance="mb.txt")
Run an optimisation
import kalix
result = kalix.optimise("calibration.ini", model_file="initial_model.ini", save_model="final_model.ini")
print(result["best_objective"]) # lower is better
print(result["parameters"]) # {"node.my_sac.uzfwm": 42.7, ...}
print(result["optimised_model_ini"]) # string copy of the final model ini
The Python equivalent of kalix optimise calibration.ini, but in-process. The
config .ini defines the algorithm, calibration terms, objective expression,
parameter bounds, and termination criteria. Unlike simulate, optimise
returns a result dictionary:
| key | meaning |
|---|---|
best_objective |
best objective value found (lower is better) |
n_evaluations |
number of function evaluations performed |
success |
whether the optimiser terminated successfully |
message |
the optimiser's termination message |
parameters |
optimised parameters as {target: physical_value} |
optimised_model_ini |
the optimised model serialised back to an INI string |
Two keyword-only options mirror the CLI's flags:
# Override the config's model_file (CLI: positional [model_file])
kalix.optimise("calibration.ini", model_file="other_model.ini")
# Also write the optimised model to disk (CLI: -s/--save-model)
kalix.optimise("calibration.ini", save_model="tuned.ini")
Paths inside the config (model_file, each term's observed_file) are
resolved relative to the current working directory, exactly as the CLI does.
If the config specifies an output_file, a results summary is written there
too.
Read / write Pixie files
df = kalix.read_pixie("results.pxb")
print(df.head())
kalix.write_pixie("out.pxb", df)
The DataFrame index is a UTC DatetimeIndex; each column is one timeseries.
read_pixie accepts either extension (or no extension) and finds both files:
kalix.read_pixie("results.pxb") # same as
kalix.read_pixie("results.pxt") # same as
kalix.read_pixie("results")
write_pixie prefers a tz-aware DatetimeIndex, but will try to coerce other
inputs (emitting a UserWarning when it does):
- a naive
DatetimeIndexis localised to UTC; - a default
RangeIndex(0, n, 1)triggers promotion of the zeroth column to the index (and drops it from the body); - any other non-
DatetimeIndexis passed throughpd.to_datetime(..., utc=True).
Integer and float dtypes are never auto-interpreted as datetimes (this would
silently misread values as epoch nanoseconds). Set a DatetimeIndex explicitly
in those cases.
Building from source
Requires Rust (1.70+) and maturin.
# Editable install for development
cd python
maturin develop --release
# uv run maturin develop --release --uv
# Build a wheel
maturin build --release
# uv run maturin build --release -- uv
Tests
Running tests directly
maturin develop
pytest python/tests
Alternatively with uv:
uv run maturin develop --uv
uv run pytest
Running tests with tox
Tox is configured to test against multiple Python versions (3.9-3.14):
# Run tests in development environment (fast, uses current Python)
uv run tox -e dev
# Run tests against all configured Python versions
uv run tox
# Run tests for specific Python version
uv run tox -e py312
# List all available test environments
uv run tox list
# Run tests in parallel
uv run tox -p auto
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 kalix-0.3.5.tar.gz.
File metadata
- Download URL: kalix-0.3.5.tar.gz
- Upload date:
- Size: 4.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4d6ff36681832f38b86f8ddd8b97dd4c4761c6af52e12530eb2e3bc05e2cd62
|
|
| MD5 |
bbb9c653c20f6ed85a442f604f408f35
|
|
| BLAKE2b-256 |
001a4c496c2c710e76f5eadcbb8c55cf0e084c5c9d1ea05319c8242dcf9172f3
|
Provenance
The following attestation bundles were made for kalix-0.3.5.tar.gz:
Publisher:
release.yml on chasegan/Kalix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kalix-0.3.5.tar.gz -
Subject digest:
b4d6ff36681832f38b86f8ddd8b97dd4c4761c6af52e12530eb2e3bc05e2cd62 - Sigstore transparency entry: 2085220783
- Sigstore integration time:
-
Permalink:
chasegan/Kalix@2d2969651ad9150cd9dcbdf326e3af394ac2908f -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/chasegan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2d2969651ad9150cd9dcbdf326e3af394ac2908f -
Trigger Event:
push
-
Statement type:
File details
Details for the file kalix-0.3.5-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: kalix-0.3.5-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 684.6 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcc60e7020582878b213527a7fcc865697006c197df2d51edd2e7e6d26c802f5
|
|
| MD5 |
2163c2b2781c50703eeb3db311e77c84
|
|
| BLAKE2b-256 |
b8c451f53f3f79ac88db5d268c8b1efebf952800fbe24551316666507effc8b7
|
Provenance
The following attestation bundles were made for kalix-0.3.5-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on chasegan/Kalix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kalix-0.3.5-cp39-abi3-win_amd64.whl -
Subject digest:
bcc60e7020582878b213527a7fcc865697006c197df2d51edd2e7e6d26c802f5 - Sigstore transparency entry: 2085221121
- Sigstore integration time:
-
Permalink:
chasegan/Kalix@2d2969651ad9150cd9dcbdf326e3af394ac2908f -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/chasegan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2d2969651ad9150cd9dcbdf326e3af394ac2908f -
Trigger Event:
push
-
Statement type:
File details
Details for the file kalix-0.3.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kalix-0.3.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 803.2 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ae475168d30de56d9815aab4731972e74eba7c0c55921f27fb82ac47b7a6719
|
|
| MD5 |
b9b92d17a10ba3f77c5122f9b2ca74f8
|
|
| BLAKE2b-256 |
cb4a1bfd7f40cd27e9b795fca13fb5381fc2c7e73ee22d7a54aa4d54a19b56dc
|
Provenance
The following attestation bundles were made for kalix-0.3.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on chasegan/Kalix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kalix-0.3.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
2ae475168d30de56d9815aab4731972e74eba7c0c55921f27fb82ac47b7a6719 - Sigstore transparency entry: 2085220895
- Sigstore integration time:
-
Permalink:
chasegan/Kalix@2d2969651ad9150cd9dcbdf326e3af394ac2908f -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/chasegan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2d2969651ad9150cd9dcbdf326e3af394ac2908f -
Trigger Event:
push
-
Statement type:
File details
Details for the file kalix-0.3.5-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: kalix-0.3.5-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 702.4 kB
- Tags: CPython 3.9+, 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 |
e87329da558ee9eaf03fe8c48550d2d94219996b88083343b51f1edc010dfb19
|
|
| MD5 |
2346860f3b87328a7018de0a3cda1e63
|
|
| BLAKE2b-256 |
2c37a8ffbd98e5fe97d55c8028b3b4ef85366416afa2ba1051efa54e50f39e78
|
Provenance
The following attestation bundles were made for kalix-0.3.5-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on chasegan/Kalix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kalix-0.3.5-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
e87329da558ee9eaf03fe8c48550d2d94219996b88083343b51f1edc010dfb19 - Sigstore transparency entry: 2085221380
- Sigstore integration time:
-
Permalink:
chasegan/Kalix@2d2969651ad9150cd9dcbdf326e3af394ac2908f -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/chasegan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2d2969651ad9150cd9dcbdf326e3af394ac2908f -
Trigger Event:
push
-
Statement type: