FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Return python mode ODFV features with full feature names by breken-ai · Pull Request #6900 · feast-dev/feast · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 19 additions & 0 deletions sdk/python/feast/utils.py
This file contains hidden or 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
Expand Up @@ -937,6 +937,18 @@ def _is_metrics_active():
transformed_features_dict: Dict[str, List[Any]] = odfv.transform_dict(
odfv_input_dict
)
if full_feature_names:
# The UDF returns short output names, but the requested refs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Move the renaming into transform_dict by adding full_feature_names parameter. It makes the three transform methods consistent and prevents the bug from recurring if transform_dict gets called from anywhere else.

# use "<view>__<feature>" (transform_arrow renames the same way).
odfv_output_names = {f.name for f in odfv.features}
transformed_features_dict = {
(
odfv._get_projected_feature_name(name)
if name in odfv_output_names
else name
): values
for name, values in transformed_features_dict.items()
}
elif odfv.mode in {"pandas", "substrait"}:
if initial_response_arrow is None:
initial_response_arrow = initial_response.to_arrow()
Expand Down Expand Up @@ -978,6 +990,13 @@ def _is_metrics_active():

proto_values = []
schema_dict = {k.name: k.dtype for k in odfv.schema}
if full_feature_names:
schema_dict.update(
{
odfv._get_projected_feature_name(k.name): k.dtype
for k in odfv.schema
}
)
for selected_feature in selected_subset:
feature_vector = transformed_features[selected_feature]
selected_feature_type = schema_dict.get(selected_feature, None)
Expand Down
This file contains hidden or 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
Expand Up @@ -321,6 +321,43 @@ def test_python_pandas_parity(self):
+ online_python_response["acc_rate"][0]
)

def test_python_views_with_full_feature_names(self):
online_response = self.store.get_online_features(
entity_rows=[{"driver_id": 1001}],
features=[
"driver_hourly_stats:conv_rate",
"driver_hourly_stats:acc_rate",
"pandas_view:conv_rate_plus_acc_pandas",
"python_demo_view:conv_rate_plus_val1_python",
"python_singleton_view:conv_rate_plus_acc_python_singleton",
],
full_feature_names=True,
).to_dict()

assert sorted(online_response.keys()) == sorted(
[
"driver_id",
"driver_hourly_stats__conv_rate",
"driver_hourly_stats__acc_rate",
"pandas_view__conv_rate_plus_acc_pandas",
"python_demo_view__conv_rate_plus_val1_python",
"python_singleton_view__conv_rate_plus_acc_python_singleton",
]
)
expected = (
online_response["driver_hourly_stats__conv_rate"][0]
+ online_response["driver_hourly_stats__acc_rate"][0]
)
assert online_response["pandas_view__conv_rate_plus_acc_pandas"] == [
pytest.approx(expected)
]
assert online_response["python_demo_view__conv_rate_plus_val1_python"] == [
pytest.approx(expected)
]
assert online_response[
"python_singleton_view__conv_rate_plus_acc_python_singleton"
] == [pytest.approx(expected)]

def test_python_docs_demo(self):
entity_rows = [
{
Expand Down
Loading

Back | FazBrowse Home | New Git URL