-
Notifications
You must be signed in to change notification settings - Fork 1k
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 support for Native Python feature transformations for On Demand Feature Views #4045
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
da3eba3
uploading current progress, not in a good state yet and have a lot of…
franciscojavierarceo f8fd949
bug fix
franciscojavierarceo bbc55de
uploading current progress...calling it a night
franciscojavierarceo 0ac27be
uploading current progress
franciscojavierarceo b028f8f
updated types and refactored to adjust
franciscojavierarceo efe16d5
fixed types, substraits, and added tests
franciscojavierarceo 74b77e6
fixed the casting issue
franciscojavierarceo 16850e9
updated mode check
franciscojavierarceo aa90fc1
fixed lint and udf example...should be singleton
franciscojavierarceo 26c1170
removed print statement
franciscojavierarceo 231e2db
updated to fix integration test
franciscojavierarceo 8fedca7
fixed unit test
franciscojavierarceo 5eb583d
removed import
franciscojavierarceo b5b71e2
linter
franciscojavierarceo 75a3023
removed print statement and OnlineResponseRow
franciscojavierarceo c5ecce6
fixed type validation
franciscojavierarceo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -2096,26 +2096,53 @@ def _augment_response_with_on_demand_transforms( | |
) | ||
|
||
initial_response = OnlineResponse(online_features_response) | ||
initial_response_df = initial_response.to_df() | ||
initial_response_df: Optional[pd.DataFrame] = None | ||
initial_response_dict: Optional[Dict[str, List[Any]]] = None | ||
|
||
# Apply on demand transformations and augment the result rows | ||
odfv_result_names = set() | ||
for odfv_name, _feature_refs in odfv_feature_refs.items(): | ||
odfv = requested_odfv_map[odfv_name] | ||
transformed_features_df = odfv.get_transformed_features_df( | ||
initial_response_df, | ||
full_feature_names, | ||
) | ||
selected_subset = [ | ||
f for f in transformed_features_df.columns if f in _feature_refs | ||
] | ||
|
||
proto_values = [ | ||
python_values_to_proto_values( | ||
transformed_features_df[feature].values, ValueType.UNKNOWN | ||
if odfv.mode == "python": | ||
if initial_response_dict is None: | ||
initial_response_dict = initial_response.to_dict() | ||
transformed_features_dict: Dict[ | ||
str, List[Any] | ||
] = odfv.get_transformed_features( | ||
initial_response_dict, | ||
full_feature_names, | ||
) | ||
for feature in selected_subset | ||
] | ||
elif odfv.mode in {"pandas", "substrait"}: | ||
if initial_response_df is None: | ||
initial_response_df = initial_response.to_df() | ||
transformed_features_df: pd.DataFrame = odfv.get_transformed_features( | ||
initial_response_df, | ||
full_feature_names, | ||
) | ||
else: | ||
raise Exception( | ||
f"Invalid OnDemandFeatureMode: {odfv.mode}. Expected one of 'pandas', 'python', or 'substrait'." | ||
) | ||
|
||
transformed_features = ( | ||
transformed_features_dict | ||
if odfv.mode == "python" | ||
else transformed_features_df | ||
) | ||
transformed_columns = ( | ||
transformed_features.columns | ||
if isinstance(transformed_features, pd.DataFrame) | ||
else transformed_features | ||
) | ||
selected_subset = [f for f in transformed_columns if f in _feature_refs] | ||
|
||
proto_values = [] | ||
for selected_feature in selected_subset: | ||
if odfv.mode in ["python", "pandas"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this kinda looks like it's breaking substrait, but I guess it's fine. seems like online path isn't tested for substrait in ci, I'll add tests and a fix (if necessary) for this later. |
||
feature_vector = transformed_features[selected_feature] | ||
proto_values.append( | ||
python_values_to_proto_values(feature_vector, ValueType.UNKNOWN) | ||
) | ||
|
||
odfv_result_names |= set(selected_subset) | ||
|
||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string 'pandas' can be replaced by a enum to avoid typo, but we don't have many "modes" so I think it's good for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i was going to refactor later and do some clean up to centralize