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/.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 dosi_engine-0.1.9-cp312-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: dosi_engine-0.1.9-cp312-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 46.5 MB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5a0f8434688f78383762b590db4dea4f96ca860ba0699f0933f8bc2bd955ad6
|
|
| MD5 |
c6e78e8b552a2405e6bd9c5460b753ff
|
|
| BLAKE2b-256 |
662f5170ff4e1df422277814836f9937eeb55bebd6c076d7306c3aa26a9fe9fd
|
File details
Details for the file dosi_engine-0.1.9-cp312-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: dosi_engine-0.1.9-cp312-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 44.8 MB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7e693318e6af00c68d490b0f0efd436db36fffc07396d3e7fb2d4a2a5eea891
|
|
| MD5 |
087c2d7f356111e97d7857fd5e611ba4
|
|
| BLAKE2b-256 |
b906212ac30eaaac4a3b8d9d53e22be5324c7549cbde3e1af28d859cbee23894
|
File details
Details for the file dosi_engine-0.1.9-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: dosi_engine-0.1.9-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 53.9 MB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2686b34d906238eabb5f77c026ae58701e7a36ad386fdc5afcd00ce5a30cca1b
|
|
| MD5 |
cc5dcb694aa90a4c938792c9cefa198b
|
|
| BLAKE2b-256 |
c9304449dd89cd9c52439bb1fd5c4627ea4ab3c98f0ce71bf2de45c6d8bbbb5b
|