Skip to content

Commit 2ab8eea

Browse files
authored
Merge branch 'master' into mwad22-1618-PR
2 parents d7d08ef + 6a09d49 commit 2ab8eea

9 files changed

Lines changed: 197 additions & 3 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
syntax = "proto3";
2+
package feast.core;
3+
4+
option go_package = "github.com/feast-dev/feast/sdk/go/protos/feast/core";
5+
option java_outer_classname = "FeatureServiceProto";
6+
option java_package = "feast.proto.core";
7+
8+
import "google/protobuf/timestamp.proto";
9+
import "feast/core/FeatureViewProjection.proto";
10+
11+
message FeatureService {
12+
// User-specified specifications of this feature service.
13+
FeatureServiceSpec spec = 1;
14+
15+
// System-populated metadata for this feature service.
16+
FeatureServiceMeta meta = 2;
17+
}
18+
19+
message FeatureServiceSpec {
20+
// Name of the Feature Service. Must be unique. Not updated.
21+
string name = 1;
22+
23+
// Name of Feast project that this Feature Service belongs to.
24+
string project = 2;
25+
26+
// List of features that this feature service encapsulates.
27+
// Stored as a list of references to other features views and the features from those views.
28+
repeated FeatureViewProjection features = 3;
29+
30+
// User defined metadata
31+
map<string,string> tags = 4;
32+
}
33+
34+
35+
message FeatureServiceMeta {
36+
// Time where this Feature Service is created
37+
google.protobuf.Timestamp created_timestamp = 1;
38+
39+
// Time where this Feature Service is last updated
40+
google.protobuf.Timestamp last_updated_timestamp = 2;
41+
42+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
syntax = "proto3";
2+
package feast.core;
3+
4+
option go_package = "github.com/feast-dev/feast/sdk/go/protos/feast/core";
5+
option java_outer_classname = "FeatureReferenceProto";
6+
option java_package = "feast.proto.core";
7+
8+
import "feast/core/Feature.proto";
9+
10+
11+
// A reference to features in a feature view
12+
message FeatureViewProjection {
13+
// The feature view name
14+
string feature_view_name = 1;
15+
16+
// The features of the feature view that are a part of the feature reference.
17+
repeated FeatureSpecV2 feature_columns = 2;
18+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
from datetime import datetime
2+
from typing import List, Optional, Union
3+
4+
from feast.feature_table import FeatureTable
5+
from feast.feature_view import FeatureView
6+
from feast.feature_view_projection import FeatureViewProjection
7+
from feast.protos.feast.core.FeatureService_pb2 import (
8+
FeatureService as FeatureServiceProto,
9+
)
10+
from feast.protos.feast.core.FeatureService_pb2 import (
11+
FeatureServiceMeta,
12+
FeatureServiceSpec,
13+
)
14+
15+
16+
class FeatureService:
17+
name: str
18+
features: List[FeatureViewProjection]
19+
created_timestamp: Optional[datetime] = None
20+
last_updated_timestamp: Optional[datetime] = None
21+
22+
def __init__(
23+
self,
24+
name: str,
25+
features: List[Union[FeatureTable, FeatureView, FeatureViewProjection]],
26+
):
27+
self.name = name
28+
self.features = []
29+
for feature in features:
30+
if isinstance(feature, FeatureTable) or isinstance(feature, FeatureView):
31+
self.features.append(FeatureViewProjection.from_definition(feature))
32+
elif isinstance(feature, FeatureViewProjection):
33+
self.features.append(feature)
34+
else:
35+
raise ValueError(f"Unexpected type: {type(feature)}")
36+
37+
def __eq__(self, other):
38+
pass
39+
40+
@staticmethod
41+
def from_proto(feature_service_proto: FeatureServiceProto):
42+
fs = FeatureService(
43+
name=feature_service_proto.spec.name,
44+
features=[
45+
FeatureViewProjection.from_proto(fp)
46+
for fp in feature_service_proto.spec.features
47+
],
48+
)
49+
50+
if feature_service_proto.meta.HasField("created_timestamp"):
51+
fs.created_timestamp = (
52+
feature_service_proto.meta.created_timestamp.ToDatetime()
53+
)
54+
if feature_service_proto.meta.HasField("last_updated_timestamp"):
55+
fs.last_updated_timestamp = (
56+
feature_service_proto.meta.last_updated_timestamp.ToDatetime()
57+
)
58+
59+
return fs
60+
61+
def to_proto(self):
62+
meta = FeatureServiceMeta()
63+
if self.created_timestamp:
64+
meta.created_timestamp.FromDatetime(self.created_timestamp)
65+
66+
spec = FeatureServiceSpec()
67+
spec.name = self.name
68+
for definition in self.features:
69+
if isinstance(definition, FeatureTable) or isinstance(
70+
definition, FeatureView
71+
):
72+
feature_ref = FeatureViewProjection(
73+
definition.name, definition.features
74+
)
75+
else:
76+
feature_ref = definition
77+
78+
spec.features.append(feature_ref.to_proto())
79+
80+
feature_service_proto = FeatureServiceProto(spec=spec, meta=meta)
81+
return feature_service_proto
82+
83+
def validate(self):
84+
pass

‎sdk/python/feast/feature_store.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,11 @@ def apply(
229229
update_entities_with_inferred_types_from_feature_views(
230230
entities_to_update, views_to_update, self.config
231231
)
232+
232233
update_data_sources_with_inferred_event_timestamp_col(
233234
[view.input for view in views_to_update], self.config
234235
)
236+
235237
for view in views_to_update:
236238
view.infer_features_from_input_source(self.config)
237239

‎sdk/python/feast/feature_view.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from feast.data_source import DataSource
2424
from feast.errors import RegistryInferenceFailure
2525
from feast.feature import Feature
26+
from feast.feature_view_projection import FeatureViewProjection
2627
from feast.protos.feast.core.FeatureView_pb2 import FeatureView as FeatureViewProto
2728
from feast.protos.feast.core.FeatureView_pb2 import (
2829
FeatureViewMeta as FeatureViewMetaProto,
@@ -110,6 +111,16 @@ def __str__(self):
110111
def __hash__(self):
111112
return hash(self.name)
112113

114+
def __getitem__(self, item) -> FeatureViewProjection:
115+
assert isinstance(item, list)
116+
117+
referenced_features = []
118+
for feature in self.features:
119+
if feature.name in item:
120+
referenced_features.append(feature)
121+
122+
return FeatureViewProjection(self.name, referenced_features)
123+
113124
def __eq__(self, other):
114125
if not isinstance(other, FeatureView):
115126
raise TypeError(
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from typing import List
2+
3+
from attr import dataclass
4+
5+
from feast.feature import Feature
6+
from feast.protos.feast.core.FeatureViewProjection_pb2 import (
7+
FeatureViewProjection as FeatureViewProjectionProto,
8+
)
9+
10+
11+
@dataclass
12+
class FeatureViewProjection:
13+
name: str
14+
features: List[Feature]
15+
16+
def to_proto(self):
17+
feature_reference_proto = FeatureViewProjectionProto(
18+
feature_view_name=self.name
19+
)
20+
for feature in self.features:
21+
feature_reference_proto.feature_columns.append(feature.to_proto())
22+
23+
return feature_reference_proto
24+
25+
@staticmethod
26+
def from_proto(proto: FeatureViewProjectionProto):
27+
ref = FeatureViewProjection(name=proto.feature_view_name, features=[])
28+
for feature_column in proto.feature_columns:
29+
ref.features.append(Feature.from_proto(feature_column))
30+
31+
return ref
32+
33+
@staticmethod
34+
def from_definition(feature_definition):
35+
return FeatureViewProjection(
36+
name=feature_definition.name, features=feature_definition.features
37+
)

‎sdk/python/feast/infra/offline_stores/redshift.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ def get_historical_features(
5656
entity_df: Union[pd.DataFrame, str],
5757
registry: Registry,
5858
project: str,
59-
full_feature_names: bool = True,
59+
full_feature_names: bool = False,
6060
) -> RetrievalJob:
6161
pass

‎sdk/python/tests/test_historical_retrieval.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ def get_expected_training_df(
204204
expected_df = expected_df[[event_timestamp] + current_cols]
205205

206206
# Cast some columns to expected types, since we lose information when converting pandas DFs into Python objects.
207-
208207
if full_feature_names:
209208
expected_column_types = {
210209
"order_is_success": "int32",

‎sdk/python/tests/test_offline_online_store_consistency.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ def check_offline_and_online_features(
269269
assert math.isnan(df.to_dict()["value"][0])
270270

271271

272+
272273
def run_offline_online_store_consistency_test(
273274
fs: FeatureStore, fv: FeatureView, full_feature_names: bool
274275
) -> None:
@@ -347,7 +348,7 @@ def test_dynamodb_offline_online_store_consistency(full_feature_names: bool):
347348
with prep_dynamodb_fs_and_fv() as (fs, fv):
348349
run_offline_online_store_consistency_test(fs, fv, full_feature_names)
349350

350-
351+
351352
@pytest.mark.parametrize("full_feature_names", [True, False])
352353
def test_local_offline_online_store_consistency(full_feature_names: bool):
353354
with prep_local_fs_and_fv() as (fs, fv):

0 commit comments

Comments
 (0)