-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Offline push endpoint for pushing to offline stores (#2837)
* Skaffolding for offline store push Signed-off-by: Kevin Zhang <[email protected]> * LInt Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * File source offline push Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Address review comments Signed-off-by: Kevin Zhang <[email protected]> * Add redshift function Signed-off-by: Kevin Zhang <[email protected]> * Add redshift Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Lint Signed-off-by: Kevin Zhang <[email protected]> * fix Signed-off-by: Kevin Zhang <[email protected]> * fix Signed-off-by: Kevin Zhang <[email protected]> * Fix test Signed-off-by: Kevin Zhang <[email protected]> * Fix test Signed-off-by: Kevin Zhang <[email protected]> * Fix test Signed-off-by: Kevin Zhang <[email protected]> * Fix interface Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Update Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Fix rebase Signed-off-by: Kevin Zhang <[email protected]> * Fix naming Signed-off-by: Kevin Zhang <[email protected]> * Fix Signed-off-by: Kevin Zhang <[email protected]> * Uncomment Signed-off-by: Kevin Zhang <[email protected]>
- Loading branch information
Showing
7 changed files
with
113 additions
and
12 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
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
67 changes: 67 additions & 0 deletions
67
sdk/python/tests/integration/offline_store/test_push_offline_retrieval.py
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,67 @@ | ||
import datetime | ||
|
||
import numpy as np | ||
import pandas as pd | ||
import pytest | ||
|
||
from feast.data_source import PushMode | ||
from tests.integration.feature_repos.repo_configuration import ( | ||
construct_universal_feature_views, | ||
) | ||
from tests.integration.feature_repos.universal.entities import ( | ||
customer, | ||
driver, | ||
location, | ||
) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.universal_offline_stores(only=["file", "redshift"]) | ||
@pytest.mark.universal_online_stores(only=["sqlite"]) | ||
def test_push_features_and_read_from_offline_store(environment, universal_data_sources): | ||
store = environment.feature_store | ||
|
||
(_, _, data_sources) = universal_data_sources | ||
feature_views = construct_universal_feature_views(data_sources) | ||
now = pd.Timestamp(datetime.datetime.utcnow()).round("ms") | ||
|
||
store.apply([driver(), customer(), location(), *feature_views.values()]) | ||
entity_df = pd.DataFrame.from_dict({"location_id": [1], "event_timestamp": [now]}) | ||
|
||
before_df = store.get_historical_features( | ||
entity_df=entity_df, | ||
features=["pushable_location_stats:temperature"], | ||
full_feature_names=False, | ||
).to_df() | ||
|
||
data = { | ||
"event_timestamp": [now], | ||
"location_id": [1], | ||
"temperature": [4], | ||
"created": [now], | ||
} | ||
df_ingest = pd.DataFrame(data) | ||
assert np.where( | ||
before_df["location_id"].reset_index(drop=True) | ||
== df_ingest["location_id"].reset_index(drop=True) | ||
) | ||
assert np.where( | ||
before_df["temperature"].reset_index(drop=True) | ||
!= df_ingest["temperature"].reset_index(drop=True) | ||
) | ||
|
||
store.push("location_stats_push_source", df_ingest, to=PushMode.OFFLINE) | ||
|
||
df = store.get_historical_features( | ||
entity_df=entity_df, | ||
features=["pushable_location_stats:temperature"], | ||
full_feature_names=False, | ||
).to_df() | ||
assert np.where( | ||
df["location_id"].reset_index(drop=True) | ||
== df_ingest["location_id"].reset_index(drop=True) | ||
) | ||
assert np.where( | ||
df["temperature"].reset_index(drop=True) | ||
== df_ingest["temperature"].reset_index(drop=True) | ||
) |