Skip to content

Commit d5cf2c5

Browse files
committed
added copy method in FVProjections
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
1 parent 476cbf3 commit d5cf2c5

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

sdk/python/feast/feature_view.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ def with_name(self, name: str):
226226
online=self.online,
227227
)
228228

229-
fv.set_projection(self.projection)
230-
fv.projection.name_alias = name
229+
fv.set_projection(self.projection.copy)
230+
fv.projection.name_to_use = name
231231

232232
return fv
233233

sdk/python/feast/feature_view_projection.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def to_proto(self):
2323

2424
return feature_reference_proto
2525

26+
def copy(self):
27+
return FeatureViewProjection(
28+
name=self.name, name_to_use=self.name_to_use, features=self.features,
29+
)
30+
2631
@staticmethod
2732
def from_proto(proto: FeatureViewProjectionProto):
2833
ref = FeatureViewProjection(

sdk/python/feast/on_demand_feature_view.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ def __init__(
6868
def __hash__(self) -> int:
6969
return hash((id(self), self.name))
7070

71+
def with_name(self, name: str):
72+
"""
73+
Produces a copy of this OnDemandFeatureView with the passed name.
74+
75+
Args:
76+
name: Name to assign to the OnDemandFeatureView copy.
77+
78+
Returns:
79+
A copy of this OnDemandFeatureView with the name replaced with the 'name' input.
80+
"""
81+
odfv = OnDemandFeatureView(
82+
name=self.name, features=self.features, inputs=self.inputs, udf=self.udf
83+
)
84+
85+
odfv.set_projection(self.projection.copy)
86+
odfv.projection.name_to_use = name
87+
88+
return odfv
89+
7190
def to_proto(self) -> OnDemandFeatureViewProto:
7291
"""
7392
Converts an on demand feature view object to its protobuf representation.

0 commit comments

Comments
 (0)