Skip to content

Commit

Permalink
Rename time spine files & classes for simplicity
Browse files Browse the repository at this point in the history
These are based on models (semantic difference from tables). And all YAML specs are configurations, so that piece just seemed redundant.
  • Loading branch information
courtneyholcomb committed Jun 17, 2024
1 parent ee52b13 commit 59286e0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
UNKNOWN_VERSION_SENTINEL,
PydanticSemanticVersion,
)
from dbt_semantic_interfaces.implementations.time_spine_table_configuration import (
PydanticTimeSpineTableConfiguration,
)
from dbt_semantic_interfaces.implementations.time_spine import PydanticTimeSpine
from dbt_semantic_interfaces.protocols import ProtocolHint
from dbt_semantic_interfaces.protocols.project_configuration import ProjectConfiguration
from dsi_pydantic_shim import validator
Expand All @@ -29,7 +27,7 @@ class PydanticProjectConfiguration(HashableBaseModel, ModelWithMetadataParsing,
def _implements_protocol(self) -> ProjectConfiguration:
return self

time_spine_table_configurations: List[PydanticTimeSpineTableConfiguration]
time_spine_table_configurations: List[PydanticTimeSpine]
metadata: Optional[PydanticMetadata] = None
dsi_package_version: PydanticSemanticVersion = UNKNOWN_VERSION_SENTINEL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
ModelWithMetadataParsing,
)
from dbt_semantic_interfaces.protocols import ProtocolHint
from dbt_semantic_interfaces.protocols.time_spine_configuration import (
TimeSpineTableConfiguration,
from dbt_semantic_interfaces.protocols.time_spine import (
TimeSpine,
)
from dbt_semantic_interfaces.type_enums import TimeGranularity


class PydanticTimeSpineTableConfiguration(
HashableBaseModel, ModelWithMetadataParsing, ProtocolHint[TimeSpineTableConfiguration]
):
class PydanticTimeSpine(HashableBaseModel, ModelWithMetadataParsing, ProtocolHint[TimeSpine]):
"""Pydantic implementation of SemanticVersion."""

@override
def _implements_protocol(self) -> TimeSpineTableConfiguration:
def _implements_protocol(self) -> TimeSpine:
return self

location: str
Expand Down
6 changes: 2 additions & 4 deletions dbt_semantic_interfaces/protocols/project_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
from typing import Protocol, Sequence

from dbt_semantic_interfaces.protocols.semantic_version import SemanticVersion
from dbt_semantic_interfaces.protocols.time_spine_configuration import (
TimeSpineTableConfiguration,
)
from dbt_semantic_interfaces.protocols.time_spine import TimeSpine


class ProjectConfiguration(Protocol):
Expand All @@ -18,6 +16,6 @@ def dsi_package_version(self) -> SemanticVersion:

@property
@abstractmethod
def time_spine_table_configurations(self) -> Sequence[TimeSpineTableConfiguration]:
def time_spine_table_configurations(self) -> Sequence[TimeSpine]:
"""The time spine table configurations. Multiple allowed for different time grains."""
pass
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dbt_semantic_interfaces.type_enums import TimeGranularity


class TimeSpineTableConfiguration(Protocol):
class TimeSpine(Protocol):
"""Describes the configuration for a time spine table.
A time spine table is a table with a single column containing dates at a specific grain.
Expand Down
6 changes: 2 additions & 4 deletions tests/example_project_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
from dbt_semantic_interfaces.implementations.project_configuration import (
PydanticProjectConfiguration,
)
from dbt_semantic_interfaces.implementations.time_spine_table_configuration import (
PydanticTimeSpineTableConfiguration,
)
from dbt_semantic_interfaces.implementations.time_spine import PydanticTimeSpine
from dbt_semantic_interfaces.parsing.objects import YamlConfigFile
from dbt_semantic_interfaces.type_enums import TimeGranularity

EXAMPLE_PROJECT_CONFIGURATION = PydanticProjectConfiguration(
time_spine_table_configurations=[
PydanticTimeSpineTableConfiguration(
PydanticTimeSpine(
location="example_schema.example_table",
column_name="ds",
grain=TimeGranularity.DAY,
Expand Down
14 changes: 5 additions & 9 deletions tests/test_implements_satisfy_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
PydanticSemanticManifest,
)
from dbt_semantic_interfaces.implementations.semantic_model import PydanticSemanticModel
from dbt_semantic_interfaces.implementations.time_spine_table_configuration import (
PydanticTimeSpineTableConfiguration,
)
from dbt_semantic_interfaces.implementations.time_spine import PydanticTimeSpine
from dbt_semantic_interfaces.protocols import Dimension as DimensionProtocol
from dbt_semantic_interfaces.protocols import Entity as EntityProtocol
from dbt_semantic_interfaces.protocols import Measure as MeasureProtocol
Expand All @@ -48,9 +46,7 @@
SemanticManifest as SemanticManifestProtocol,
)
from dbt_semantic_interfaces.protocols import SemanticModel as SemanticModelProtocol
from dbt_semantic_interfaces.protocols.time_spine_configuration import (
TimeSpineTableConfiguration as TimeSpineTableConfigurationProtocol,
)
from dbt_semantic_interfaces.protocols.time_spine import TimeSpine as TimeSpineProtocol
from dbt_semantic_interfaces.type_enums import DimensionType, MetricType

OPTIONAL_STR_STRATEGY = text() | none()
Expand Down Expand Up @@ -284,12 +280,12 @@ def test_saved_query_protocol(saved_query: PydanticSavedQuery) -> None: # noqa:


@runtime_checkable
class RuntimeCheckableTimeSpineConfiguration(TimeSpineTableConfigurationProtocol, Protocol):
class RuntimeCheckableTimeSpineConfiguration(TimeSpineProtocol, Protocol):
"""We don't want runtime_checkable versions of protocols in the package, but we want them for tests."""

pass


@given(builds(PydanticTimeSpineTableConfiguration))
def test_time_spine_table_configuration_protocol(time_spine: PydanticTimeSpineTableConfiguration) -> None: # noqa: D
@given(builds(PydanticTimeSpine))
def test_time_spine_table_configuration_protocol(time_spine: PydanticTimeSpine) -> None: # noqa: D
assert isinstance(time_spine, RuntimeCheckableTimeSpineConfiguration)

0 comments on commit 59286e0

Please sign in to comment.