Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix
Signed-off-by: Kevin Zhang <kzhang@tecton.ai>
  • Loading branch information
kevjumba committed Apr 19, 2022
commit ad3ba3fc6ff0d85d5ee8b350a20ce318ad2a33c9
4 changes: 3 additions & 1 deletion sdk/python/feast/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,9 @@ def __init__(

super().__init__(name=_name, description=description, tags=tags, owner=owner)
if not _batch_source:
raise ValueError(f"batch_source parameter is needed for push source {self.name}")
raise ValueError(
f"batch_source parameter is needed for push source {self.name}"
)
self.batch_source = _batch_source

def __eq__(self, other):
Expand Down
52 changes: 39 additions & 13 deletions sdk/python/tests/unit/test_data_sources.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
from multiprocessing.sharedctypes import Value

import pytest
from sdk.python.feast.data_format import ProtoFormat

from feast import ValueType
from feast.data_source import PushSource, RequestDataSource, RequestSource
from feast.data_source import (
KafkaSource,
KinesisSource,
PushSource,
RequestDataSource,
RequestSource,
)
from feast.field import Field
from feast.types import Bool, Float32
from feast.types import Bool, Float32, Int64
from feast.data_source import KafkaSource, KinesisSource, PushSource, RequestSource
from feast.infra.offline_stores.bigquery_source import BigQuerySource
from feast.infra.offline_stores.file_source import FileSource
Expand Down Expand Up @@ -50,8 +58,6 @@ def test_request_source_primitive_type_to_proto():
deserialized_request_source = RequestSource.from_proto(request_proto)
assert deserialized_request_source == request_source

<<<<<<< HEAD

def test_hash():
push_source_1 = PushSource(
name="test", batch_source=BigQuerySource(table="test.test"),
Expand Down Expand Up @@ -79,12 +85,14 @@ def test_hash():

s4 = {push_source_1, push_source_2, push_source_3, push_source_4}
assert len(s4) == 3
=======

# TODO(kevjumba): Remove this test in feast 0.23 when positional arguments are removed.
def test_default_data_source_kw_arg_warning():
# source_class = request.param
with pytest.warns(DeprecationWarning):
source = KafkaSource("name", "column", "bootstrap_servers", ProtoFormat("class_path"), "topic")
source = KafkaSource(
"name", "column", "bootstrap_servers", ProtoFormat("class_path"), "topic"
)
assert source.name == "name"
assert source.timestamp_field == "column"
assert source.kafka_options.bootstrap_servers == "bootstrap_servers"
Expand All @@ -93,26 +101,41 @@ def test_default_data_source_kw_arg_warning():
KafkaSource("name", "column", "bootstrap_servers", topic="topic")

with pytest.warns(DeprecationWarning):
source = KinesisSource("name", "column", "c_column", ProtoFormat("class_path"), "region", "stream_name")
source = KinesisSource(
"name",
"column",
"c_column",
ProtoFormat("class_path"),
"region",
"stream_name",
)
assert source.name == "name"
assert source.timestamp_field == "column"
assert source.created_timestamp_column == "c_column"
assert source.kinesis_options.region == "region"
assert source.kinesis_options.stream_name == "stream_name"

with pytest.raises(ValueError):
KinesisSource("name", "column", "c_column", region="region", stream_name="stream_name")
KinesisSource(
"name", "column", "c_column", region="region", stream_name="stream_name"
)

with pytest.warns(DeprecationWarning):
source = RequestSource("name", [Field(name="val_to_add", dtype=Int64)], description="description")
source = RequestSource(
"name", [Field(name="val_to_add", dtype=Int64)], description="description"
)
assert source.name == "name"
assert source.description == "description"

with pytest.raises(ValueError):
RequestSource("name")

with pytest.warns(DeprecationWarning):
source = PushSource("name", BigQuerySource(name="bigquery_source", table="table"), description="description")
source = PushSource(
"name",
BigQuerySource(name="bigquery_source", table="table"),
description="description",
)
assert source.name == "name"
assert source.description == "description"
assert source.batch_source.name == "bigquery_source"
Expand All @@ -122,6 +145,9 @@ def test_default_data_source_kw_arg_warning():

# No name warning for DataSource
with pytest.warns(UserWarning):
source = KafkaSource(event_timestamp_column="column", bootstrap_servers="bootstrap_servers", message_format=ProtoFormat("class_path"), topic="topic")

>>>>>>> ed13af2f (Add unit tests)
source = KafkaSource(
event_timestamp_column="column",
bootstrap_servers="bootstrap_servers",
message_format=ProtoFormat("class_path"),
topic="topic",
)