Skip to content

Commit 86d6221

Browse files
authored
fix: Correct the returning class proto type of StreamFeatureView to StreamFeatureViewProto instead of FeatureViewProto. (#3843)
1 parent a75d417 commit 86d6221

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

sdk/python/feast/feature_view.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing import Dict, List, Optional, Tuple, Type
1818

1919
from google.protobuf.duration_pb2 import Duration
20+
from google.protobuf.message import Message
2021
from typeguard import typechecked
2122

2223
from feast import utils
@@ -274,7 +275,7 @@ def ensure_valid(self):
274275
raise ValueError("Feature view has no entities.")
275276

276277
@property
277-
def proto_class(self) -> Type[FeatureViewProto]:
278+
def proto_class(self) -> Type[Message]:
278279
return FeatureViewProto
279280

280281
def with_join_key_map(self, join_key_map: Dict[str, str]):

sdk/python/feast/stream_feature_view.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import warnings
44
from datetime import datetime, timedelta
55
from types import FunctionType
6-
from typing import Dict, List, Optional, Tuple, Union
6+
from typing import Dict, List, Optional, Tuple, Type, Union
77

88
import dill
9+
from google.protobuf.message import Message
910
from typeguard import typechecked
1011

1112
from feast import flags_helper, utils
@@ -298,6 +299,10 @@ def __copy__(self):
298299
fv.projection = copy.copy(self.projection)
299300
return fv
300301

302+
@property
303+
def proto_class(self) -> Type[Message]:
304+
return StreamFeatureViewProto
305+
301306

302307
def stream_feature_view(
303308
*,

sdk/python/tests/unit/test_feature_views.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
from feast.feature_view import FeatureView
1111
from feast.field import Field
1212
from feast.infra.offline_stores.file_source import FileSource
13+
from feast.protos.feast.core.StreamFeatureView_pb2 import (
14+
StreamFeatureView as StreamFeatureViewProto,
15+
)
1316
from feast.protos.feast.types.Value_pb2 import ValueType
1417
from feast.stream_feature_view import StreamFeatureView, stream_feature_view
1518
from feast.types import Float32
@@ -277,3 +280,22 @@ def test_hash():
277280
def test_field_types():
278281
with pytest.raises(TypeError):
279282
Field(name="name", dtype=ValueType.INT32)
283+
284+
285+
def test_stream_feature_view_proto_type():
286+
stream_source = KafkaSource(
287+
name="kafka",
288+
timestamp_field="event_timestamp",
289+
kafka_bootstrap_servers="",
290+
message_format=AvroFormat(""),
291+
topic="topic",
292+
batch_source=FileSource(path="some path"),
293+
)
294+
sfv = StreamFeatureView(
295+
name="test stream featureview proto class",
296+
entities=[],
297+
ttl=timedelta(days=30),
298+
source=stream_source,
299+
aggregations=[],
300+
)
301+
assert sfv.proto_class is StreamFeatureViewProto

0 commit comments

Comments
 (0)