Skip to content

Commit bce718e

Browse files
chore: Remove unnecessary methods from FeatureView (#2443)
* Remove unnecessary methods from FeatureView Signed-off-by: Felix Wang <[email protected]> * Fix comment Signed-off-by: Felix Wang <[email protected]>
1 parent 7d1efd5 commit bce718e

2 files changed

Lines changed: 16 additions & 80 deletions

File tree

‎sdk/python/feast/base_feature_view.py‎

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class BaseFeatureView(ABC):
3333
tags: A dictionary of key-value pairs to store arbitrary metadata.
3434
owner: The owner of the base feature view, typically the email of the primary
3535
maintainer.
36-
projection: The feature view projection to be applied to this base feature view
37-
at retrieval time.
36+
projection: The feature view projection storing modifications to be applied to
37+
this base feature view at retrieval time.
3838
created_timestamp (optional): The time when the base feature view was created.
3939
last_updated_timestamp (optional): The time when the base feature view was last
4040
updated.
@@ -152,15 +152,11 @@ def ensure_valid(self):
152152

153153
def with_name(self, name: str):
154154
"""
155-
Renames this feature view by returning a copy of this feature view with an alias
156-
set for the feature view name. This rename operation is only used as part of query
157-
operations and will not modify the underlying FeatureView.
155+
Returns a renamed copy of this base feature view. This renamed copy should only be
156+
used for query operations and will not modify the underlying base feature view.
158157
159158
Args:
160-
name: Name to assign to the FeatureView copy.
161-
162-
Returns:
163-
A copy of this FeatureView with the name replaced with the 'name' input.
159+
name: The name to assign to the copy.
164160
"""
165161
cp = self.__copy__()
166162
cp.projection.name_alias = name
@@ -169,15 +165,13 @@ def with_name(self, name: str):
169165

170166
def set_projection(self, feature_view_projection: FeatureViewProjection) -> None:
171167
"""
172-
Setter for the projection object held by this FeatureView. A projection is an
173-
object that stores the modifications to a FeatureView that is applied to the FeatureView
174-
when the FeatureView is used such as during feature_store.get_historical_features.
175-
This method also performs checks to ensure the projection is consistent with this
176-
FeatureView before doing the set.
168+
Sets the feature view projection of this base feature view to the given projection.
177169
178170
Args:
179-
feature_view_projection: The FeatureViewProjection object to set this FeatureView's
180-
'projection' field to.
171+
feature_view_projection: The feature view projection to be set.
172+
173+
Raises:
174+
ValueError: The name or features of the projection do not match.
181175
"""
182176
if feature_view_projection.name != self.name:
183177
raise ValueError(
@@ -197,18 +191,14 @@ def set_projection(self, feature_view_projection: FeatureViewProjection) -> None
197191

198192
def with_projection(self, feature_view_projection: FeatureViewProjection):
199193
"""
200-
Sets the feature view projection by returning a copy of this on-demand feature view
201-
with its projection set to the given projection. A projection is an
202-
object that stores the modifications to a feature view that is used during
203-
query operations.
194+
Returns a copy of this base feature view with the feature view projection set to
195+
the given projection.
204196
205197
Args:
206-
feature_view_projection: The FeatureViewProjection object to link to this
207-
OnDemandFeatureView.
198+
feature_view_projection: The feature view projection to assign to the copy.
208199
209-
Returns:
210-
A copy of this OnDemandFeatureView with its projection replaced with the
211-
'feature_view_projection' argument.
200+
Raises:
201+
ValueError: The name or features of the projection do not match.
212202
"""
213203
if feature_view_projection.name != self.name:
214204
raise ValueError(

‎sdk/python/feast/feature_view.py‎

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -213,36 +213,16 @@ def ensure_valid(self):
213213
def proto_class(self) -> Type[FeatureViewProto]:
214214
return FeatureViewProto
215215

216-
def with_name(self, name: str):
217-
"""
218-
Renames this feature view by returning a copy of this feature view with an alias
219-
set for the feature view name. This rename operation is only used as part of query
220-
operations and will not modify the underlying FeatureView.
221-
222-
Args:
223-
name: Name to assign to the FeatureView copy.
224-
225-
Returns:
226-
A copy of this FeatureView with the name replaced with the 'name' input.
227-
"""
228-
cp = self.__copy__()
229-
cp.projection.name_alias = name
230-
231-
return cp
232-
233216
def with_join_key_map(self, join_key_map: Dict[str, str]):
234217
"""
235-
Sets the join_key_map by returning a copy of this feature view with that field set.
218+
Returns a copy of this feature view with the join key map set to the given map.
236219
This join_key mapping operation is only used as part of query operations and will
237220
not modify the underlying FeatureView.
238221
239222
Args:
240223
join_key_map: A map of join keys in which the left is the join_key that
241224
corresponds with the feature data and the right corresponds with the entity data.
242225
243-
Returns:
244-
A copy of this FeatureView with the join_key_map replaced with the 'join_key_map' input.
245-
246226
Examples:
247227
Join a location feature data table to both the origin column and destination
248228
column of the entity data.
@@ -268,40 +248,6 @@ def with_join_key_map(self, join_key_map: Dict[str, str]):
268248

269249
return cp
270250

271-
def with_projection(self, feature_view_projection: FeatureViewProjection):
272-
"""
273-
Sets the feature view projection by returning a copy of this feature view
274-
with its projection set to the given projection. A projection is an
275-
object that stores the modifications to a feature view that is used during
276-
query operations.
277-
278-
Args:
279-
feature_view_projection: The FeatureViewProjection object to link to this
280-
OnDemandFeatureView.
281-
282-
Returns:
283-
A copy of this FeatureView with its projection replaced with the 'feature_view_projection'
284-
argument.
285-
"""
286-
if feature_view_projection.name != self.name:
287-
raise ValueError(
288-
f"The projection for the {self.name} FeatureView cannot be applied because it differs in name. "
289-
f"The projection is named {feature_view_projection.name} and the name indicates which "
290-
"FeatureView the projection is for."
291-
)
292-
293-
for feature in feature_view_projection.features:
294-
if feature not in self.features:
295-
raise ValueError(
296-
f"The projection for {self.name} cannot be applied because it contains {feature.name} which the "
297-
"FeatureView doesn't have."
298-
)
299-
300-
cp = self.__copy__()
301-
cp.projection = feature_view_projection
302-
303-
return cp
304-
305251
def to_proto(self) -> FeatureViewProto:
306252
"""
307253
Converts a feature view object to its protobuf representation.

0 commit comments

Comments
 (0)