Skip to content

Commit 764b4db

Browse files
committed
Fix loader detection order: check MetricFlow before native YAML
"semantic_models:" contains "models:" as a substring, so MetricFlow files were incorrectly routed to SidemanticAdapter. Move the semantic_models: check before the models: check to fix this.
1 parent b3216ad commit 764b4db

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

sidemantic/loaders.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,18 @@ def load_from_directory(layer: "SemanticLayer", directory: str | Path) -> None:
9797
elif suffix in (".yml", ".yaml"):
9898
# Try to detect which format by reading the file
9999
content = file_path.read_text()
100-
# Check for Sidemantic format first (explicit models: key)
101-
if "models:" in content:
102-
adapter = SidemanticAdapter()
100+
# Check for MetricFlow before Sidemantic native since
101+
# "semantic_models:" contains "models:" as a substring
102+
if "semantic_models:" in content:
103+
adapter = MetricFlowAdapter()
103104
elif "semantic_model:" in content and "datasets:" in content:
104105
adapter = OSIAdapter()
105106
elif "cubes:" in content or "views:" in content and "measures:" in content:
106107
adapter = CubeAdapter()
107-
elif "semantic_models:" in content or "metrics:" in content and "type: " in content:
108+
# Check for Sidemantic native format (explicit models: key)
109+
elif "models:" in content:
110+
adapter = SidemanticAdapter()
111+
elif "metrics:" in content and "type: " in content:
108112
adapter = MetricFlowAdapter()
109113
elif "base_sql_table:" in content and "measures:" in content:
110114
adapter = HexAdapter()

0 commit comments

Comments
 (0)