Skip to content

from_domo

from_domo

Convert live Domo entities to OSI semantic models.

from_domo_semantic_model async

from_domo_semantic_model(sm) -> list[OsiSemanticModel]

Fetch a data model's definition and convert it to OSI output.

Calls sm.Model.get() to hydrate the definition, then runs DataModelConverter with an empty datasets dict (Phase 1.0 — no AI Readiness hydration). Pass enriched datasets directly to DataModelConverter().convert() if you need AI Readiness metadata.

Phase 1.5: also fetches each source dataset's aggregated Beast Modes and resolves any DOMO_BEAST_MODE() refs they contain, so the returned models include Beast-Mode-derived OsiMetric entries with self-contained expressions.

Parameters:

Name Type Description Default
sm

DomoSemanticModel with auth embedded.

required

Returns:

Type Description
list[OsiSemanticModel]

list[OsiSemanticModel], one per source table in the data model.

Raises:

Type Description
ValueError

if the API returns no model definition.

Source code in src/crew_dcs/integrations/osi/from_domo.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
async def from_domo_semantic_model(sm) -> list[OsiSemanticModel]:
    """Fetch a data model's definition and convert it to OSI output.

    Calls ``sm.Model.get()`` to hydrate the definition, then runs
    ``DataModelConverter`` with an empty datasets dict (Phase 1.0 — no AI
    Readiness hydration).  Pass enriched ``datasets`` directly to
    ``DataModelConverter().convert()`` if you need AI Readiness metadata.

    Phase 1.5: also fetches each source dataset's aggregated Beast Modes and
    resolves any ``DOMO_BEAST_MODE()`` refs they contain, so the returned
    models include Beast-Mode-derived ``OsiMetric`` entries with
    self-contained expressions.

    Args:
        sm: DomoSemanticModel with auth embedded.

    Returns:
        list[OsiSemanticModel], one per source table in the data model.

    Raises:
        ValueError: if the API returns no model definition.
    """
    await sm.Model.get()
    if not sm.Model.template:
        raise ValueError(f"No model definition returned for data model {sm.id!r}")

    beastmodes = await _fetch_aggregated_beastmodes(sm.auth, sm.Model.template)

    return DataModelConverter().convert(
        sm.Model.template,
        {},
        beastmodes=beastmodes,
        domo_instance=sm.auth.domo_instance,
    )