-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Fix feature service inference logic #3089
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
Changes from 1 commit
1e09ad3
5a5c6f6
07eaba6
51174b3
45ec63c
7a43b8f
40d7965
8dfb6db
c4d9c5a
64dfdef
31115ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,8 +98,15 @@ def infer_features(self, fvs_to_update: Optional[Dict[str, FeatureView]] = None) | |
| projection = feature_grouping.projection | ||
|
|
||
| if fvs_to_update and feature_grouping.name in fvs_to_update: | ||
| # There are three situations to be handled. First, the projection specifies | ||
| # desired features, in which case we should select those desired features. | ||
| # Second, the projection does not specify any desired features but has | ||
| # already selected features, in which case nothing needs to be done. And | ||
| # third, the projection does not specify any desired features but has not | ||
| # yet selected features (since the original feature view did not yet have | ||
| # features), in which case we should select all possible inferred features. | ||
| if projection.desired_features: | ||
| # Select the specific desired features. | ||
| # First case, so we select the specific desired features. | ||
| desired_features = set(projection.desired_features) | ||
| actual_features = set( | ||
| [ | ||
|
|
@@ -115,8 +122,11 @@ def infer_features(self, fvs_to_update: Optional[Dict[str, FeatureView]] = None) | |
| for f in fvs_to_update[feature_grouping.name].features: | ||
| if f.name in desired_features: | ||
| projection.features.append(f) | ||
| elif not projection.features: | ||
| # No features have been specifically selected, so all features will be added to the projection. | ||
| elif not projection.desired_features and projection.features: | ||
|
Collaborator
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. would be cleaner imo if you had early returns instead of the elif and else.. and maybe some example definitions e.g. if projection.desired_features:
# The projection wants to reference inferred features. Validate they exist
# Example: FeatureService(features=[[fv_with_no_schema["feature]])
...
return
if projection.features:
# The projection only references features from a FV's known schema (not inferred).
# Example 1: FeatureService(features=[fv_with_schema[["feature"]])
# Example 2: FeatureService(features=[fv_with_schema])
return
# The projection wants all features from a FV that has an inferred schema
# Example: FeatureService(features=[fv_with_no_schema])
...
Collaborator
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. wondering if we can exit earlier than this. i.e in line 98 instead |
||
| # Second cass, so nothing needs to be done. | ||
| pass | ||
| else: | ||
| # Third case, so all inferred features will be selected. | ||
| projection.features = fvs_to_update[ | ||
| feature_grouping.name | ||
| ].features | ||
|
|
||
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.
Might be easier to read if you have the cases within the blocks themselves, instead of all in one block before the if starts