data_model_converter
data_model_converter ¶
DataModelConverter — converts DataModelTemplate to OSI semantic models.
DataModelConverter ¶
Bases: OsiConverter
Converts a Domo DataModelTemplate to a list of OsiSemanticModels.
One OsiSemanticModel is produced per DataModelObject (source table). Join key columns become OsiEntity instances; all other columns are classified as dimensions or metrics based on AI_Readiness subType, falling back to data-type inference.
Cross-model relationships (JOINs) are attached to the left-side model.
Metrics (Phase 1.5) come from two routes, per the PRD's classification
rules — both can contribute to the same model, they are not mutually
exclusive:
1. Primary: columns with AI_Readiness_Column.subType == 'METRIC'.
2. Fallback: Beast Modes with BeastModeTemplate.aggregated is True,
passed in via the beastmodes param (keyed by datasource_id).
A Beast Mode whose name collides with an AI-Readiness-derived
metric name is skipped — the AI Readiness path wins.
Usage
converter = DataModelConverter() models = converter.convert(template, datasets) converter.export_to_file(models, "output.yaml")
With Beast Mode metrics:¶
models = converter.convert( template, datasets, beastmodes={"ds-orders": [aggregated_template, ...]}, domo_instance="mycompany", )
convert ¶
convert(
source,
datasets: dict,
beastmodes: (
dict[str, list[BeastModeTemplate]] | None
) = None,
domo_instance: str | None = None,
**options
) -> list[OsiSemanticModel]
Convert a DataModelTemplate to OSI semantic models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
DataModelTemplate with objects and relationships |
required | |
datasets
|
dict
|
dict mapping datasource_id -> DomoDataset (or None) |
required |
beastmodes
|
dict[str, list[BeastModeTemplate]] | None
|
dict mapping datasource_id -> list[BeastModeTemplate]
(Phase 1.5). Only templates with |
None
|
domo_instance
|
str | None
|
Domo instance hostname, recorded on Beast-Mode-
derived metrics' |
None
|
**options
|
Unused beyond the params above |
{}
|
Returns:
| Type | Description |
|---|---|
list[OsiSemanticModel]
|
list[OsiSemanticModel], one per DataModelObject |
Source code in src/crew_dcs/integrations/osi/data_model_converter.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 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 | |