-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test fixtures to load manifests using paths from anchors.
- Loading branch information
Showing
3 changed files
with
94 additions
and
41 deletions.
There are no files selected for viewing
26 changes: 9 additions & 17 deletions
26
metricflow-semantics/metricflow_semantics/test_helpers/manifest_helpers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,26 @@ | ||
from __future__ import annotations | ||
|
||
import pathlib | ||
from typing import Dict, Optional | ||
|
||
from dbt_semantic_interfaces.implementations.semantic_manifest import PydanticSemanticManifest | ||
from dbt_semantic_interfaces.parsing.dir_to_model import ( | ||
SemanticManifestBuildResult, | ||
parse_directory_of_yaml_files_to_semantic_manifest, | ||
) | ||
from dbt_semantic_interfaces.validations.semantic_manifest_validator import SemanticManifestValidator | ||
|
||
from metricflow_semantics.test_helpers.semantic_manifest_yamls import SEMANTIC_MANIFEST_YAMLS_PATH_ANCHOR | ||
|
||
|
||
def load_semantic_manifest( | ||
relative_manifest_path: str, | ||
yaml_file_directory: pathlib.Path, | ||
template_mapping: Optional[Dict[str, str]] = None, | ||
) -> SemanticManifestBuildResult: | ||
) -> PydanticSemanticManifest: | ||
"""Reads the manifest YAMLs from the standard location, applies transformations, runs validations.""" | ||
yaml_file_directory = SEMANTIC_MANIFEST_YAMLS_PATH_ANCHOR.directory.joinpath(relative_manifest_path) | ||
build_result = parse_directory_of_yaml_files_to_semantic_manifest( | ||
str(yaml_file_directory), template_mapping=template_mapping | ||
) | ||
validator = SemanticManifestValidator[PydanticSemanticManifest]() | ||
validator.checked_validations(build_result.semantic_manifest) | ||
return build_result | ||
|
||
|
||
def load_named_manifest(template_mapping: Dict[str, str], manifest_name: str) -> PydanticSemanticManifest: # noqa: D103 | ||
try: | ||
build_result = load_semantic_manifest(manifest_name, template_mapping) | ||
build_result = parse_directory_of_yaml_files_to_semantic_manifest( | ||
str(yaml_file_directory), template_mapping=template_mapping | ||
) | ||
validator = SemanticManifestValidator[PydanticSemanticManifest]() | ||
validator.checked_validations(build_result.semantic_manifest) | ||
return build_result.semantic_manifest | ||
except Exception as e: | ||
raise RuntimeError(f"Error while loading semantic manifest: {manifest_name}") from e | ||
raise RuntimeError(f"Error while loading semantic manifest: {yaml_file_directory}") from e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters