Skip to content

Commit

Permalink
Merge pull request #64 from dbt-labs/adding-semantic-manifest-version
Browse files Browse the repository at this point in the history
Adding semantic manifest version
  • Loading branch information
QMalcolm authored May 20, 2023
2 parents 6f8dfcd + cfd1912 commit 51f0bf6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20230517-103947.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Adding DSI version number to semantic manifest
time: 2023-05-17T10:39:47.542969-05:00
custom:
Author: callum-mcdata
Issue: "30"
12 changes: 12 additions & 0 deletions dbt_semantic_interfaces/implementations/semantic_manifest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from typing import List

from importlib_metadata import version
from pydantic import validator

from dbt_semantic_interfaces.implementations.base import HashableBaseModel
from dbt_semantic_interfaces.implementations.metric import Metric
from dbt_semantic_interfaces.implementations.semantic_model import SemanticModel
Expand All @@ -10,3 +13,12 @@ class SemanticManifest(HashableBaseModel):

semantic_models: List[SemanticModel]
metrics: List[Metric]
interfaces_version: str = ""

@validator("interfaces_version", always=True)
@classmethod
def __create_default_interfaces_version(cls, value: str) -> str: # type: ignore[misc]
"""Returns the version of the dbt_semantic_interfaces package that generated this manifest."""
if value:
return value
return version("dbt_semantic_interfaces")
1 change: 1 addition & 0 deletions dbt_semantic_interfaces/protocols/semantic_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ class SemanticManifest(Protocol):

semantic_models: List[SemanticModel]
metrics: List[Metric]
interfaces_version: str
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies = [
"Jinja2==3.1.2",
"click>=7.1.2",
"python-dateutil==2.8.2",
"importlib_metadata==6.6.0"
]

[build-system]
Expand Down
15 changes: 15 additions & 0 deletions tests/implementations/test_semantic_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from importlib_metadata import version

from dbt_semantic_interfaces.implementations.semantic_manifest import SemanticManifest


def test_interfaces_version_matches() -> None:
"""Test that the interfaces_version property returns the installed version of dbt_semantic_interfaces."""
semantic_manifest = SemanticManifest(
semantic_models=[],
metrics=[],
)

# get the actual installed version
installed_version = version("dbt_semantic_interfaces")
assert semantic_manifest.interfaces_version == installed_version

0 comments on commit 51f0bf6

Please sign in to comment.