-
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 MFEngine models to contain attributes from pydantic models (#533)
- Loading branch information
1 parent
8645754
commit dadd45f
Showing
5 changed files
with
60 additions
and
32 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
kind: Under the Hood | ||
time: 2023-05-23T18:07:25.654887-07:00 | ||
custom: | ||
Author: courtneyholcomb | ||
Issue: "0" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,35 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import List | ||
from typing import List, Optional | ||
|
||
from dbt_semantic_interfaces.objects.metric import MetricType, MetricTypeParams, Metric as SemanticManifestMetric | ||
from dbt_semantic_interfaces.objects.filters.where_filter import WhereFilter | ||
from dbt_semantic_interfaces.objects.metadata import Metadata | ||
from dbt_semantic_interfaces.objects.elements.dimension import Dimension | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Metric: | ||
"""Dataclass representation of a Metric.""" | ||
|
||
name: str | ||
description: Optional[str] | ||
type: MetricType | ||
type_params: MetricTypeParams | ||
filter: Optional[WhereFilter] | ||
metadata: Optional[Metadata] | ||
dimensions: List[Dimension] | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Dimension: | ||
"""Dataclass representation of a Dimension.""" | ||
|
||
name: str | ||
@classmethod | ||
def from_pydantic(cls, pydantic_metric: SemanticManifestMetric, dimensions: List[Dimension]) -> Metric: | ||
"""Build from pydantic Metric object and list of Dimensions.""" | ||
return cls( | ||
name=pydantic_metric.name, | ||
description=pydantic_metric.description, | ||
type=pydantic_metric.type, | ||
type_params=pydantic_metric.type_params, | ||
filter=pydantic_metric.filter, | ||
metadata=pydantic_metric.metadata, | ||
dimensions=dimensions, | ||
) |
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