Skip to main content

datus-semantic-dosi

A Datus semantic adapter backed by Dosi, the native Rust OSI engine, with no MetricFlow dependency. It is a thin protocol translator: the OSI YAML is loaded, planned, compiled to dialect SQL, and executed entirely inside the Rust engine (via the dosi-engine pyo3 bindings); this package only maps the Datus semantic-adapter contract onto the engine's API and its structured errors onto SemanticValidationError.

service_type: dosi.

Install

The adapter declares the native engine as a normal dependency. One command installs both packages:

pip install datus-semantic-dosi

No separate dosi-engine installation is required.

For local source development, a release is not required. Install the native checkout first, then the adapter into the same environment:

uv pip install -e ../osi-engine/crates/dosi-py
uv pip install -e ./datus-semantic-dosi

Adjust the relative paths to the workspace root. The first command builds the Rust/PyO3 extension with maturin and keeps the Python package linked to the local checkout.

Configure

from datus_semantic_dosi.config import DosiConfig

DosiConfig(
    semantic_model_path="model.yaml",  # OSI model (.yaml/.yml/.json)
    db_config={"type": "duckdb", "uri": "orders.db"},  # or connections_path=...
)

Connection precedence: an explicit connections_path (agent.yml or a standalone datasources: YAML, consumed verbatim by the engine) wins over an inline db_config (one agent.yml datasource entry, written to a temporary connections file). With neither, the engine falls back to its own discovery order and, failing that, local DuckDB.

Use with Datus-agent

Install the adapter into the same virtualenv as datus-agent:

uv pip install datus-semantic-dosi

For local development before a registry release, install both checkouts with the editable commands above. Entry-point discovery requires an installed adapter distribution; PYTHONPATH alone is not sufficient.

Then wire it in agent.yml. The semantic_layer key must equal the service_type (dosi); Datus-agent fills db_config from the active datasource and semantic_models_path from subject/semantic_models/<datasource>/ automatically, so a model file dropped there needs no further config:

agent:
  services:
    datasources:
      mydb:
        type: duckdb
        uri: /abs/path/to/orders.db
    semantic_layer:
      dosi:                 # key MUST be the service_type
        # both optional; either overrides the auto-derived directory:
        # semantic_model_path: /abs/path/to/model.yaml   # explicit single file
        # connections_path: /abs/path/to/agent.yml       # reuse a connections file

Place OSI model files under <project>/subject/semantic_models/mydb/ (Datus's per-datasource convention). The adapter catalogs every top-level YAML/YML/JSON file, keeps one native engine per file, and routes each globally unique metric name to its owning model. Set semantic_model_path only when an authoring flow must pin the adapter to one explicit file. Launch with datus --datasource mydb; the ask_metrics node then drives list_metrics / query_metrics through this adapter.

Behavior notes

  • validate_semantic delegates to the engine's own validator (structure, references, metric compilation) — no separate ossie integration.
  • get_dimensions(metric) checks model dimensions against that metric with native compile-only planning and returns only queryable candidates and grains. Window discovery includes the planner-required time axis while testing business dimensions. list_metrics leaves metric-level dimensions empty until the engine exposes this catalog relation directly.
  • Ambiguous / unknown names surface as SemanticValidationException whose payload carries the engine's candidates; single-candidate fixes are turned into a concrete suggested_retry.
  • Multiple model files are supported for discovery and single-model queries. Metric and semantic-model names must be unique within a datasource; one query cannot combine metrics owned by different files.
  • Time granularity attaches only to time dimensions; supplying it with no time dimension raises a time_grain_required validation payload.
  • Native time axis accepts metric_time plus time_granularity; a suffixed result column is an output/order key, not a query dimension.
  • Window discovery exposes native structured-window metadata and rejects legacy grain_to_date, window_aggregation, period_over_period, and string window hints instead of silently executing the base aggregate.
  • Engine instances and the metric routing catalog refresh when model files are added, removed, or changed.

Tests

Unit tests run against a fake binding (no native build needed): ci/run-unit-tests.sh datus-semantic-dosi. Integration tests (-m integration) need the real local or installed dosi-engine binding and the duckdb CLI used to seed the test fixture, and use the vendored tests/fixtures/orders/ copy.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datus_semantic_dosi-0.1.3.tar.gz (45.0 kB view details)

Uploaded Source

Built Distribution

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

datus_semantic_dosi-0.1.3-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file datus_semantic_dosi-0.1.3.tar.gz.

File metadata

  • Download URL: datus_semantic_dosi-0.1.3.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for datus_semantic_dosi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e0d6525d8963fb0b20b3e970c6b4560a0dede65d36e0c937df566889b42d3825
MD5 c8a505d18fec2f7fc518b0e117d6c456
BLAKE2b-256 b76079d92669c26700297d1066c06c028ae60f11a69649618abebe69c3c1a631

See more details on using hashes here.

File details

Details for the file datus_semantic_dosi-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for datus_semantic_dosi-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1b30c1284d4778c5a6cff57b31028f9dd915d184bee55973810296d204f42cd6
MD5 58940cfc3c5de45fcc29b787e8ff0209
BLAKE2b-256 d00d0afffdcb6552a884b5304ba4648ef6f9ceec4a3761386ac939d976696d13

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.10

2 files

0.1.9

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

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