From 3d5af3cf05e511a9ac641dd3967bfb3b07751807 Mon Sep 17 00:00:00 2001 From: fbad Date: Tue, 13 Feb 2024 19:09:23 +0100 Subject: [PATCH] fix: Fix copy method for StreamFeatureView Signed-off-by: fbad --- sdk/python/feast/stream_feature_view.py | 6 ++++-- sdk/python/tests/unit/test_feature_views.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/sdk/python/feast/stream_feature_view.py b/sdk/python/feast/stream_feature_view.py index 6a204d68136..13abbc5e284 100644 --- a/sdk/python/feast/stream_feature_view.py +++ b/sdk/python/feast/stream_feature_view.py @@ -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, @@ -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 diff --git a/sdk/python/tests/unit/test_feature_views.py b/sdk/python/tests/unit/test_feature_views.py index afef332d372..8e4ff92fc0d 100644 --- a/sdk/python/tests/unit/test_feature_views.py +++ b/sdk/python/tests/unit/test_feature_views.py @@ -1,3 +1,4 @@ +import copy from datetime import timedelta import pytest @@ -299,3 +300,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)