Skip to content

semantic_model

semantic_model

DomoSemanticModel - a Domo data model (semantic layer).

A semantic model (UI: "Data Model") is a data-model datasource: a query-time join over N source datasets, defined by the model key of the schema/indexed response (objects + relationships).

It is a SIBLING of DomoDatasetView, not a subclass: a dataset view's definition lives in viewTemplate while a data model's lives in model — foundationally different formats. Both inherit dataset + lineage behavior from DomoDataset_Default.

DomoSemanticModel dataclass

DomoSemanticModel(
    auth: DomoAuth,
    id: str,
    raw: dict,
    display_type: str = "",
    data_provider_type: str = "",
    name: str = "",
    description: str = "",
    row_count: int | None = None,
    column_count: int | None = None,
    stream_id: int | None = None,
    cloud_id: str | None = None,
    last_touched_dt: datetime | None = None,
    last_updated_dt: datetime | None = None,
    created_dt: datetime | None = None,
    owner: dict = dict(),
    formulas: dict = dict(),
    Data: DomoDataset_Data | None = None,
    Schema: DomoDataset_Schema | None = None,
    Stream: DomoStream | None = None,
    Tags: DomoTags | None = None,
    PDP: DatasetPdpPolicies | None = None,
    Access: DomoDatasetAccessController | None = None,
    Formulas: DomoDataset_FormulasManager | None = None,
    Certification: DomoCertification | None = None,
    AI_Readiness: DomoDataset_AI_Readiness | None = None,
    _is_schedule_hydrated: bool = False,
    Model: DomoSemanticModel_ModelManager | None = None,
)

Bases: DomoDataset_Default

A Domo data model (semantic layer datasource).

Joins multiple source datasets at query time. The tables and JOIN criteria are exposed via the composed Model manager:

model = await DomoSemanticModel.get_by_id(auth=auth, dataset_id=...)
await model.Model.get()
model.Model.tables           # source-dataset tables
model.Model.relationships    # JOIN criteria

Upstream source datasets are available two ways: directly from the definition (model.Model.source_dataset_ids) and via the inherited Domo lineage API (model.Lineage).

is_semantic_model property

is_semantic_model: bool

Whether this datasource is a data model.

from_dict classmethod

from_dict(
    auth: DomoAuth,
    obj: dict[str, Any],
    is_use_default_dataset_class: bool = True,
    new_cls=None,
    **kwargs
) -> DomoSemanticModel

Create a DomoSemanticModel from an API response dictionary.

Source code in src/crew_dcs/classes/DomoDataset/semantic_model.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@classmethod
def from_dict(
    cls,
    auth: DomoAuth,
    obj: dict[str, Any],
    is_use_default_dataset_class: bool = True,
    new_cls=None,
    **kwargs,
) -> DomoSemanticModel:
    """Create a DomoSemanticModel from an API response dictionary."""
    return super().from_dict(
        auth=auth,
        obj=obj,
        is_use_default_dataset_class=True,
        new_cls=cls,
        **kwargs,
    )

DomoSemanticModels dataclass

DomoSemanticModels(
    auth: DomoAuth, models: list[DomoSemanticModel] = list()
)

Bases: DomoManager

Manager for searching and listing Domo semantic models (data models).

create async

create(
    data_source_name: str,
    schema: dict,
    *,
    data_source_description: str | None = None,
    cloud_id: str = "domo",
    return_raw: bool = False,
    context: RouteContext | None = None,
    **context_kwargs
) -> DomoSemanticModel

Create a new data model on the Domo instance.

Parameters:

Name Type Description Default
data_source_name str

Model display name

required
schema dict

Model definition: {"objects": {...}, "relationships": [...]} (the shape produced by DataModelTemplate.to_schema())

required
data_source_description str | None

Optional model description

None
cloud_id str

Cloud engine ID (defaults to "domo")

'domo'
return_raw bool

Return the raw API response instead of a DomoSemanticModel

False
context RouteContext | None

Optional RouteContext

None
**context_kwargs

Additional context parameters

{}

Returns:

Type Description
DomoSemanticModel

The newly created DomoSemanticModel, or the raw response if

DomoSemanticModel

return_raw=True.

Note

The Domo API has a validation bug where non-primary relationships require a non-null alias but rejects all string values for it. Set primary=True on all relationships in the schema to work around this.

