-
Notifications
You must be signed in to change notification settings - Fork 996
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix on demand feature view crash from inference when it uses df.…
…apply (#2713) * fix: Fix on demand feature view crash from inference when transformation uses df.apply Signed-off-by: Danny Chiao <danny@tecton.ai> * Fix inference Signed-off-by: Danny Chiao <danny@tecton.ai> * Fix test Signed-off-by: Danny Chiao <danny@tecton.ai>
- Loading branch information
Showing
4 changed files
with
168 additions
and
3 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
48 changes: 48 additions & 0 deletions
48
sdk/python/tests/example_repos/on_demand_feature_view_repo.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,48 @@ | ||
from datetime import timedelta | ||
|
||
import pandas as pd | ||
|
||
from feast import FeatureView, Field, FileSource | ||
from feast.on_demand_feature_view import on_demand_feature_view | ||
from feast.types import Float32, String | ||
|
||
driver_stats = FileSource( | ||
name="driver_stats_source", | ||
path="data/driver_stats_lat_lon.parquet", | ||
timestamp_field="event_timestamp", | ||
created_timestamp_column="created", | ||
description="A table describing the stats of a driver based on hourly logs", | ||
owner="test2@gmail.com", | ||
) | ||
|
||
driver_daily_features_view = FeatureView( | ||
name="driver_daily_features", | ||
entities=["driver"], | ||
ttl=timedelta(seconds=8640000000), | ||
schema=[ | ||
Field(name="daily_miles_driven", dtype=Float32), | ||
Field(name="lat", dtype=Float32), | ||
Field(name="lon", dtype=Float32), | ||
Field(name="string_feature", dtype=String), | ||
], | ||
online=True, | ||
source=driver_stats, | ||
tags={"production": "True"}, | ||
owner="test2@gmail.com", | ||
) | ||
|
||
|
||
@on_demand_feature_view( | ||
sources=[driver_daily_features_view], | ||
schema=[ | ||
Field(name="first_char", dtype=String), | ||
Field(name="concat_string", dtype=String), | ||
], | ||
) | ||
def location_features_from_push(inputs: pd.DataFrame) -> pd.DataFrame: | ||
df = pd.DataFrame() | ||
df["concat_string"] = inputs.apply( | ||
lambda x: x.string_feature + "hello", axis=1 | ||
).astype("string") | ||
df["first_char"] = inputs["string_feature"].str[:1].astype("string") | ||
return df |
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