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

UDF error logging #92

Merged
merged 2 commits into from
Sep 5, 2023
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "feast-affirm"
version = "0.28+affirm142"
version = "0.28+affirm144"
description = "Feast - Affirm"
authors = ["Francisco Arceo", "Ross Briden", "Maks Stachowiak"]
readme = "README.md"
Expand Down
24 changes: 18 additions & 6 deletions sdk/python/feast/on_demand_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,13 @@ def get_transformed_features_df(
dict_with_features[full_feature_ref] = dict_with_features[feature.name]
columns_to_cleanup.append(full_feature_ref)
df_with_features = pd.DataFrame.from_dict(dict_with_features)
# Compute transformed values and apply to each result row
df_with_transformed_features = self.udf.__call__(df_with_features)

try:
# Compute transformed values and apply to each result row
df_with_transformed_features = self.udf.__call__(df_with_features)
except Exception as e:
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
message = f"A udf error occured for {self.name}: {e}; udf inputs: {df_with_features}."
raise Exception(message) from e
# Work out whether the correct columns names are used.
rename_columns = self._get_correct_names(df_with_transformed_features.columns, full_feature_names)

Expand All @@ -391,15 +395,23 @@ def get_transformed_features_dict(

# dict of lists into list of dicts
input_rows = [dict(zip(feature_dict.keys(), values)) for values in zip(*feature_dict.values())]
output_rows = [self.udf.__call__(row) for row in input_rows]
output_rows = []
for row in input_rows:
for feature_value in row.values():
assert not isinstance(feature_value, pd.Series)
try:
output_rows.append(self.udf.__call__(row))
except Exception as e:
message = f"A udf error occured for {self.name}: {e}; udf inputs: {row}."
raise Exception(message) from e
output_names = list(output_rows[0].keys())
correct_names_map = self._get_correct_names(output_names, full_feature_names)

try:
# list of dicts into dict of lists
return {correct_names_map[name]: [row[name] for row in output_rows] for name in output_names}
except KeyError as e:
logging.error(f"OnDemandFeatureView {self.name} udf returned unknown feature: {e.message}")
logging.error(f"OnDemandFeatureView {self.name} udf returned unknown feature: {e}")
raise

def infer_features(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from distutils.core import setup

NAME = "feast"
VERSION = "0.28+affirm142"
VERSION = "0.28+affirm144"
DESCRIPTION = "Python SDK for Feast @ Affirm"
URL = "https://github.com/feast-dev/feast"
AUTHOR = "Feast"
Expand Down