Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding mode='python' for get_historical_features on ODFVs #4653

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sdk/python/feast/transformation/python_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def __init__(self, udf: FunctionType, udf_string: str = ""):
self.udf_string = udf_string

def transform_arrow(
self, pa_table: pyarrow.Table, features: list[Field]
self,
pa_table: pyarrow.Table,
features: list[Field],
) -> pyarrow.Table:
raise Exception(
'OnDemandFeatureView with mode "python" does not support offline processing.'
)
return pyarrow.Table.from_pydict(self.udf(pa_table.to_pydict()))

def transform(self, input_dict: dict) -> dict:
# Ensuring that the inputs are included as well
Expand Down
18 changes: 18 additions & 0 deletions sdk/python/tests/unit/test_on_demand_python_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,24 @@ def pandas_view(features_df: pd.DataFrame) -> pd.DataFrame:
assert resp is not None
assert resp["conv_rate_plus_val1"].isnull().sum() == 0

batch_sample["avg_daily_trip_rank_thresholds"] = [
[100, 250, 500, 1000]
] * batch_sample.shape[0]
batch_sample["avg_daily_trip_rank_names"] = [
["Bronze", "Silver", "Gold", "Platinum"]
] * batch_sample.shape[0]
resp_python = self.store.get_historical_features(
entity_df=batch_sample,
features=[
"driver_hourly_stats:conv_rate",
"driver_hourly_stats:acc_rate",
"driver_hourly_stats:avg_daily_trips",
"python_view:conv_rate_plus_acc",
],
).to_df()
assert resp_python is not None
assert resp_python["conv_rate_plus_acc"].isnull().sum() == 0

# Now testing feature retrieval for driver ids not in the dataset
missing_batch_sample = pd.DataFrame([1234567890], columns=["driver_id"])
missing_batch_sample["val_to_add"] = 0
Expand Down
Loading