forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeature_view_projection.py
More file actions
37 lines (28 loc) · 1.05 KB
/
Copy pathfeature_view_projection.py
File metadata and controls
37 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from typing import List
from attr import dataclass
from feast.feature import Feature
from feast.protos.feast.core.FeatureViewProjection_pb2 import (
FeatureViewProjection as FeatureViewProjectionProto,
)
@dataclass
class FeatureViewProjection:
name: str
features: List[Feature]
def to_proto(self):
feature_reference_proto = FeatureViewProjectionProto(
feature_view_name=self.name
)
for feature in self.features:
feature_reference_proto.feature_columns.append(feature.to_proto())
return feature_reference_proto
@staticmethod
def from_proto(proto: FeatureViewProjectionProto):
ref = FeatureViewProjection(name=proto.feature_view_name, features=[])
for feature_column in proto.feature_columns:
ref.features.append(Feature.from_proto(feature_column))
return ref
@staticmethod
def from_definition(feature_definition):
return FeatureViewProjection(
name=feature_definition.name, features=feature_definition.features
)