Skip to main content

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 settings mapping in the Datus agent.yml datasources: vocabulary. File discovery and loading belong to the Rust CLI/server; the Python binding never reads or writes a connections file.
  • execute without connection runs on the runtime connections mapping's default: true profile when one exists, else on local DuckDB (db_path= file, or in-memory).
  • Timeouts abandon, they do not cancel: on timeout_secs expiry the call raises ExecuteError(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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dosi_engine-0.1.10-cp312-abi3-manylinux_2_28_x86_64.whl (47.2 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ x86-64

dosi_engine-0.1.10-cp312-abi3-manylinux_2_28_aarch64.whl (45.6 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

dosi_engine-0.1.10-cp312-abi3-macosx_11_0_arm64.whl (54.6 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

File details

Details for the file dosi_engine-0.1.10-cp312-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dosi_engine-0.1.10-cp312-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea89520fd896ebb9c37788a99b586f74d424ca7059f4784c76969efa164ca4f4
MD5 55541365453e312018d76a3d127a282f
BLAKE2b-256 b17ab90b3e88d231ef09d04e33a20251a165c072e4cfde91a673a7129511aba4

See more details on using hashes here.

File details

Details for the file dosi_engine-0.1.10-cp312-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for dosi_engine-0.1.10-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6b57a4f18a1a871e510118545a1298db3d3a96b66fb7a7a328916fb95b6b1ed7
MD5 50f1999f00610c61f288646dd17b46aa
BLAKE2b-256 ad67f718461f8f876c8b91ad00fa637ef6f928afd2efdd0882a844b7385b9a76

See more details on using hashes here.

File details

Details for the file dosi_engine-0.1.10-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dosi_engine-0.1.10-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b14ec66ec8f25a2fd4ed6a353b6679f81306cf9f9e2a0bffd237ef7cdb8c835
MD5 2f825b834bc2329ffa4720ec61281e81
BLAKE2b-256 89debd7428f6d365ae5944fa519979598f3a3797bbb7d41abd56f28350b4a011

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.10 This release

3 files

0.1.9

3 files

0.1.7

3 files

0.1.6

2 files

0.1.5

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page