From 7cea469320d03843fdec856935cf02a9587dec17 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Mon, 4 Apr 2022 16:29:28 -0700 Subject: [PATCH 01/14] Update request data source Signed-off-by: Kevin Zhang --- docs/getting-started/concepts/feature-view.md | 4 ++-- .../docker-compose/feast10/definitions.py | 4 ++-- sdk/python/feast/data_source.py | 12 ++++++------ sdk/python/feast/inference.py | 4 ++-- sdk/python/feast/on_demand_feature_view.py | 18 +++++++++--------- sdk/python/feast/request_feature_view.py | 8 ++++---- .../feature_repos/universal/feature_views.py | 10 +++++----- .../integration/registration/test_inference.py | 6 +++--- .../integration/registration/test_registry.py | 4 ++-- ui/feature_repo/features.py | 6 +++--- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/docs/getting-started/concepts/feature-view.md b/docs/getting-started/concepts/feature-view.md index 0bb4f96a31..3f7f59547a 100644 --- a/docs/getting-started/concepts/feature-view.md +++ b/docs/getting-started/concepts/feature-view.md @@ -130,9 +130,9 @@ Feature names must be unique within a [feature view](feature-view.md#feature-vie On demand feature views allows users to use existing features and request time data (features only available at request time) to transform and create new features. Users define python transformation logic which is executed in both historical retrieval and online retrieval paths: ```python -# Define a request data source which encodes features / information only +# Define a request data source which encodes features / information only # available at request time (e.g. part of the user initiated HTTP request) -input_request = RequestDataSource( +input_request = RequestSource( name="vals_to_add", schema={ "val_to_add": ValueType.INT64, diff --git a/java/serving/src/test/resources/docker-compose/feast10/definitions.py b/java/serving/src/test/resources/docker-compose/feast10/definitions.py index 0b00704348..18c9aa39c1 100644 --- a/java/serving/src/test/resources/docker-compose/feast10/definitions.py +++ b/java/serving/src/test/resources/docker-compose/feast10/definitions.py @@ -7,7 +7,7 @@ from feast.feature_view import FeatureView from feast.entity import Entity from feast.feature_service import FeatureService -from feast.on_demand_feature_view import RequestDataSource, on_demand_feature_view +from feast.on_demand_feature_view import RequestSource, on_demand_feature_view from feast import FileSource @@ -40,7 +40,7 @@ ) -input_request = RequestDataSource( +input_request = RequestSource( name="vals_to_add", schema={ "val_to_add": ValueType.INT64, diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index db9eabfb9f..85f16c07b2 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -16,7 +16,7 @@ import enum import warnings from abc import ABC, abstractmethod -from typing import Any, Callable, Dict, Iterable, Optional, Tuple +from typing import Any, Callable, Dict, Iterable, Optional, Tuple, Union, List, Field from google.protobuf.json_format import MessageToJson @@ -144,7 +144,7 @@ def to_proto(self) -> DataSourceProto.KinesisOptions: DataSourceProto.SourceType.BATCH_SNOWFLAKE: "feast.infra.offline_stores.snowflake_source.SnowflakeSource", DataSourceProto.SourceType.STREAM_KAFKA: "feast.data_source.KafkaSource", DataSourceProto.SourceType.STREAM_KINESIS: "feast.data_source.KinesisSource", - DataSourceProto.SourceType.REQUEST_SOURCE: "feast.data_source.RequestDataSource", + DataSourceProto.SourceType.REQUEST_SOURCE: "feast.data_source.RequestSource", DataSourceProto.SourceType.PUSH_SOURCE: "feast.data_source.PushSource", } @@ -422,9 +422,9 @@ def get_table_query_string(self) -> str: raise NotImplementedError -class RequestDataSource(DataSource): +class RequestSource(DataSource): """ - RequestDataSource that can be used to provide input features for on demand transforms + RequestSource that can be used to provide input features for on demand transforms Args: name: Name of the request data source @@ -446,7 +446,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, owner: Optional[str] = "", ): - """Creates a RequestDataSource object.""" + """Creates a RequestSource object.""" super().__init__(name=name, description=description, tags=tags, owner=owner) self.schema = schema @@ -464,7 +464,7 @@ def from_proto(data_source: DataSourceProto): schema = {} for key, val in schema_pb.items(): schema[key] = ValueType(val) - return RequestDataSource( + return RequestSource( name=data_source.name, schema=schema, description=data_source.description, diff --git a/sdk/python/feast/inference.py b/sdk/python/feast/inference.py index 51c4e9d78e..a4ea1859aa 100644 --- a/sdk/python/feast/inference.py +++ b/sdk/python/feast/inference.py @@ -9,7 +9,7 @@ RedshiftSource, SnowflakeSource, ) -from feast.data_source import DataSource, RequestDataSource +from feast.data_source import DataSource, RequestSource from feast.errors import RegistryInferenceFailure from feast.feature_view import FeatureView from feast.repo_config import RepoConfig @@ -78,7 +78,7 @@ def update_data_sources_with_inferred_event_timestamp_col( ERROR_MSG_PREFIX = "Unable to infer DataSource event_timestamp_column" for data_source in data_sources: - if isinstance(data_source, RequestDataSource): + if isinstance(data_source, RequestSource): continue if ( data_source.event_timestamp_column is None diff --git a/sdk/python/feast/on_demand_feature_view.py b/sdk/python/feast/on_demand_feature_view.py index 483d80892e..13796d1dfb 100644 --- a/sdk/python/feast/on_demand_feature_view.py +++ b/sdk/python/feast/on_demand_feature_view.py @@ -8,7 +8,7 @@ import pandas as pd from feast.base_feature_view import BaseFeatureView -from feast.data_source import RequestDataSource +from feast.data_source import RequestSource from feast.errors import RegistryInferenceFailure, SpecifiedFeaturesNotPresentError from feast.feature import Feature from feast.feature_view import FeatureView @@ -46,7 +46,7 @@ class OnDemandFeatureView(BaseFeatureView): source_feature_view_projections: A map from input source names to actual input sources with type FeatureViewProjection. source_request_data_sources: A map from input source names to the actual input - sources with type RequestDataSource. + sources with type RequestSource. udf: The user defined transformation function, which must take pandas dataframes as inputs. description: A human-readable description. @@ -59,7 +59,7 @@ class OnDemandFeatureView(BaseFeatureView): name: str features: List[Feature] source_feature_view_projections: Dict[str, FeatureViewProjection] - source_request_data_sources: Dict[str, RequestDataSource] + source_request_data_sources: Dict[str, RequestSource] udf: MethodType description: str tags: Dict[str, str] @@ -71,11 +71,11 @@ def __init__( name: str, features: List[Feature], sources: Optional[ - Dict[str, Union[FeatureView, FeatureViewProjection, RequestDataSource]] + Dict[str, Union[FeatureView, FeatureViewProjection, RequestSource]] ] = None, udf: Optional[MethodType] = None, inputs: Optional[ - Dict[str, Union[FeatureView, FeatureViewProjection, RequestDataSource]] + Dict[str, Union[FeatureView, FeatureViewProjection, RequestSource]] ] = None, description: str = "", tags: Optional[Dict[str, str]] = None, @@ -124,9 +124,9 @@ def __init__( assert sources is not None self.source_feature_view_projections: Dict[str, FeatureViewProjection] = {} - self.source_request_data_sources: Dict[str, RequestDataSource] = {} + self.source_request_data_sources: Dict[str, RequestSource] = {} for source_name, odfv_source in sources.items(): - if isinstance(odfv_source, RequestDataSource): + if isinstance(odfv_source, RequestSource): self.source_request_data_sources[source_name] = odfv_source elif isinstance(odfv_source, FeatureViewProjection): self.source_feature_view_projections[source_name] = odfv_source @@ -241,7 +241,7 @@ def from_proto(cls, on_demand_feature_view_proto: OnDemandFeatureViewProto): on_demand_source.feature_view_projection ) else: - sources[source_name] = RequestDataSource.from_proto( + sources[source_name] = RequestSource.from_proto( on_demand_source.request_data_source ) on_demand_feature_view_obj = cls( @@ -385,7 +385,7 @@ def get_requested_odfvs(feature_refs, project, registry): def on_demand_feature_view( - features: List[Feature], sources: Dict[str, Union[FeatureView, RequestDataSource]] + features: List[Feature], sources: Dict[str, Union[FeatureView, RequestSource]] ): """ Declare an on-demand feature view diff --git a/sdk/python/feast/request_feature_view.py b/sdk/python/feast/request_feature_view.py index 3be361347c..b1eb22fe8e 100644 --- a/sdk/python/feast/request_feature_view.py +++ b/sdk/python/feast/request_feature_view.py @@ -3,7 +3,7 @@ from typing import Dict, List, Optional, Type from feast.base_feature_view import BaseFeatureView -from feast.data_source import RequestDataSource +from feast.data_source import RequestSource from feast.feature import Feature from feast.feature_view_projection import FeatureViewProjection from feast.protos.feast.core.RequestFeatureView_pb2 import ( @@ -30,7 +30,7 @@ class RequestFeatureView(BaseFeatureView): """ name: str - request_data_source: RequestDataSource + request_data_source: RequestSource features: List[Feature] description: str tags: Dict[str, str] @@ -40,7 +40,7 @@ class RequestFeatureView(BaseFeatureView): def __init__( self, name: str, - request_data_source: RequestDataSource, + request_data_source: RequestSource, description: str = "", tags: Optional[Dict[str, str]] = None, owner: str = "", @@ -110,7 +110,7 @@ def from_proto(cls, request_feature_view_proto: RequestFeatureViewProto): request_feature_view_obj = cls( name=request_feature_view_proto.spec.name, - request_data_source=RequestDataSource.from_proto( + request_data_source=RequestSource.from_proto( request_feature_view_proto.spec.request_data_source ), description=request_feature_view_proto.spec.description, diff --git a/sdk/python/tests/integration/feature_repos/universal/feature_views.py b/sdk/python/tests/integration/feature_repos/universal/feature_views.py index 04443c38a0..551604e237 100644 --- a/sdk/python/tests/integration/feature_repos/universal/feature_views.py +++ b/sdk/python/tests/integration/feature_repos/universal/feature_views.py @@ -5,7 +5,7 @@ import pandas as pd from feast import Feature, FeatureView, OnDemandFeatureView, PushSource, ValueType -from feast.data_source import DataSource, RequestDataSource +from feast.data_source import DataSource, RequestSource def driver_feature_view( @@ -51,7 +51,7 @@ def conv_rate_plus_100(features_df: pd.DataFrame) -> pd.DataFrame: def conv_rate_plus_100_feature_view( - sources: Dict[str, Union[RequestDataSource, FeatureView]], + sources: Dict[str, Union[RequestSource, FeatureView]], infer_features: bool = False, features: Optional[List[Feature]] = None, ) -> OnDemandFeatureView: @@ -86,7 +86,7 @@ def similarity(features_df: pd.DataFrame) -> pd.DataFrame: def similarity_feature_view( - sources: Dict[str, Union[RequestDataSource, FeatureView]], + sources: Dict[str, Union[RequestSource, FeatureView]], infer_features: bool = False, features: Optional[List[Feature]] = None, ) -> OnDemandFeatureView: @@ -103,13 +103,13 @@ def similarity_feature_view( def create_conv_rate_request_data_source(): - return RequestDataSource( + return RequestSource( name="conv_rate_input", schema={"val_to_add": ValueType.INT32} ) def create_similarity_request_data_source(): - return RequestDataSource( + return RequestSource( name="similarity_input", schema={ "vector_double": ValueType.DOUBLE_LIST, diff --git a/sdk/python/tests/integration/registration/test_inference.py b/sdk/python/tests/integration/registration/test_inference.py index 54af9f6ff2..6eaae3ec7d 100644 --- a/sdk/python/tests/integration/registration/test_inference.py +++ b/sdk/python/tests/integration/registration/test_inference.py @@ -13,7 +13,7 @@ SnowflakeSource, ValueType, ) -from feast.data_source import RequestDataSource +from feast.data_source import RequestSource from feast.errors import ( DataSourceNoNameException, RegistryInferenceFailure, @@ -164,7 +164,7 @@ def test_update_data_sources_with_inferred_event_timestamp_col(universal_data_so def test_on_demand_features_type_inference(): # Create Feature Views - date_request = RequestDataSource( + date_request = RequestSource( name="date_request", schema={"some_date": ValueType.UNIX_TIMESTAMP} ) @@ -217,7 +217,7 @@ def test_view_with_missing_feature(features_df: pd.DataFrame) -> pd.DataFrame: def test_datasource_inference(): # Create Feature Views - date_request = RequestDataSource( + date_request = RequestSource( name="date_request", schema={"some_date": ValueType.UNIX_TIMESTAMP} ) diff --git a/sdk/python/tests/integration/registration/test_registry.py b/sdk/python/tests/integration/registration/test_registry.py index 88369ba76b..7fb30d25fb 100644 --- a/sdk/python/tests/integration/registration/test_registry.py +++ b/sdk/python/tests/integration/registration/test_registry.py @@ -24,7 +24,7 @@ from feast.entity import Entity from feast.feature import Feature from feast.feature_view import FeatureView -from feast.on_demand_feature_view import RequestDataSource, on_demand_feature_view +from feast.on_demand_feature_view import RequestSource, on_demand_feature_view from feast.protos.feast.types import Value_pb2 as ValueProto from feast.registry import Registry from feast.repo_config import RegistryConfig @@ -244,7 +244,7 @@ def test_modify_feature_views_success(test_registry): created_timestamp_column="timestamp", ) - request_source = RequestDataSource( + request_source = RequestSource( name="request_source", schema={"my_input_1": ValueType.INT32} ) diff --git a/ui/feature_repo/features.py b/ui/feature_repo/features.py index 8d9f5c66f1..f06a7b76bf 100644 --- a/ui/feature_repo/features.py +++ b/ui/feature_repo/features.py @@ -8,7 +8,7 @@ FileSource, ValueType, ) -from feast.data_source import RequestDataSource +from feast.data_source import RequestSource from feast.request_feature_view import RequestFeatureView from feast.on_demand_feature_view import on_demand_feature_view import pandas as pd @@ -126,12 +126,12 @@ # Define a request data source which encodes features / information only # available at request time (e.g. part of the user initiated HTTP request) -input_request = RequestDataSource( +input_request = RequestSource( name="transaction", schema={"transaction_amt": ValueType.INT64}, ) # Define an on demand feature view which can generate new features based on -# existing feature views and RequestDataSource features +# existing feature views and RequestSource features @on_demand_feature_view( inputs={"credit_history": credit_history, "transaction": input_request,}, features=[ From 7b7395ce7848f25e454dd38b802fee27c4e4ef2e Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Mon, 4 Apr 2022 16:30:42 -0700 Subject: [PATCH 02/14] Fix Signed-off-by: Kevin Zhang --- sdk/python/feast/data_source.py | 2 +- .../integration/feature_repos/universal/feature_views.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 85f16c07b2..29b92f0511 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -16,7 +16,7 @@ import enum import warnings from abc import ABC, abstractmethod -from typing import Any, Callable, Dict, Iterable, Optional, Tuple, Union, List, Field +from typing import Any, Callable, Dict, Field, Iterable, List, Optional, Tuple, Union from google.protobuf.json_format import MessageToJson diff --git a/sdk/python/tests/integration/feature_repos/universal/feature_views.py b/sdk/python/tests/integration/feature_repos/universal/feature_views.py index 551604e237..b456b2debc 100644 --- a/sdk/python/tests/integration/feature_repos/universal/feature_views.py +++ b/sdk/python/tests/integration/feature_repos/universal/feature_views.py @@ -103,9 +103,7 @@ def similarity_feature_view( def create_conv_rate_request_data_source(): - return RequestSource( - name="conv_rate_input", schema={"val_to_add": ValueType.INT32} - ) + return RequestSource(name="conv_rate_input", schema={"val_to_add": ValueType.INT32}) def create_similarity_request_data_source(): From 945e0f8b9b9ce6583fc272c6ce1fc59cbfd0a4ef Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Mon, 4 Apr 2022 16:32:10 -0700 Subject: [PATCH 03/14] Fix Signed-off-by: Kevin Zhang --- sdk/python/feast/data_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 29b92f0511..9b1ed2a209 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -16,7 +16,7 @@ import enum import warnings from abc import ABC, abstractmethod -from typing import Any, Callable, Dict, Field, Iterable, List, Optional, Tuple, Union +from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union from google.protobuf.json_format import MessageToJson From 19158f8a14938024f59d1c94f9db5b566b0c880b Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Mon, 4 Apr 2022 16:33:04 -0700 Subject: [PATCH 04/14] Fix Signed-off-by: Kevin Zhang --- sdk/python/feast/data_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 9b1ed2a209..10f309bbd5 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -16,7 +16,7 @@ import enum import warnings from abc import ABC, abstractmethod -from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union +from typing import Any, Callable, Dict, Iterable, Optional, Tuple from google.protobuf.json_format import MessageToJson From b284d5fc8cd8ad83a9d97b668b987831d0c6dbe5 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 10:03:40 -0700 Subject: [PATCH 05/14] Data source update Signed-off-by: Author Signed-off-by: Kevin Zhang --- sdk/python/feast/data_source.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 10f309bbd5..c097ce04c7 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. - +import warnings import enum import warnings from abc import ABC, abstractmethod @@ -421,7 +421,6 @@ def source_datatype_to_feast_value_type() -> Callable[[str], ValueType]: def get_table_query_string(self) -> str: raise NotImplementedError - class RequestSource(DataSource): """ RequestSource that can be used to provide input features for on demand transforms @@ -495,6 +494,12 @@ def get_table_query_string(self) -> str: def source_datatype_to_feast_value_type() -> Callable[[str], ValueType]: raise NotImplementedError +class RequestDataSource(RequestSource): + def __init__(self, *args, **kwargs): + warnings.warn("The 'RequestDataSource' class is deprecated and was renamed to RequestSource. Please use RequestSource instead.", + DeprecationWarning) + RequestSource.__init__(*args, **kwargs) + class KinesisSource(DataSource): def validate(self, config: RepoConfig): From c90a22463e80b3605e58d80d07819bd2e41c84e9 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 10:14:28 -0700 Subject: [PATCH 06/14] Data source Signed-off-by: Kevin Zhang Signed-off-by: Author Signed-off-by: Kevin Zhang --- sdk/python/feast/data_source.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index c097ce04c7..195f04841d 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings import enum import warnings from abc import ABC, abstractmethod @@ -421,6 +420,7 @@ def source_datatype_to_feast_value_type() -> Callable[[str], ValueType]: def get_table_query_string(self) -> str: raise NotImplementedError + class RequestSource(DataSource): """ RequestSource that can be used to provide input features for on demand transforms @@ -494,10 +494,13 @@ def get_table_query_string(self) -> str: def source_datatype_to_feast_value_type() -> Callable[[str], ValueType]: raise NotImplementedError + class RequestDataSource(RequestSource): def __init__(self, *args, **kwargs): - warnings.warn("The 'RequestDataSource' class is deprecated and was renamed to RequestSource. Please use RequestSource instead.", - DeprecationWarning) + warnings.warn( + "The 'RequestDataSource' class is deprecated and was renamed to RequestSource. Please use RequestSource instead.", + DeprecationWarning, + ) RequestSource.__init__(*args, **kwargs) From a362e9fffa1b0bf888bec492c9243d367a3af729 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 11:36:46 -0700 Subject: [PATCH 07/14] Temp fix Signed-off-by: Kevin Zhang --- .../src/test/resources/docker-compose/feast10/definitions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/serving/src/test/resources/docker-compose/feast10/definitions.py b/java/serving/src/test/resources/docker-compose/feast10/definitions.py index 18c9aa39c1..0b00704348 100644 --- a/java/serving/src/test/resources/docker-compose/feast10/definitions.py +++ b/java/serving/src/test/resources/docker-compose/feast10/definitions.py @@ -7,7 +7,7 @@ from feast.feature_view import FeatureView from feast.entity import Entity from feast.feature_service import FeatureService -from feast.on_demand_feature_view import RequestSource, on_demand_feature_view +from feast.on_demand_feature_view import RequestDataSource, on_demand_feature_view from feast import FileSource @@ -40,7 +40,7 @@ ) -input_request = RequestSource( +input_request = RequestDataSource( name="vals_to_add", schema={ "val_to_add": ValueType.INT64, From f3c9d7a9b4c0bb5fabbc665c4d5e2a432b1e1e7d Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 11:40:04 -0700 Subject: [PATCH 08/14] Fix Signed-off-by: Kevin Zhang --- sdk/python/feast/data_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 195f04841d..ba3289a78f 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -498,7 +498,7 @@ def source_datatype_to_feast_value_type() -> Callable[[str], ValueType]: class RequestDataSource(RequestSource): def __init__(self, *args, **kwargs): warnings.warn( - "The 'RequestDataSource' class is deprecated and was renamed to RequestSource. Please use RequestSource instead.", + "The 'RequestDataSource' class is deprecated and was renamed to RequestSource. Please use RequestSource instead. This class name will be removed in Feast 0.23.", DeprecationWarning, ) RequestSource.__init__(*args, **kwargs) From b44259959c1fe284371699d1d557a81acae63b55 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 12:31:56 -0700 Subject: [PATCH 09/14] Update internal var names Signed-off-by: Kevin Zhang --- .../java-demo/feature_repo/driver_repo.py | 8 +++---- sdk/python/feast/on_demand_feature_view.py | 24 +++++++++---------- sdk/python/feast/request_feature_view.py | 10 ++++---- .../feature_repos/repo_configuration.py | 4 ++-- .../feature_repos/universal/feature_views.py | 4 ++-- .../test_universal_odfv_feature_inference.py | 14 +++++------ 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/examples/java-demo/feature_repo/driver_repo.py b/examples/java-demo/feature_repo/driver_repo.py index 233593ff02..09db18f036 100644 --- a/examples/java-demo/feature_repo/driver_repo.py +++ b/examples/java-demo/feature_repo/driver_repo.py @@ -1,6 +1,6 @@ import pandas as pd from feast import Entity, Feature, FeatureView, FileSource, ValueType -from feast.data_source import RequestDataSource +from feast.data_source import RequestSource from feast.on_demand_feature_view import on_demand_feature_view from feast.request_feature_view import RequestFeatureView from google.protobuf.duration_pb2 import Duration @@ -28,13 +28,13 @@ # Define a request data source which encodes features / information only # available at request time (e.g. part of the user initiated HTTP request) -input_request = RequestDataSource( +input_request = RequestSource( name="vals_to_add", schema={"val_to_add": ValueType.INT64, "val_to_add_2": ValueType.INT64}, ) # Define an on demand feature view which can generate new features based on -# existing feature views and RequestDataSource features +# existing feature views and RequestSource features @on_demand_feature_view( inputs={ "driver_hourly_stats": driver_hourly_stats_view, @@ -55,7 +55,7 @@ def transformed_conv_rate(inputs: pd.DataFrame) -> pd.DataFrame: # Define request feature view driver_age_request_fv = RequestFeatureView( name="driver_age", - request_data_source=RequestDataSource( + request_source=RequestSource( name="driver_age", schema={"driver_age": ValueType.INT64,} ), ) diff --git a/sdk/python/feast/on_demand_feature_view.py b/sdk/python/feast/on_demand_feature_view.py index 13796d1dfb..a127601e6d 100644 --- a/sdk/python/feast/on_demand_feature_view.py +++ b/sdk/python/feast/on_demand_feature_view.py @@ -45,7 +45,7 @@ class OnDemandFeatureView(BaseFeatureView): features: The list of features in the output of the on demand feature view. source_feature_view_projections: A map from input source names to actual input sources with type FeatureViewProjection. - source_request_data_sources: A map from input source names to the actual input + source_request_sources: A map from input source names to the actual input sources with type RequestSource. udf: The user defined transformation function, which must take pandas dataframes as inputs. @@ -59,7 +59,7 @@ class OnDemandFeatureView(BaseFeatureView): name: str features: List[Feature] source_feature_view_projections: Dict[str, FeatureViewProjection] - source_request_data_sources: Dict[str, RequestSource] + source_request_sources: Dict[str, RequestSource] udf: MethodType description: str tags: Dict[str, str] @@ -124,10 +124,10 @@ def __init__( assert sources is not None self.source_feature_view_projections: Dict[str, FeatureViewProjection] = {} - self.source_request_data_sources: Dict[str, RequestSource] = {} + self.source_request_sources: Dict[str, RequestSource] = {} for source_name, odfv_source in sources.items(): if isinstance(odfv_source, RequestSource): - self.source_request_data_sources[source_name] = odfv_source + self.source_request_sources[source_name] = odfv_source elif isinstance(odfv_source, FeatureViewProjection): self.source_feature_view_projections[source_name] = odfv_source else: @@ -150,7 +150,7 @@ def __copy__(self): features=self.features, sources=dict( **self.source_feature_view_projections, - **self.source_request_data_sources, + **self.source_request_sources, ), udf=self.udf, description=self.description, @@ -167,7 +167,7 @@ def __eq__(self, other): if ( not self.source_feature_view_projections == other.source_feature_view_projections - or not self.source_request_data_sources == other.source_request_data_sources + or not self.source_request_sources == other.source_request_sources or not self.udf.__code__.co_code == other.udf.__code__.co_code ): return False @@ -196,10 +196,10 @@ def to_proto(self) -> OnDemandFeatureViewProto: ) for ( source_name, - request_data_source, - ) in self.source_request_data_sources.items(): + source_request_sources, + ) in self.source_request_sources.items(): sources[source_name] = OnDemandSource( - request_data_source=request_data_source.to_proto() + source_request_sources=source_request_sources.to_proto() ) spec = OnDemandFeatureViewSpec( @@ -282,8 +282,8 @@ def from_proto(cls, on_demand_feature_view_proto: OnDemandFeatureViewProto): def get_request_data_schema(self) -> Dict[str, ValueType]: schema: Dict[str, ValueType] = {} - for request_data_source in self.source_request_data_sources.values(): - schema.update(request_data_source.schema) + for request_source in self.source_request_sources.values(): + schema.update(request_source.schema) return schema def get_transformed_features_df( @@ -339,7 +339,7 @@ def infer_features(self): dtype=dtype ) df[f"{feature.name}"] = pd.Series(dtype=dtype) - for request_data in self.source_request_data_sources.values(): + for request_data in self.source_request_sources.values(): for feature_name, feature_type in request_data.schema.items(): dtype = feast_value_type_to_pandas_type(feature_type) df[f"{feature_name}"] = pd.Series(dtype=dtype) diff --git a/sdk/python/feast/request_feature_view.py b/sdk/python/feast/request_feature_view.py index b1eb22fe8e..5455cc7f13 100644 --- a/sdk/python/feast/request_feature_view.py +++ b/sdk/python/feast/request_feature_view.py @@ -20,7 +20,7 @@ class RequestFeatureView(BaseFeatureView): Attributes: name: The unique name of the request feature view. - request_data_source: The request data source that specifies the schema and + request_source: The request source that specifies the schema and features of the request feature view. features: The list of features defined as part of this request feature view. description: A human-readable description. @@ -30,7 +30,7 @@ class RequestFeatureView(BaseFeatureView): """ name: str - request_data_source: RequestSource + request_source: RequestSource features: List[Feature] description: str tags: Dict[str, str] @@ -73,7 +73,7 @@ def __init__( tags=tags, owner=owner, ) - self.request_data_source = request_data_source + self.request_source = request_data_source @property def proto_class(self) -> Type[RequestFeatureViewProto]: @@ -88,7 +88,7 @@ def to_proto(self) -> RequestFeatureViewProto: """ spec = RequestFeatureViewSpec( name=self.name, - request_data_source=self.request_data_source.to_proto(), + request_source=self.request_source.to_proto(), description=self.description, tags=self.tags, owner=self.owner, @@ -128,7 +128,7 @@ def from_proto(cls, request_feature_view_proto: RequestFeatureViewProto): def __copy__(self): fv = RequestFeatureView( - name=self.name, request_data_source=self.request_data_source + name=self.name, request_data_source=self.request_source ) fv.projection = copy.copy(self.projection) return fv diff --git a/sdk/python/tests/integration/feature_repos/repo_configuration.py b/sdk/python/tests/integration/feature_repos/repo_configuration.py index 3029b2e774..3beee03d8f 100644 --- a/sdk/python/tests/integration/feature_repos/repo_configuration.py +++ b/sdk/python/tests/integration/feature_repos/repo_configuration.py @@ -35,7 +35,7 @@ ) from tests.integration.feature_repos.universal.feature_views import ( conv_rate_plus_100_feature_view, - create_conv_rate_request_data_source, + create_conv_rate_request_source, create_customer_daily_profile_feature_view, create_driver_hourly_stats_feature_view, create_field_mapping_feature_view, @@ -279,7 +279,7 @@ def construct_universal_feature_views( driver_odfv=conv_rate_plus_100_feature_view( { "driver": driver_hourly_stats, - "input_request": create_conv_rate_request_data_source(), + "input_request": create_conv_rate_request_source(), } ) if with_odfv diff --git a/sdk/python/tests/integration/feature_repos/universal/feature_views.py b/sdk/python/tests/integration/feature_repos/universal/feature_views.py index b456b2debc..fb5bd8e455 100644 --- a/sdk/python/tests/integration/feature_repos/universal/feature_views.py +++ b/sdk/python/tests/integration/feature_repos/universal/feature_views.py @@ -102,11 +102,11 @@ def similarity_feature_view( ) -def create_conv_rate_request_data_source(): +def create_conv_rate_request_source(): return RequestSource(name="conv_rate_input", schema={"val_to_add": ValueType.INT32}) -def create_similarity_request_data_source(): +def create_similarity_request_source(): return RequestSource( name="similarity_input", schema={ diff --git a/sdk/python/tests/integration/registration/test_universal_odfv_feature_inference.py b/sdk/python/tests/integration/registration/test_universal_odfv_feature_inference.py index e8cc1552e2..c925ff7047 100644 --- a/sdk/python/tests/integration/registration/test_universal_odfv_feature_inference.py +++ b/sdk/python/tests/integration/registration/test_universal_odfv_feature_inference.py @@ -9,10 +9,10 @@ from tests.integration.feature_repos.universal.entities import customer, driver, item from tests.integration.feature_repos.universal.feature_views import ( conv_rate_plus_100_feature_view, - create_conv_rate_request_data_source, + create_conv_rate_request_source, create_driver_hourly_stats_feature_view, create_item_embeddings_feature_view, - create_similarity_request_data_source, + create_similarity_request_source, similarity_feature_view, ) @@ -26,9 +26,9 @@ def test_infer_odfv_features(environment, universal_data_sources, infer_features (entities, datasets, data_sources) = universal_data_sources driver_hourly_stats = create_driver_hourly_stats_feature_view(data_sources.driver) - request_data_source = create_conv_rate_request_data_source() + request_source = create_conv_rate_request_source() driver_odfv = conv_rate_plus_100_feature_view( - {"driver": driver_hourly_stats, "input_request": request_data_source}, + {"driver": driver_hourly_stats, "input_request": request_source}, infer_features=infer_features, ) @@ -60,7 +60,7 @@ def test_infer_odfv_list_features(environment, infer_features, tmp_path): ) items = create_item_embeddings_feature_view(fake_items_src) sim_odfv = similarity_feature_view( - {"items": items, "input_request": create_similarity_request_data_source()}, + {"items": items, "input_request": create_similarity_request_source()}, infer_features=infer_features, ) store = environment.feature_store @@ -78,9 +78,9 @@ def test_infer_odfv_features_with_error(environment, universal_data_sources): features = [Feature("conv_rate_plus_200", ValueType.DOUBLE)] driver_hourly_stats = create_driver_hourly_stats_feature_view(data_sources.driver) - request_data_source = create_conv_rate_request_data_source() + request_source = create_conv_rate_request_source() driver_odfv = conv_rate_plus_100_feature_view( - {"driver": driver_hourly_stats, "input_request": request_data_source}, + {"driver": driver_hourly_stats, "input_request": request_source}, features=features, ) From af8e98fb42eec62815dee45c6617d3ee1ea8d97c Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 12:45:33 -0700 Subject: [PATCH 10/14] Add test Signed-off-by: Kevin Zhang --- sdk/python/feast/data_source.py | 2 +- sdk/python/feast/on_demand_feature_view.py | 3 +-- sdk/python/feast/request_feature_view.py | 4 +--- sdk/python/tests/unit/test_data_sources.py | 10 ++++++++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index ba3289a78f..f0f1d8ef52 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -501,7 +501,7 @@ def __init__(self, *args, **kwargs): "The 'RequestDataSource' class is deprecated and was renamed to RequestSource. Please use RequestSource instead. This class name will be removed in Feast 0.23.", DeprecationWarning, ) - RequestSource.__init__(*args, **kwargs) + super().__init__(*args, **kwargs) class KinesisSource(DataSource): diff --git a/sdk/python/feast/on_demand_feature_view.py b/sdk/python/feast/on_demand_feature_view.py index a127601e6d..c109699fa7 100644 --- a/sdk/python/feast/on_demand_feature_view.py +++ b/sdk/python/feast/on_demand_feature_view.py @@ -149,8 +149,7 @@ def __copy__(self): name=self.name, features=self.features, sources=dict( - **self.source_feature_view_projections, - **self.source_request_sources, + **self.source_feature_view_projections, **self.source_request_sources, ), udf=self.udf, description=self.description, diff --git a/sdk/python/feast/request_feature_view.py b/sdk/python/feast/request_feature_view.py index 5455cc7f13..e380b8a4e0 100644 --- a/sdk/python/feast/request_feature_view.py +++ b/sdk/python/feast/request_feature_view.py @@ -127,8 +127,6 @@ def from_proto(cls, request_feature_view_proto: RequestFeatureViewProto): return request_feature_view_obj def __copy__(self): - fv = RequestFeatureView( - name=self.name, request_data_source=self.request_source - ) + fv = RequestFeatureView(name=self.name, request_data_source=self.request_source) fv.projection = copy.copy(self.projection) return fv diff --git a/sdk/python/tests/unit/test_data_sources.py b/sdk/python/tests/unit/test_data_sources.py index 28a12d44ad..ceaf4a9c2f 100644 --- a/sdk/python/tests/unit/test_data_sources.py +++ b/sdk/python/tests/unit/test_data_sources.py @@ -1,7 +1,10 @@ +from aiohttp import request from feast import ValueType from feast.data_source import PushSource from feast.infra.offline_stores.bigquery_source import BigQuerySource +import pytest +from feast.data_source import RequestDataSource def test_push_with_batch(): push_source = PushSource( @@ -18,3 +21,10 @@ def test_push_with_batch(): assert push_source.name == push_source_unproto.name assert push_source.schema == push_source_unproto.schema assert push_source.batch_source.name == push_source_unproto.batch_source.name + +def test_request_data_source_deprecation(): + with pytest.warns(DeprecationWarning): + request_data_source = RequestDataSource( + name="vals_to_add", + schema={"val_to_add": ValueType.INT64, "val_to_add_2": ValueType.INT64}, + ) \ No newline at end of file From b28932d68b5cc09b2720edcad8709f90239ec20f Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 12:49:44 -0700 Subject: [PATCH 11/14] Fix Signed-off-by: Kevin Zhang --- sdk/python/feast/on_demand_feature_view.py | 4 ++-- sdk/python/feast/request_feature_view.py | 2 +- sdk/python/tests/unit/test_data_sources.py | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sdk/python/feast/on_demand_feature_view.py b/sdk/python/feast/on_demand_feature_view.py index c109699fa7..ca7f6184fe 100644 --- a/sdk/python/feast/on_demand_feature_view.py +++ b/sdk/python/feast/on_demand_feature_view.py @@ -195,10 +195,10 @@ def to_proto(self) -> OnDemandFeatureViewProto: ) for ( source_name, - source_request_sources, + request_sources, ) in self.source_request_sources.items(): sources[source_name] = OnDemandSource( - source_request_sources=source_request_sources.to_proto() + request_data_source=request_sources.to_proto() ) spec = OnDemandFeatureViewSpec( diff --git a/sdk/python/feast/request_feature_view.py b/sdk/python/feast/request_feature_view.py index e380b8a4e0..52b1fa56a9 100644 --- a/sdk/python/feast/request_feature_view.py +++ b/sdk/python/feast/request_feature_view.py @@ -88,7 +88,7 @@ def to_proto(self) -> RequestFeatureViewProto: """ spec = RequestFeatureViewSpec( name=self.name, - request_source=self.request_source.to_proto(), + request_data_source=self.request_source.to_proto(), description=self.description, tags=self.tags, owner=self.owner, diff --git a/sdk/python/tests/unit/test_data_sources.py b/sdk/python/tests/unit/test_data_sources.py index ceaf4a9c2f..058e5be460 100644 --- a/sdk/python/tests/unit/test_data_sources.py +++ b/sdk/python/tests/unit/test_data_sources.py @@ -1,10 +1,10 @@ +import pytest from aiohttp import request + from feast import ValueType -from feast.data_source import PushSource +from feast.data_source import PushSource, RequestDataSource from feast.infra.offline_stores.bigquery_source import BigQuerySource -import pytest -from feast.data_source import RequestDataSource def test_push_with_batch(): push_source = PushSource( @@ -22,9 +22,10 @@ def test_push_with_batch(): assert push_source.schema == push_source_unproto.schema assert push_source.batch_source.name == push_source_unproto.batch_source.name + def test_request_data_source_deprecation(): with pytest.warns(DeprecationWarning): request_data_source = RequestDataSource( name="vals_to_add", schema={"val_to_add": ValueType.INT64, "val_to_add_2": ValueType.INT64}, - ) \ No newline at end of file + ) From 9ecf9c8eabee6deccd3729e9a7f5baae03316e43 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 12:54:47 -0700 Subject: [PATCH 12/14] Fix Signed-off-by: Kevin Zhang --- sdk/python/feast/on_demand_feature_view.py | 5 +---- sdk/python/tests/unit/test_data_sources.py | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sdk/python/feast/on_demand_feature_view.py b/sdk/python/feast/on_demand_feature_view.py index ca7f6184fe..9ea1c055de 100644 --- a/sdk/python/feast/on_demand_feature_view.py +++ b/sdk/python/feast/on_demand_feature_view.py @@ -193,10 +193,7 @@ def to_proto(self) -> OnDemandFeatureViewProto: sources[source_name] = OnDemandSource( feature_view_projection=fv_projection.to_proto() ) - for ( - source_name, - request_sources, - ) in self.source_request_sources.items(): + for (source_name, request_sources,) in self.source_request_sources.items(): sources[source_name] = OnDemandSource( request_data_source=request_sources.to_proto() ) diff --git a/sdk/python/tests/unit/test_data_sources.py b/sdk/python/tests/unit/test_data_sources.py index 058e5be460..bbff726362 100644 --- a/sdk/python/tests/unit/test_data_sources.py +++ b/sdk/python/tests/unit/test_data_sources.py @@ -2,7 +2,7 @@ from aiohttp import request from feast import ValueType -from feast.data_source import PushSource, RequestDataSource +from feast.data_source import PushSource, RequestDataSource, RequestSource from feast.infra.offline_stores.bigquery_source import BigQuerySource @@ -29,3 +29,7 @@ def test_request_data_source_deprecation(): name="vals_to_add", schema={"val_to_add": ValueType.INT64, "val_to_add_2": ValueType.INT64}, ) + request_data_source_proto = request_data_source.to_proto() + returned_request_source = RequestSource.from_proto(request_data_source_proto) + assert returned_request_source.name == request_data_source.name + assert returned_request_source.schema == request_data_source.schema From 61230c8b0d3458e4216a01f1217af1f521093940 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 12:56:07 -0700 Subject: [PATCH 13/14] Fix Signed-off-by: Kevin Zhang --- sdk/python/tests/unit/test_data_sources.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/python/tests/unit/test_data_sources.py b/sdk/python/tests/unit/test_data_sources.py index bbff726362..6e8e44c0e3 100644 --- a/sdk/python/tests/unit/test_data_sources.py +++ b/sdk/python/tests/unit/test_data_sources.py @@ -1,5 +1,4 @@ import pytest -from aiohttp import request from feast import ValueType from feast.data_source import PushSource, RequestDataSource, RequestSource From 340b98a6d33e913418857807b7eea650dc33e463 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 5 Apr 2022 15:08:23 -0700 Subject: [PATCH 14/14] Fix Signed-off-by: Kevin Zhang --- sdk/python/feast/feature_store.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/python/feast/feature_store.py b/sdk/python/feast/feature_store.py index b060d286fd..06b5ad57b9 100644 --- a/sdk/python/feast/feature_store.py +++ b/sdk/python/feast/feature_store.py @@ -679,7 +679,7 @@ def apply( data_sources_set_to_update.add(rfv.request_data_source) for odfv in odfvs_to_update: - for v in odfv.source_request_data_sources.values(): + for v in odfv.source_request_sources.values(): data_sources_set_to_update.add(v) data_sources_to_update = list(data_sources_set_to_update)