|
| 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 | + |
0 commit comments