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/.

Metadata

Release files for dosi-engine 0.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for dosi-engine 0.1.13
File
dosi_engine-0.1.13-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
dosi_engine-0.1.13-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details
dosi_engine-0.1.13-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details
dosi_engine-0.1.13-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details
dosi_engine-0.1.13-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details

Total release size: 242.6 MB

Release files / dosi_engine-0.1.13-cp312-abi3-win_amd64.whl

Download URL dosi_engine-0.1.13-cp312-abi3-win_amd64.whl
Size 35.1 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1a179f22d2e643784675f133e6b4f6c3804ac84243a8fb44f270e49888d8e4c8
BLAKE2b-256 checksum
How to use checksums
46771b8f001712be9eaf1a29c3fc0e318d2b51344cf97b3c16fbd16c71c0f4f7
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.13-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL dosi_engine-0.1.13-cp312-abi3-manylinux_2_28_x86_64.whl
Size 48.2 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
76a6d47458049e29b0a9a8844d74150f3fe26fe571b1119c32b8af7b185a4378
BLAKE2b-256 checksum
How to use checksums
815f0bbecbbdff73b7e62efb1349e8995d842a2f826d3c6fc595b4f91d6efd5b
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.13-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL dosi_engine-0.1.13-cp312-abi3-manylinux_2_28_aarch64.whl
Size 46.6 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
b435e8c5f24d99c0bfe203cf9101b775d39b66fb6d37d08e6157601d98284461
BLAKE2b-256 checksum
How to use checksums
44a50f742d22abe652d0ba2d2e2aff656598433417e3ea80ad379e653efcee9a
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.13-cp312-abi3-macosx_11_0_arm64.whl

Download URL dosi_engine-0.1.13-cp312-abi3-macosx_11_0_arm64.whl
Size 55.6 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fcd43a41d88b0937d772de38259a210f19e82dbe2cfa513313e5781e634590d1
BLAKE2b-256 checksum
How to use checksums
786c67fb48de58054177cf21ea5a20b725b3a3567e3a09fea2135a3fd90da015
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.13-cp312-abi3-macosx_10_12_x86_64.whl

Download URL dosi_engine-0.1.13-cp312-abi3-macosx_10_12_x86_64.whl
Size 57.1 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
91c96e7a1f995fda46bc32a9e2994d39203596f89e9681ff0f292bf79c8de895
BLAKE2b-256 checksum
How to use checksums
c4cd06b649e2ea68bb95a5d5e6949541042b17e1711e39edee97e2b01fccd702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.13 This release

5 release files

0.1.12

3 release files

0.1.11

3 release files

0.1.10

3 release files

0.1.9

3 release files

0.1.7

3 release files

0.1.6

2 release files

0.1.5

1 release 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