Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added a test to make it explicit that feature calculation must happen…
… on a list

Signed-off-by: Francisco Javier Arceo <franciscojavierarceo@users.noreply.github.com>
  • Loading branch information
franciscojavierarceo committed Apr 4, 2024
commit 255ba05c7218a27a6685971bcb4b1c0e7d4390ba
Binary file removed sdk/python/tests/data/driver_hourly_stats.parquet
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file necessary? looks like it should be auto-generated during tests in a temp folder

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good catch I didn't mean to check this in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binary files in a tests folder are scary these days lol 😄

Binary file not shown.
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 @@ -5,6 +5,7 @@
from typing import Any, Dict

import pandas as pd
import pytest

from feast import Entity, FeatureStore, FeatureView, FileSource, RepoConfig
from feast.driver_test_data import create_driver_hourly_stats_df
Expand Down Expand Up @@ -88,6 +89,23 @@ def python_view(inputs: Dict[str, Any]) -> Dict[str, Any]:
)
return output

@on_demand_feature_view(
sources=[driver_stats_fv[["conv_rate", "acc_rate"]]],
schema=[Field(name="conv_rate_plus_acc_python_singleton", dtype=Float64)],
mode="python",
)
def python_singleton_view(inputs: Dict[str, Any]) -> Dict[str, Any]:
output: Dict[str, Any] = dict(conv_rate_plus_acc_python=float('-inf'))
output["conv_rate_plus_acc_python_singleton"] = inputs["conv_rate"] + inputs["acc_rate"]
return output

with pytest.raises(TypeError):
# Note the singleton view will fail as the type is
# expected to be a List which can be confirmed in _infer_features_dict
self.store.apply(
[driver, driver_stats_source, driver_stats_fv, pandas_view, python_view, python_singleton_view]
)

self.store.apply(
[driver, driver_stats_source, driver_stats_fv, pandas_view, python_view]
)
Expand Down