-
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.
chore: Remove gcp requirement for local tests (#2972)
* Remove unused objects Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Switch from bigquery to file sources Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Switch tests using example_feature_repo_1 to use file offline store Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Disable tests that require gcp Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Remove duplicate test Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Remove integration marker Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix snowflake config Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix import Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Add empty feature repo Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix comments Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Add new example feature repo Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Add new feature repo with just feature service Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Move tests from integration to unit Signed-off-by: Felix Wang <wangfelix98@gmail.com>
- Loading branch information
1 parent
651ce34
commit c611eb8
Showing
15 changed files
with
298 additions
and
276 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This example feature repo is deliberately left empty. It should be used for tests that do not need | ||
# any feature views or other objects (for example, a test that checks that a feature service can be | ||
# applied and retrieved correctly). |
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
30 changes: 30 additions & 0 deletions
30
sdk/python/tests/example_repos/example_feature_repo_with_driver_stats_feature_view.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,30 @@ | ||
from datetime import timedelta | ||
|
||
from feast import Entity, FeatureView, Field, FileSource | ||
from feast.types import Float32, Int32, Int64 | ||
|
||
driver_hourly_stats = FileSource( | ||
path="data/driver_stats.parquet", # Fake path | ||
timestamp_field="event_timestamp", | ||
created_timestamp_column="created", | ||
) | ||
|
||
driver = Entity( | ||
name="driver_id", | ||
description="driver id", | ||
) | ||
|
||
driver_hourly_stats_view = FeatureView( | ||
name="driver_hourly_stats", | ||
entities=[driver], | ||
ttl=timedelta(days=1), | ||
schema=[ | ||
Field(name="conv_rate", dtype=Float32), | ||
Field(name="acc_rate", dtype=Float32), | ||
Field(name="avg_daily_trips", dtype=Int64), | ||
Field(name="driver_id", dtype=Int32), | ||
], | ||
online=True, | ||
source=driver_hourly_stats, | ||
tags={}, | ||
) |
36 changes: 36 additions & 0 deletions
36
sdk/python/tests/example_repos/example_feature_repo_with_feature_service.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,36 @@ | ||
from datetime import timedelta | ||
|
||
from feast import Entity, FeatureService, FeatureView, Field, FileSource | ||
from feast.types import Float32, Int64, String | ||
|
||
driver_locations_source = FileSource( | ||
path="data/driver_locations.parquet", | ||
timestamp_field="event_timestamp", | ||
created_timestamp_column="created_timestamp", | ||
) | ||
|
||
driver = Entity( | ||
name="driver", # The name is derived from this argument, not object name. | ||
join_keys=["driver_id"], | ||
description="driver id", | ||
) | ||
|
||
driver_locations = FeatureView( | ||
name="driver_locations", | ||
entities=[driver], | ||
ttl=timedelta(days=1), | ||
schema=[ | ||
Field(name="lat", dtype=Float32), | ||
Field(name="lon", dtype=String), | ||
Field(name="driver_id", dtype=Int64), | ||
], | ||
online=True, | ||
batch_source=driver_locations_source, | ||
tags={}, | ||
) | ||
|
||
all_drivers_feature_service = FeatureService( | ||
name="driver_locations_service", | ||
features=[driver_locations], | ||
tags={"release": "production"}, | ||
) |
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
25 changes: 25 additions & 0 deletions
25
sdk/python/tests/unit/local_feast_tests/test_feature_service_apply.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,25 @@ | ||
from feast.feature_service import FeatureService | ||
from tests.utils.cli_repo_creator import CliRunner, get_example_repo | ||
|
||
|
||
def test_read_pre_applied() -> None: | ||
""" | ||
Read feature values from the FeatureStore using a FeatureService. | ||
""" | ||
runner = CliRunner() | ||
with runner.local_repo( | ||
get_example_repo("example_feature_repo_with_feature_service.py"), "file" | ||
) as store: | ||
assert len(store.list_feature_services()) == 1 | ||
fs = store.get_feature_service("driver_locations_service") | ||
assert len(fs.tags) == 1 | ||
assert fs.tags["release"] == "production" | ||
|
||
fv = store.get_feature_view("driver_locations") | ||
|
||
fs = FeatureService(name="new_feature_service", features=[fv[["lon"]]]) | ||
|
||
store.apply([fs]) | ||
|
||
assert len(store.list_feature_services()) == 2 | ||
store.get_feature_service("new_feature_service") |
Oops, something went wrong.