Skip to content

Commit

Permalink
fix: Fix copy method for StreamFeatureView (#3951)
Browse files Browse the repository at this point in the history
Signed-off-by: fbad <fabio.badali@gmail.com>
  • Loading branch information
fbad authored Feb 24, 2024
1 parent 9e58bd4 commit cf06704
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sdk/python/feast/stream_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ def __copy__(self):
fv = StreamFeatureView(
name=self.name,
schema=self.schema,
entities=self.entities,
ttl=self.ttl,
tags=self.tags,
online=self.online,
Expand All @@ -293,9 +292,12 @@ def __copy__(self):
aggregations=self.aggregations,
mode=self.mode,
timestamp_field=self.timestamp_field,
source=self.source,
source=self.stream_source if self.stream_source else self.batch_source,
udf=self.udf,
)
fv.entities = self.entities
fv.features = copy.copy(self.features)
fv.entity_columns = copy.copy(self.entity_columns)
fv.projection = copy.copy(self.projection)
return fv

Expand Down
20 changes: 20 additions & 0 deletions sdk/python/tests/unit/test_feature_views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
from datetime import timedelta

import pytest
Expand Down Expand Up @@ -300,3 +301,22 @@ def test_stream_feature_view_proto_type():
aggregations=[],
)
assert sfv.proto_class is StreamFeatureViewProto


def test_stream_feature_view_copy():
stream_source = KafkaSource(
name="kafka",
timestamp_field="event_timestamp",
kafka_bootstrap_servers="",
message_format=AvroFormat(""),
topic="topic",
batch_source=FileSource(path="some path"),
)
sfv = StreamFeatureView(
name="test stream featureview proto class",
entities=[],
ttl=timedelta(days=30),
source=stream_source,
aggregations=[],
)
assert sfv == copy.copy(sfv)

0 comments on commit cf06704

Please sign in to comment.