forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add mysql as online store (feast-dev#3190)
* update remove debug Signed-off-by: hao-affirm <[email protected]> * add interface Signed-off-by: hao-affirm <[email protected]> * fix lint Signed-off-by: hao-affirm <[email protected]> * fix lint Signed-off-by: hao-affirm <[email protected]> * update sql Signed-off-by: hao-affirm <[email protected]> * update ci reqs Signed-off-by: hao-affirm <[email protected]> * remove pip index Signed-off-by: hao-affirm <[email protected]> * format Signed-off-by: hao-affirm <[email protected]> * fix unit test issue Signed-off-by: hao-affirm <[email protected]> * fix lint issue Signed-off-by: hao-affirm <[email protected]> * add entity_key_serialization_version Signed-off-by: hao-affirm <[email protected]> * update doc Signed-off-by: hao-affirm <[email protected]> * format Signed-off-by: hao-affirm <[email protected]> * format Signed-off-by: hao-affirm <[email protected]> * fix makefile typo Signed-off-by: hao-affirm <[email protected]> * move to func Signed-off-by: hao-affirm <[email protected]> * format Signed-off-by: hao-affirm <[email protected]> Signed-off-by: hao-affirm <[email protected]>
- Loading branch information
1 parent
a2dc0d0
commit cb8db84
Showing
16 changed files
with
473 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# MySQL online store (contrib) | ||
|
||
## Description | ||
|
||
The MySQL online store provides support for materializing feature values into a MySQL database for serving online features. | ||
|
||
* Only the latest feature values are persisted | ||
|
||
|
||
## Example | ||
|
||
{% code title="feature_store.yaml" %} | ||
```yaml | ||
project: my_feature_repo | ||
registry: data/registry.db | ||
provider: local | ||
online_store: | ||
type: mysql | ||
host: DB_HOST | ||
port: DB_PORT | ||
database: DB_NAME | ||
user: DB_USERNAME | ||
password: DB_PASSWORD | ||
``` | ||
{% endcode %} | ||
The full set of configuration options is available in [MySQLOnlineStoreConfig](https://rtd.feast.dev/en/master/#feast.infra.online_stores.contrib.mysql.MySQLOnlineStoreConfig). | ||
## Functionality Matrix | ||
The set of functionality supported by online stores is described in detail [here](overview.md#functionality). | ||
Below is a matrix indicating which functionality is supported by the Mys online store. | ||
| | Mys | | ||
| :-------------------------------------------------------- | :-- | | ||
| write feature values to the online store | yes | | ||
| read feature values from the online store | yes | | ||
| update infrastructure (e.g. tables) in the online store | yes | | ||
| teardown infrastructure (e.g. tables) in the online store | yes | | ||
| generate a plan of infrastructure changes | no | | ||
| support for on-demand transforms | yes | | ||
| readable by Python SDK | yes | | ||
| readable by Java | no | | ||
| readable by Go | no | | ||
| support for entityless feature views | yes | | ||
| support for concurrent writing to the same key | no | | ||
| support for ttl (time to live) at retrieval | no | | ||
| support for deleting expired data | no | | ||
| collocated by feature view | yes | | ||
| collocated by feature service | no | | ||
| collocated by entity key | no | | ||
To compare this set of functionality against other online stores, please see the full [functionality matrix](overview.md#functionality-matrix). |
21 changes: 21 additions & 0 deletions
21
sdk/python/docs/source/feast.infra.online_stores.contrib.mysql_online_store.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
feast.infra.online\_stores.contrib.mysql\_online\_store package | ||
=============================================================== | ||
|
||
Submodules | ||
---------- | ||
|
||
feast.infra.online\_stores.contrib.mysql\_online\_store.mysql module | ||
-------------------------------------------------------------------- | ||
|
||
.. automodule:: feast.infra.online_stores.contrib.mysql_online_store.mysql | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: feast.infra.online_stores.contrib.mysql_online_store | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
sdk/python/feast/infra/online_stores/contrib/mysql_online_store/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Mysql Online Store | ||
Mysql is not included in current [Feast](https://github.com/feast-dev/feast) roadmap, this project intends to add Mysql support for Online Store. | ||
We create a table <project_name>_<feature_view_name> which gets updated with data on every materialize call | ||
|
||
|
||
#### Create a feature repository | ||
|
||
```shell | ||
feast init feature_repo | ||
cd feature_repo | ||
``` | ||
|
||
#### Edit `feature_store.yaml` | ||
|
||
set `online_store` type to be `mysql` | ||
|
||
```yaml | ||
project: feature_repo | ||
registry: data/registry.db | ||
provider: local | ||
online_store: | ||
type: mysql | ||
host: 127.0.0.1 # mysql endpoint, default to 127.0.0.1 | ||
port: 3306 # mysql port, default to 3306 | ||
user: test # mysql user, default to test | ||
password: test # mysql password, default to test | ||
database: feast # mysql database, default to feast | ||
``` | ||
#### Apply the feature definitions in `example.py` | ||
|
||
```shell | ||
feast -c feature_repo apply | ||
``` | ||
##### Output | ||
``` | ||
Registered entity driver_id | ||
Registered feature view driver_hourly_stats_view | ||
Deploying infrastructure for driver_hourly_stats_view | ||
``` | ||
### Materialize Latest Data to Online Feature Store (Mysql) | ||
``` | ||
$ CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S") | ||
$ feast -c feature_repo materialize-incremental $CURRENT_TIME | ||
``` | ||
#### Output | ||
``` | ||
Materializing 1 feature views from 2022-04-16 15:30:39+05:30 to 2022-04-19 15:31:04+05:30 into the mysql online store. | ||
|
||
driver_hourly_stats_view from 2022-04-16 15:30:39+05:30 to 2022-04-19 15:31:04+05:30: | ||
100%|████████████████████████████████████████████████████████████████| 5/5 [00:00<00:00, 120.59it/s] | ||
``` | ||
### Fetch the latest features for some entity id | ||
```python | ||
from pprint import pprint | ||
from feast import FeatureStore | ||
store = FeatureStore(repo_path=".") | ||
feature_vector = store.get_online_features( | ||
features=[ | ||
"driver_hourly_stats:conv_rate", | ||
"driver_hourly_stats:acc_rate", | ||
"driver_hourly_stats:avg_daily_trips", | ||
], | ||
entity_rows=[ | ||
{"driver_id": 1004}, | ||
{"driver_id": 1005}, | ||
], | ||
).to_dict() | ||
pprint(feature_vector) | ||
``` | ||
#### Output | ||
``` | ||
{'acc_rate': [0.01390857808291912, 0.4063614010810852], | ||
'avg_daily_trips': [69, 706], | ||
'conv_rate': [0.6624961495399475, 0.7595928311347961], | ||
'driver_id': [1004, 1005]} | ||
``` |
Empty file.
Oops, something went wrong.