Skip to content

Commit 7dff49a

Browse files
achalswoop
andauthored
Allow specifying FeatureServices in FeatureStore methods (feast-dev#1691)
* Allow specifying FeatureServices in FeatureStore methods Signed-off-by: Achal Shah <achals@gmail.com> * format and lint Signed-off-by: Achal Shah <achals@gmail.com> * features_refs -> features Signed-off-by: Achal Shah <achals@gmail.com> * remote type: ignores Signed-off-by: Achal Shah <achals@gmail.com> * implement applying and persisting feature services into registry Signed-off-by: Achal Shah <achals@gmail.com> * Fix integration test references Signed-off-by: Achal Shah <achals@gmail.com> * Add backwards compatibility Signed-off-by: Achal Shah <achals@gmail.com> * More lint Signed-off-by: Achal Shah <achals@gmail.com> * add integration tests Signed-off-by: Achal Shah <achals@gmail.com> * refactor and lint Signed-off-by: Achal Shah <achals@gmail.com> * More tests Signed-off-by: Achal Shah <achals@gmail.com> * Add cli commands Signed-off-by: Achal Shah <achals@gmail.com> * Update sdk/python/feast/feature_store.py Co-authored-by: Willem Pienaar <6728866+woop@users.noreply.github.com> Signed-off-by: Achal Shah <achals@gmail.com> * Update sdk/python/feast/feature_store.py Co-authored-by: Willem Pienaar <6728866+woop@users.noreply.github.com> Signed-off-by: Achal Shah <achals@gmail.com> * Update sdk/python/feast/feature_store.py Co-authored-by: Willem Pienaar <6728866+woop@users.noreply.github.com> Signed-off-by: Achal Shah <achals@gmail.com> * Update sdk/python/feast/feature_store.py Co-authored-by: Willem Pienaar <6728866+woop@users.noreply.github.com> Signed-off-by: Achal Shah <achals@gmail.com> * Update tests to use file offline source Signed-off-by: Achal Shah <achals@gmail.com> * Make tests integration and lint Signed-off-by: Achal Shah <achals@gmail.com> * Retrieve feature services to avoid stale references Signed-off-by: Achal Shah <achals@gmail.com> * Fix lint Signed-off-by: Achal Shah <achals@gmail.com> * Merge master into branch Signed-off-by: Achal Shah <achals@gmail.com> * fix tests Signed-off-by: Achal Shah <achals@gmail.com> * fix import Signed-off-by: Achal Shah <achals@gmail.com> * fix integ tests Signed-off-by: Achal Shah <achals@gmail.com> * CR Signed-off-by: Achal Shah <achals@gmail.com> * format Signed-off-by: Achal Shah <achals@gmail.com> * Fix integ test Signed-off-by: Achal Shah <achals@gmail.com> * Fix integ test Signed-off-by: Achal Shah <achals@gmail.com> * Rename in comments Signed-off-by: Achal Shah <achals@gmail.com> * Docstrings for Feature Services Signed-off-by: Achal Shah <achals@gmail.com> * make format Signed-off-by: Achal Shah <achals@gmail.com> * format and refactor Signed-off-by: Achal Shah <achals@gmail.com> * docs and updates Signed-off-by: Achal Shah <achals@gmail.com> * Update docs/concepts/feature-service.md Co-authored-by: Willem Pienaar <6728866+woop@users.noreply.github.com> Signed-off-by: Achal Shah <achals@gmail.com> * Update sdk/python/feast/feature_service.py Co-authored-by: Willem Pienaar <6728866+woop@users.noreply.github.com> Signed-off-by: Achal Shah <achals@gmail.com> * Update sdk/python/feast/feature_service.py Co-authored-by: Willem Pienaar <6728866+woop@users.noreply.github.com> Signed-off-by: Achal Shah <achals@gmail.com> * docs docs docs Signed-off-by: Achal Shah <achals@gmail.com> * docs docs Signed-off-by: Achal Shah <achals@gmail.com> * Fixes after merge Signed-off-by: Achal Shah <achals@gmail.com> * Remove dupe Signed-off-by: Achal Shah <achals@gmail.com> * Renames and deletions Signed-off-by: Achal Shah <achals@gmail.com> * lint Signed-off-by: Achal Shah <achals@gmail.com> * format and tests Signed-off-by: Achal Shah <achals@gmail.com> * remove unused imports Signed-off-by: Achal Shah <achals@gmail.com> * fix registry Signed-off-by: Achal Shah <achals@gmail.com> * fix docs Signed-off-by: Achal Shah <achals@gmail.com> * fix dangling print Signed-off-by: Achal Shah <achals@gmail.com> * make format and lint Signed-off-by: Achal Shah <achals@gmail.com> * list feature servces Signed-off-by: Achal Shah <achals@gmail.com> * fix tests Signed-off-by: Achal Shah <achals@gmail.com> * Remove unused file Signed-off-by: Achal Shah <achals@gmail.com> * single heading Signed-off-by: Achal Shah <achals@gmail.com> Co-authored-by: Willem Pienaar <6728866+woop@users.noreply.github.com>
1 parent 5c7c240 commit 7dff49a

28 files changed

Lines changed: 567 additions & 85 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ store = FeatureStore(repo_path=".")
6262

6363
training_df = store.get_historical_features(
6464
entity_df=entity_df,
65-
feature_refs = [
65+
features = [
6666
'driver_hourly_stats:conv_rate',
6767
'driver_hourly_stats:acc_rate',
6868
'driver_hourly_stats:avg_daily_trips'
@@ -101,7 +101,7 @@ from feast import FeatureStore
101101
store = FeatureStore(repo_path=".")
102102

103103
feature_vector = store.get_online_features(
104-
feature_refs=[
104+
features=[
105105
'driver_hourly_stats:conv_rate',
106106
'driver_hourly_stats:acc_rate',
107107
'driver_hourly_stats:avg_daily_trips'

docs/concepts/data-model-and-concepts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Feature references are used for the retrieval of features from Feast:
1616

1717
```python
1818
online_features = fs.get_online_features(
19-
feature_refs=[
19+
features=[
2020
'driver_locations:lon',
2121
'drivers_activity:trips_today'
2222
],
@@ -53,7 +53,7 @@ A collection of entity rows. Entity dataframes are the "left table" that is enri
5353
```python
5454
training_df = store.get_historical_features(
5555
entity_df=entity_df,
56-
feature_refs = [
56+
features = [
5757
'drivers_activity:trips_today'
5858
'drivers_activity:rating'
5959
],

docs/concepts/feature-service.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Feature Service
2+
3+
A feature service is an object that represents a logical group of features from one or more [feature views](feature-view.md).
4+
Feature Services allows features from within a feature view to be used as needed by an ML model. Users can expect to create one feature service per model, allowing for tracking of the features used by models.
5+
6+
{% tabs %}
7+
{% tab title="driver\_trips\_feature\_service.py" %}
8+
```python
9+
from driver_ratings_feature_view import driver_ratings_fv
10+
from driver_trips_feature_view import driver_stats_fv
11+
12+
driver_stats_fs = FeatureService(
13+
name="driver_activity",
14+
features=[driver_stats_fv, driver_ratings_fv[["lifetime_rating"]]]
15+
)
16+
```
17+
{% endtab %}
18+
{% endtabs %}
19+
20+
Feature services are used during
21+
22+
* The generation of training datasets when querying feature views in order to find historical feature values. A single training dataset may consist of features from multiple feature views.
23+
* Retrieval of features from the online store. The features retrieved from the online store may also belong to multiple feature views.
24+
25+
{% hint style="info" %}
26+
Applying a feature service does not result in an actual service being deployed.
27+
{% endhint %}

docs/feast-on-kubernetes/user-guide/getting-training-features.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Below is an example of the process required to produce a training dataset:
88

99
```python
1010
# Feature references with target feature
11-
feature_refs = [
11+
features = [
1212
"driver_trips:average_daily_rides",
1313
"driver_trips:maximum_daily_rides",
1414
"driver_trips:rating",
@@ -24,7 +24,7 @@ entity_source = FileSource(
2424

2525
# Retrieve historical dataset from Feast.
2626
historical_feature_retrieval_job = client.get_historical_features(
27-
feature_refs=feature_refs,
27+
features=features,
2828
entity_rows=entity_source
2929
)
3030

docs/getting-started/build-a-training-dataset.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ from feast import FeatureStore
6161
fs = FeatureStore(repo_path="path/to/your/feature/repo")
6262

6363
training_df = fs.get_historical_features(
64-
feature_refs=[
64+
features=[
6565
"driver_hourly_stats:conv_rate",
6666
"driver_hourly_stats:acc_rate"
6767
],

docs/getting-started/read-features-from-the-online-store.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Please ensure that you have materialized \(loaded\) your feature values into the
1919
Create a list of features that you would like to retrieve. This list typically comes from the model training step and should accompany the model binary.
2020

2121
```python
22-
feature_refs = [
22+
features = [
2323
"driver_hourly_stats:conv_rate",
2424
"driver_hourly_stats:acc_rate"
2525
]
@@ -32,7 +32,7 @@ Next, we will create a feature store object and call `get_online_features()` whi
3232
```python
3333
fs = FeatureStore(repo_path="path/to/feature/repo")
3434
online_features = fs.get_online_features(
35-
feature_refs=feature_refs,
35+
features=features,
3636
entity_rows=[
3737
{"driver_id": 1001},
3838
{"driver_id": 1002}]

docs/quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ store = FeatureStore(repo_path=".")
6969

7070
training_df = store.get_historical_features(
7171
entity_df=entity_df,
72-
feature_refs=[
72+
features=[
7373
"driver_hourly_stats:conv_rate",
7474
"driver_hourly_stats:acc_rate",
7575
"driver_hourly_stats:avg_daily_trips",
@@ -105,7 +105,7 @@ from feast import FeatureStore
105105
store = FeatureStore(repo_path=".")
106106

107107
feature_vector = store.get_online_features(
108-
feature_refs=[
108+
features=[
109109
"driver_hourly_stats:conv_rate",
110110
"driver_hourly_stats:acc_rate",
111111
"driver_hourly_stats:avg_daily_trips",

docs/user-guide/getting-training-features.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Below is an example of the process required to produce a training dataset:
88

99
```python
1010
# Feature references with target feature
11-
feature_refs = [
11+
features = [
1212
"driver_trips:average_daily_rides",
1313
"driver_trips:maximum_daily_rides",
1414
"driver_trips:rating",
@@ -24,7 +24,7 @@ entity_source = FileSource(
2424

2525
# Retrieve historical dataset from Feast.
2626
historical_feature_retrieval_job = client.get_historical_features(
27-
feature_refs=feature_refs,
27+
features=features,
2828
entity_rows=entity_source
2929
)
3030

protos/feast/core/Registry.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ option java_outer_classname = "RegistryProto";
2222
option go_package = "github.com/feast-dev/feast/sdk/go/protos/feast/core";
2323

2424
import "feast/core/Entity.proto";
25+
import "feast/core/FeatureService.proto";
2526
import "feast/core/FeatureTable.proto";
2627
import "feast/core/FeatureView.proto";
2728
import "google/protobuf/timestamp.proto";
@@ -30,8 +31,10 @@ message Registry {
3031
repeated Entity entities = 1;
3132
repeated FeatureTable feature_tables = 2;
3233
repeated FeatureView feature_views = 6;
34+
repeated FeatureService feature_services = 7;
3335

3436
string registry_schema_version = 3; // to support migrations; incremented when schema is changed
3537
string version_id = 4; // version id, random string generated on each update of the data; now used only for debugging purposes
3638
google.protobuf.Timestamp last_updated = 5;
39+
3740
}

sdk/python/feast/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .data_source import KafkaSource, KinesisSource, SourceType
1111
from .entity import Entity
1212
from .feature import Feature
13+
from .feature_service import FeatureService
1314
from .feature_store import FeatureStore
1415
from .feature_table import FeatureTable
1516
from .feature_view import FeatureView
@@ -34,6 +35,7 @@
3435
"KafkaSource",
3536
"KinesisSource",
3637
"Feature",
38+
"FeatureService",
3739
"FeatureStore",
3840
"FeatureTable",
3941
"FeatureView",

0 commit comments

Comments
 (0)