Skip to content
Merged
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
11 changes: 9 additions & 2 deletions sdk/python/feast/feature_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,15 @@ def infer_features(self, fvs_to_update: Optional[Dict[str, FeatureView]] = None)
if f.name in desired_features:
projection.features.append(f)
elif not projection.desired_features and projection.features:
Copy link
Collaborator

Choose a reason for hiding this comment

The 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])
...

Copy link
Collaborator

Choose a reason for hiding this comment

The 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
# Second cass, so nothing needs to be done. In case something went wrong
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Second cass, so nothing needs to be done. In case something went wrong
# Second case, so nothing needs to be done. In case something went wrong

# during feature inference, we check that the selected features still exist.
actual_features = set(
[
f.name
for f in fvs_to_update[feature_grouping.name].features
]
)
assert projection.features.issubset(actual_features)
else:
# Third case, so all inferred features will be selected.
projection.features = fvs_to_update[
Expand Down