dosi-engine
Python bindings for osi-engine: load an OSI semantic model once, then list metrics/dimensions, compile metric queries to dialect SQL, and execute them against a warehouse — all in-process.
from dosi_engine import Engine, QueryError
engine = Engine(
model_path="model.yaml",
connections={"warehouse": {"type": "snowflake", "account": "...", "password": "..."}},
)
engine.metrics() # [{"name", "kind", "datasets", ...}]
engine.compile({"metrics": ["order_count"],
"group_by": [{"field": "orders.status"}]},
dialect="snowflake") # {"dialect": "snowflake", "sql": "..."}
engine.execute({"metrics": ["order_count"]},
connection="warehouse", timeout_secs=60)
# {"dialect", "sql", "columns", "rows": [{col: val}], "row_count"}
The list/compile/execute payloads are the same machine contract as
osi --format json and the REST API; errors raise
ModelError / QueryError / ExecuteError (see dosi_engine.errors)
carrying the same structured fields (code, candidates, hint) as the
CLI/REST JSON error contract. QueryError.candidates lists valid
alternatives for unknown/ambiguous names, so agentic callers can retry
without parsing prose.
Semantics worth knowing
- One Engine = one compiled model. Construction runs load → validate →
compile and fails fast with
ModelError. Engines are thread-safe; compile and execute release the GIL. - Connections are an in-memory
name -> datasource settingsmapping in the Datusagent.ymldatasources:vocabulary. File discovery and loading belong to the Rust CLI/server; the Python binding never reads or writes a connections file. executewithoutconnectionruns on the runtime connections mapping'sdefault: trueprofile when one exists, else on local DuckDB (db_path=file, or in-memory).- Timeouts abandon, they do not cancel: on
timeout_secsexpiry the call raisesExecuteError(code="timeout")but the warehouse request keeps running on its thread; its pool slot frees when it finishes (same limitation as dosi-server). - DuckDB runs in process and ships inside the wheel — nothing to install
for local execution. Warehouse drivers are compiled in too (
exec-all), so no client libraries either.
Building
Requires a Python ≥ 3.12 interpreter discoverable by pyo3; on hosts whose
default python3 is older, set PYO3_PYTHON:
cd crates/dosi-py
PYO3_PYTHON=$(command -v python3.12) uvx maturin build --release -o ../../target/wheels
Development loop against a venv: uvx maturin develop (with the venv
active). Rust-side tests: cargo test -p dosi-py; Python smoke tests (after
maturin develop): pytest tests/python/.
Metadata
Release files for dosi-engine 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dosi_engine-0.1.12-cp312-abi3-manylinux_2_28_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| dosi_engine-0.1.12-cp312-abi3-manylinux_2_28_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| dosi_engine-0.1.12-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 148.7 MB
Release files / dosi_engine-0.1.12-cp312-abi3-manylinux_2_28_x86_64.whl
| Download URL | dosi_engine-0.1.12-cp312-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 47.4 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
da1f6fc5a9094458c30d3550f90dc5b7edda4f981f2028035c1584b13ddf3512
|
|
BLAKE2b-256 checksum How to use checksums |
9a03f0ccee21d0e69929d0a51bad1338d8311d3d8d6967003382dac348168bd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / dosi_engine-0.1.12-cp312-abi3-manylinux_2_28_aarch64.whl
| Download URL | dosi_engine-0.1.12-cp312-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 45.8 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
d1270d8081cee54130cdc38215b98acc37731a1227d866cdef1dab417a51ea27
|
|
BLAKE2b-256 checksum How to use checksums |
8c824a23cb7682e98bc6dff28deaf8348ae8601c42f165ea823aae83cb3d0f77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / dosi_engine-0.1.12-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | dosi_engine-0.1.12-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 55.5 MB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6530635ea9c5b6f88fbae91f267d268f5079b65f284c31eaf1397cfdad7db76f
|
|
BLAKE2b-256 checksum How to use checksums |
3479368167a6b5c8af8eca64f1e7d3670922fef0585b02dd1cb43cbfb1509336
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|