Skip to content

Commit eac6c07

Browse files
Ly Caoachals
authored andcommitted
added a simple connector config type to RepoConfig in python sdk to support feast alpha enable go_feature_server
Signed-off-by: Felix Wang <wangfelix98@gmail.com> Signed-off-by: Achal Shah <achals@gmail.com>
1 parent fd27ee1 commit eac6c07

2 files changed

Lines changed: 125 additions & 0 deletions

File tree

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Copyright 2021 The Feast Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from pydantic import StrictStr
16+
from pydantic.typing import Literal
17+
from datetime import datetime
18+
from typing import (
19+
Any,
20+
ByteString,
21+
Callable,
22+
Dict,
23+
List,
24+
Optional,
25+
Sequence,
26+
Tuple,
27+
Union,
28+
)
29+
30+
from google.protobuf.timestamp_pb2 import Timestamp
31+
from pydantic import StrictStr
32+
from pydantic.typing import Literal
33+
34+
from feast import Entity, FeatureView, RepoConfig
35+
from feast.protos.feast.types.EntityKey_pb2 import EntityKey as EntityKeyProto
36+
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
37+
from feast.infra.infra_object import InfraObject
38+
from feast.protos.feast.core.Registry_pb2 import Registry as RegistryProto
39+
40+
from feast.repo_config import FeastConfigBaseModel
41+
from feast.infra.online_stores.online_store import OnlineStore
42+
43+
class ConnectorOnlineStoreConfig(FeastConfigBaseModel):
44+
"""Online store config for Connector store"""
45+
46+
type: Literal["connector"] = "connector"
47+
"""Online store type selector"""
48+
49+
KV_PLUGIN: StrictStr = "./dist/plugin"
50+
"""KV_PLUGIN contains the command to run binary file"""
51+
52+
53+
class ConnectorOnlineStore(OnlineStore):
54+
55+
"""
56+
OnlineStore is an object used for all interaction between Feast and the service used for online storage of
57+
features.
58+
"""
59+
def online_write_batch(
60+
self,
61+
config: RepoConfig,
62+
table: FeatureView,
63+
data: List[
64+
Tuple[EntityKeyProto, Dict[str, ValueProto], datetime, Optional[datetime]]
65+
],
66+
progress: Optional[Callable[[int], Any]],
67+
) -> None:
68+
"""
69+
Write a batch of feature rows to the online store. This is a low level interface, not
70+
expected to be used by the users directly.
71+
72+
If a tz-naive timestamp is passed to this method, it should be assumed to be UTC by implementors.
73+
74+
Args:
75+
config: The RepoConfig for the current FeatureStore.
76+
table: Feast FeatureView
77+
data: a list of quadruplets containing Feature data. Each quadruplet contains an Entity Key,
78+
a dict containing feature values, an event timestamp for the row, and
79+
the created timestamp for the row if it exists.
80+
progress: Optional function to be called once every mini-batch of rows is written to
81+
the online store. Can be used to display progress.
82+
"""
83+
pass
84+
85+
def online_read(
86+
self,
87+
config: RepoConfig,
88+
table: FeatureView,
89+
entity_keys: List[EntityKeyProto],
90+
requested_features: Optional[List[str]] = None,
91+
) -> List[Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]]:
92+
pass
93+
94+
def update(
95+
self,
96+
config: RepoConfig,
97+
tables_to_delete: Sequence[FeatureView],
98+
tables_to_keep: Sequence[FeatureView],
99+
entities_to_delete: Sequence[Entity],
100+
entities_to_keep: Sequence[Entity],
101+
partial: bool,
102+
):
103+
pass
104+
105+
def plan(
106+
self, config: RepoConfig, desired_registry_proto: RegistryProto
107+
) -> List[InfraObject]:
108+
"""
109+
Returns the set of InfraObjects required to support the desired registry.
110+
111+
Args:
112+
config: The RepoConfig for the current FeatureStore.
113+
desired_registry_proto: The desired registry, in proto form.
114+
"""
115+
return []
116+
117+
def teardown(
118+
self,
119+
config: RepoConfig,
120+
tables: Sequence[FeatureView],
121+
entities: Sequence[Entity],
122+
):
123+
pass
124+

sdk/python/feast/repo_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"redis": "feast.infra.online_stores.redis.RedisOnlineStore",
3333
"dynamodb": "feast.infra.online_stores.dynamodb.DynamoDBOnlineStore",
3434
"snowflake.online": "feast.infra.online_stores.snowflake.SnowflakeOnlineStore",
35+
"connector": "feast.infra.online_stores.connector.ConnectorOnlineStore",
3536
}
3637

3738
OFFLINE_STORE_CLASS_FOR_TYPE = {

0 commit comments

Comments
 (0)