Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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_path="agent.yml")

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 use the Datus agent.yml datasources: vocabulary. An explicit connections_path is loaded eagerly (fail fast); otherwise the CLI's discovery order applies lazily (DOSI_CONNECTIONS, ./osi-connections.yaml, ~/.config/osi/connections.yaml, ./conf/agent.yml, ~/.datus/conf/agent.yml).
  • execute without connection runs on the connections file's default: true profile when one exists, else on local DuckDB (db_path= file, or in-memory). In-memory DuckDB spawns one process per statement, so seeded data requires a file database.
  • 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 osi-server).
  • DuckDB execution shells out to the system duckdb CLI — install it (https://duckdb.org) for local execution; warehouse drivers are compiled into the wheel (exec-all).

Building

Requires a Python ≥ 3.12 interpreter discoverable by pyo3; on hosts whose default python3 is older, set PYO3_PYTHON:

cd crates/osi-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 osi-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.6rc1-cp312-abi3-manylinux_2_28_x86_64.whl (34.5 MB view details)

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

dosi_engine-0.1.6rc1-cp312-abi3-manylinux_2_28_aarch64.whl (34.0 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

File details

Details for the file dosi_engine-0.1.6rc1-cp312-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dosi_engine-0.1.6rc1-cp312-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 210fc9b70e80b0f0557239df4ce4d999df6fea0726b7d27f3c8c5d40535beca1
MD5 22f0e4c98e23fa90fc950a3bc745cc2d
BLAKE2b-256 9afaebcc612fe1dc7cb9cd7abf5024800559fb4527703079c01f092cf847748a

See more details on using hashes here.

File details

Details for the file dosi_engine-0.1.6rc1-cp312-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for dosi_engine-0.1.6rc1-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ab56a4715f1670c5bc9c5355d732deea7c744e09a843474be8d9f468bc767d03
MD5 259e697a7c51c56f0376027186311058
BLAKE2b-256 7cb37aa8a50f67085f0cde23e6c2e1e86869f60bc4dfba4228605ab6c82c4530

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.10

3 files

0.1.9

3 files

0.1.7

3 files

0.1.6

2 files

This release

0.1.6rc1 This release

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