Skip to content

Commit 5ec17f4

Browse files
committed
Always pass full and partial feature names to ODFV
Signed-off-by: Judah Rand <17158624+judahrand@users.noreply.github.com>
1 parent 963d3ac commit 5ec17f4

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

sdk/python/feast/feature_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ def _augment_response_with_on_demand_transforms(
12101210
for odfv_name, _feature_refs in odfv_feature_refs.items():
12111211
odfv = all_on_demand_feature_views[odfv_name]
12121212
transformed_features_df = odfv.get_transformed_features_df(
1213-
full_feature_names, initial_response_df
1213+
initial_response_df
12141214
)
12151215
for row_idx in range(len(result_rows)):
12161216
result_row = result_rows[row_idx]

sdk/python/feast/infra/offline_stores/offline_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def to_df(self) -> pd.DataFrame:
4747
# TODO(adchia): Fix requirement to specify dependent feature views in feature_refs
4848
for odfv in self.on_demand_feature_views:
4949
features_df = features_df.join(
50-
odfv.get_transformed_features_df(self.full_feature_names, features_df)
50+
odfv.get_transformed_features_df(features_df)
5151
)
5252
return features_df
5353

@@ -69,7 +69,7 @@ def to_arrow(self) -> pyarrow.Table:
6969
features_df = self._to_df_internal()
7070
for odfv in self.on_demand_feature_views:
7171
features_df = features_df.join(
72-
odfv.get_transformed_features_df(self.full_feature_names, features_df)
72+
odfv.get_transformed_features_df(features_df)
7373
)
7474
return pyarrow.Table.from_pandas(features_df)
7575

sdk/python/feast/on_demand_feature_view.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,21 @@ def get_request_data_schema(self) -> Dict[str, ValueType]:
164164
return schema
165165

166166
def get_transformed_features_df(
167-
self, full_feature_names: bool, df_with_features: pd.DataFrame
167+
self, df_with_features: pd.DataFrame
168168
) -> pd.DataFrame:
169169
# Apply on demand transformations
170-
# TODO(adchia): Include only the feature values from the specified input FVs in the ODFV.
171-
# Copy over un-prefixed features even if not requested since transform may need it
172170
columns_to_cleanup = []
173-
if full_feature_names:
174-
for input_fv in self.input_feature_views.values():
175-
for feature in input_fv.features:
176-
full_feature_ref = f"{input_fv.name}__{feature.name}"
177-
if full_feature_ref in df_with_features.keys():
178-
df_with_features[feature.name] = df_with_features[
179-
full_feature_ref
180-
]
181-
columns_to_cleanup.append(feature.name)
171+
for input_fv in self.input_feature_views.values():
172+
for feature in input_fv.features:
173+
full_feature_ref = f"{input_fv.name}__{feature.name}"
174+
if full_feature_ref in df_with_features.keys():
175+
# Make sure the partial feature name is always present
176+
df_with_features[feature.name] = df_with_features[full_feature_ref]
177+
columns_to_cleanup.append(feature.name)
178+
elif feature.name in df_with_features.keys():
179+
# Make sure the full feature name is always present
180+
df_with_features[full_feature_ref] = df_with_features[feature.name]
181+
columns_to_cleanup.append(full_feature_ref)
182182

183183
# Compute transformed values and apply to each result row
184184
df_with_transformed_features = self.udf.__call__(df_with_features)

sdk/python/feast/transformation_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def TransformFeatures(self, request, context):
4747

4848
df = pa.ipc.open_file(request.transformation_input.arrow_value).read_pandas()
4949

50-
result_df = odfv.get_transformed_features_df(True, df)
50+
result_df = odfv.get_transformed_features_df(df)
5151
result_arrow = pa.Table.from_pandas(result_df)
5252
sink = pa.BufferOutputStream()
5353
writer = pa.ipc.new_file(sink, result_arrow.schema)

0 commit comments

Comments
 (0)