Skip to content

Commit a708915

Browse files
achalsgitbook-bot
authored andcommitted
GitBook: [master] 2 pages modified
1 parent 55eb8cd commit a708915

2 files changed

Lines changed: 107 additions & 0 deletions

File tree

‎docs/SUMMARY.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
* [Getting online features](feast-on-kubernetes/user-guide/getting-online-features.md)
5757
* [Getting training features](feast-on-kubernetes/user-guide/getting-training-features.md)
5858
* [Define and ingest features](feast-on-kubernetes/user-guide/define-and-ingest-features.md)
59+
* [Extending Feast](feast-on-kubernetes/user-guide/extending-feast.md)
5960
* [Reference](feast-on-kubernetes/reference-1/README.md)
6061
* [Configuration Reference](feast-on-kubernetes/reference-1/configuration-reference.md)
6162
* [Feast and Spark](feast-on-kubernetes/reference-1/feast-and-spark.md)
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Extending Feast
2+
3+
## Custom OnlineStore
4+
5+
Feast allow users to create their own OnlineStore implementations, allowing Feast to read and write feature values to stores other than first-party implementations already in Feast directly. The interface for the is found at [here](https://github.com/feast-dev/feast/blob/master/sdk/python/feast/infra/online_stores/online_store.py), and consists of four methods that need to be implemented.
6+
7+
### Update/Teardown methods
8+
9+
The `update` method is should be set up any state in the OnlineStore that is required before any data can be ingested into it. This can be things like tables in sqlite, or keyspaces in Cassandra, etc. The update method should be idempotent. Similarly, the `teardown` method should remove any state in the online store.
10+
11+
```python
12+
def update(
13+
self,
14+
config: RepoConfig,
15+
tables_to_delete: Sequence[Union[FeatureTable, FeatureView]],
16+
tables_to_keep: Sequence[Union[FeatureTable, FeatureView]],
17+
entities_to_delete: Sequence[Entity],
18+
entities_to_keep: Sequence[Entity],
19+
partial: bool,
20+
):
21+
...
22+
23+
def teardown(
24+
self,
25+
config: RepoConfig,
26+
tables: Sequence[Union[FeatureTable, FeatureView]],
27+
entities: Sequence[Entity],
28+
):
29+
...
30+
31+
```
32+
33+
### Write/Read methods
34+
35+
The `online_write_batch` method is responsible for writing the data into the online store - and `online_read` method is responsible for reading data from the online store.
36+
37+
```python
38+
def online_write_batch(
39+
self,
40+
config: RepoConfig,
41+
table: Union[FeatureTable, FeatureView],
42+
data: List[
43+
Tuple[EntityKeyProto, Dict[str, ValueProto], datetime, Optional[datetime]]
44+
],
45+
progress: Optional[Callable[[int], Any]],
46+
) -> None:
47+
48+
...
49+
50+
def online_read(
51+
self,
52+
config: RepoConfig,
53+
table: Union[FeatureTable, FeatureView],
54+
entity_keys: List[EntityKeyProto],
55+
requested_features: Optional[List[str]] = None,
56+
) -> List[Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]]:
57+
...
58+
```
59+
60+
## Custom OfflineStore
61+
62+
Feast allow users to create their own OfflineStore implementations, allowing Feast to read and write feature values to stores other than first-party implementations already in Feast directly. The interface for the is found at [here](https://github.com/feast-dev/feast/blob/master/sdk/python/feast/infra/offline_stores/offline_store.py), and consists of two methods that need to be implemented.
63+
64+
### Write method
65+
66+
The `pull_latest_from_table_or_query` method is used to read data from a source for materialization into the OfflineStore.
67+
68+
```python
69+
def pull_latest_from_table_or_query(
70+
data_source: DataSource,
71+
join_key_columns: List[str],
72+
feature_name_columns: List[str],
73+
event_timestamp_column: str,
74+
created_timestamp_column: Optional[str],
75+
start_date: datetime,
76+
end_date: datetime,
77+
) -> pyarrow.Table:
78+
...
79+
80+
```
81+
82+
### Read method
83+
84+
The read method is responsible for reading historical features from the OfflineStore. The feature retrieval may be asynchronous, so the read method is expected to return an object that should produce a DataFrame representing the historical features once the feature retrieval job is complete.
85+
86+
```python
87+
class RetrievalJob:
88+
89+
@abstractmethod
90+
def to_df(self):
91+
pass
92+
93+
def get_historical_features(
94+
config: RepoConfig,
95+
feature_views: List[FeatureView],
96+
feature_refs: List[str],
97+
entity_df: Union[pd.DataFrame, str],
98+
registry: Registry,
99+
project: str,
100+
) -> RetrievalJob:
101+
pass
102+
103+
```
104+
105+
106+

0 commit comments

Comments
 (0)