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
Prev Previous commit
Next Next commit
Address comments
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
  • Loading branch information
felixwang9817 committed Aug 17, 2022
commit 8dfb6dba0c8b2cf35debf75e2dd1efe158126ba0
46 changes: 19 additions & 27 deletions sdk/python/feast/feature_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,35 +100,29 @@ def infer_features(self, fvs_to_update: Dict[str, FeatureView]):
"""
for feature_grouping in self._features:
if isinstance(feature_grouping, BaseFeatureView):
projection = feature_grouping.projection


if feature_grouping.name not in fvs_to_update:
raise FeatureViewMissingDuringFeatureServiceInference(
feature_view_name=feature_grouping.name,
feature_service_name=self.name,
)

projection = feature_grouping.projection
if projection.desired_features:
# The projection wants to select a specific set of inferred features.
# Example: FeatureService(features=[fv[["inferred_feature"]]]), where
# 'fv' is a feature view that was defined without a schema.
if feature_grouping.name in fvs_to_update:
# Validate that the selected features have actually been inferred.
desired_features = set(projection.desired_features)
actual_features = set(
[
f.name
for f in fvs_to_update[feature_grouping.name].features
]
)
assert desired_features.issubset(actual_features)

# Extract the selected features and add them to the projection.
projection.features = []
for f in fvs_to_update[feature_grouping.name].features:
if f.name in desired_features:
projection.features.append(f)
else:
raise FeatureViewMissingDuringFeatureServiceInference(
feature_view_name=feature_grouping.name,
feature_service_name=self.name,
)
# First we validate that the selected features have actually been inferred.
desired_features = set(projection.desired_features)
actual_features = set(
[f.name for f in fvs_to_update[feature_grouping.name].features]
)
assert desired_features.issubset(actual_features)

# Then we extract the selected features and add them to the projection.
projection.features = []
for f in fvs_to_update[feature_grouping.name].features:
if f.name in desired_features:
projection.features.append(f)

continue

Expand All @@ -142,9 +136,7 @@ def infer_features(self, fvs_to_update: Dict[str, FeatureView]):
# The projection wants to select all possible inferred features.
# Example: FeatureService(features=[fv]), where 'fv' is a feature view that
# was defined without a schema.
projection.features = fvs_to_update[
feature_grouping.name
].features
projection.features = fvs_to_update[feature_grouping.name].features
else:
raise ValueError(
f"The feature service {self.name} has been provided with an invalid type "
Expand Down