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
Fix
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
  • Loading branch information
felixwang9817 committed Aug 18, 2022
commit c4d9c5a83fe5ce57931db7014334d2b342089975
48 changes: 29 additions & 19 deletions sdk/python/feast/feature_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,29 +100,33 @@ def infer_features(self, fvs_to_update: Dict[str, FeatureView]):
"""
for feature_grouping in self._features:
if isinstance(feature_grouping, BaseFeatureView):
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.
# 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)
if feature_grouping.name in fvs_to_update:
# 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)
else:
raise FeatureViewMissingDuringFeatureServiceInference(
Comment thread
adchia marked this conversation as resolved.
feature_view_name=feature_grouping.name,
feature_service_name=self.name,
)

continue

Expand All @@ -136,7 +140,13 @@ 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
if feature_grouping.name in fvs_to_update:
projection.features = fvs_to_update[feature_grouping.name].features
else:
raise FeatureViewMissingDuringFeatureServiceInference(
feature_view_name=feature_grouping.name,
feature_service_name=self.name,
)
else:
raise ValueError(
f"The feature service {self.name} has been provided with an invalid type "
Expand Down