Source code in src/crew_dcs/classes/DomoDataset/semantic_model.py
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
async def create(
    self,
    data_source_name: str,
    schema: dict,
    *,
    data_source_description: str | None = None,
    cloud_id: str = "domo",
    return_raw: bool = False,
    context: RouteContext | None = None,
    **context_kwargs,
) -> DomoSemanticModel:
    """Create a new data model on the Domo instance.

    Args:
        data_source_name: Model display name
        schema: Model definition: ``{"objects": {...}, "relationships": [...]}``
            (the shape produced by ``DataModelTemplate.to_schema()``)
        data_source_description: Optional model description
        cloud_id: Cloud engine ID (defaults to "domo")
        return_raw: Return the raw API response instead of a DomoSemanticModel
        context: Optional RouteContext
        **context_kwargs: Additional context parameters

    Returns:
        The newly created DomoSemanticModel, or the raw response if
        ``return_raw=True``.

    Note:
        The Domo API has a validation bug where non-primary relationships
        require a non-null ``alias`` but rejects all string values for it.
        Set ``primary=True`` on all relationships in the schema to work
        around this.
    """
    from ...routes import dataset as dataset_routes

    context = RouteContext.build_context(context=context, **context_kwargs)

    res = await dataset_routes.create_semantic_model(
        auth=self.auth,
        data_source_name=data_source_name,
        schema=schema,
        data_source_description=data_source_description,
        cloud_id=cloud_id,
        context=context,
    )

    if return_raw:
        return res

    model_id = res.response.get("dataSourceId") or res.response.get("id")
    if not model_id:
        return res

    return await DomoSemanticModel.get_by_id(
        auth=self.auth,
        dataset_id=model_id,
        context=context,
    )

get async

get(
    model_id: str,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> DomoSemanticModel

Retrieve a single semantic model by its datasource ID.

Parameters:

Name Type Description Default
model_id str

The data model datasource ID

required
context RouteContext | None

Optional RouteContext

None
**context_kwargs

Additional context parameters

{}

Returns:

Type Description
DomoSemanticModel

A DomoSemanticModel instance.

Source code in src/crew_dcs/classes/DomoDataset/semantic_model.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
async def get(
    self,
    model_id: str,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> DomoSemanticModel:
    """Retrieve a single semantic model by its datasource ID.

    Args:
        model_id: The data model datasource ID
        context: Optional RouteContext
        **context_kwargs: Additional context parameters

    Returns:
        A DomoSemanticModel instance.
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    return await DomoSemanticModel.get_by_id(
        auth=self.auth,
        dataset_id=model_id,
        context=context,
    )

search async

search(
    maximum: int | None = None,
    last_updated_bucket: str | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[DomoSemanticModel]

Search the instance for semantic models via the SEMANTIC_MODEL profile.

Parameters:

Name Type Description Default
maximum int | None

Maximum number of models to return

None
last_updated_bucket str | None

Optional last_updated dateBucket (e.g. "LAST_WEEK")

None
return_raw bool

Return the raw search response

False
context RouteContext | None

Optional RouteContext

None
**context_kwargs

Additional context parameters

{}

Returns:

Type Description
list[DomoSemanticModel]

List of DomoSemanticModel objects.

Source code in src/crew_dcs/classes/DomoDataset/semantic_model.py
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
async def search(
    self,
    maximum: int | None = None,
    last_updated_bucket: str | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[DomoSemanticModel]:
    """Search the instance for semantic models via the SEMANTIC_MODEL profile.

    Args:
        maximum: Maximum number of models to return
        last_updated_bucket: Optional ``last_updated`` dateBucket (e.g. "LAST_WEEK")
        return_raw: Return the raw search response
        context: Optional RouteContext
        **context_kwargs: Additional context parameters

    Returns:
        List of DomoSemanticModel objects.
    """
    from ...routes import datacenter as datacenter_routes

    context = RouteContext.build_context(context=context, **context_kwargs)

    res = await datacenter_routes.search_semantic_models(
        auth=self.auth,
        maximum=maximum,
        last_updated_bucket=last_updated_bucket,
        return_raw=True,
        context=context,
    )

    if return_raw:
        return res

    self.models = [
        DomoSemanticModel.from_dict(auth=self.auth, obj=obj)
        for obj in (res.response or [])
    ]
    return self.models