From 6615d232e78e935f40c91298f16304b6d0f47cfc Mon Sep 17 00:00:00 2001 From: Terence Date: Thu, 10 Sep 2020 19:12:31 +0800 Subject: [PATCH] Remove and update deprecation functions --- .../tests/test-feast-batch-serving.yaml | 2 +- .../tests/test-feast-online-serving.yaml | 11 ++-- sdk/python/feast/client.py | 38 +------------ sdk/python/tests/test_client.py | 6 ++- tests/e2e/redis/basic-ingest-redis-serving.py | 53 ++++++------------- 5 files changed, 26 insertions(+), 84 deletions(-) diff --git a/infra/charts/feast/templates/tests/test-feast-batch-serving.yaml b/infra/charts/feast/templates/tests/test-feast-batch-serving.yaml index f2a76e37b21..1fa6b0cf2ee 100644 --- a/infra/charts/feast/templates/tests/test-feast-batch-serving.yaml +++ b/infra/charts/feast/templates/tests/test-feast-batch-serving.yaml @@ -15,7 +15,7 @@ spec: - bash - -c - | - pip install -U feast==0.4.* + pip install -U feast==0.7.* cat < featureset.yaml kind: feature_set diff --git a/infra/charts/feast/templates/tests/test-feast-online-serving.yaml b/infra/charts/feast/templates/tests/test-feast-online-serving.yaml index f9a213aabb8..74acb4d26d9 100644 --- a/infra/charts/feast/templates/tests/test-feast-online-serving.yaml +++ b/infra/charts/feast/templates/tests/test-feast-online-serving.yaml @@ -15,7 +15,7 @@ spec: - bash - -c - | - pip install -U feast==0.4.* + pip install -U feast==0.7.* cat < featureset.yaml kind: feature_set @@ -68,12 +68,9 @@ spec: time.sleep(5) entity_rows=[ - GetOnlineFeaturesRequest.EntityRow( - fields={"customer_id": Value(int64_val=0)}), - GetOnlineFeaturesRequest.EntityRow( - fields={"customer_id": Value(int64_val=1)}), - GetOnlineFeaturesRequest.EntityRow( - fields={"customer_id": Value(int64_val=2)}), + {"customer_id": Value(int64_val=0)}, + {"customer_id": Value(int64_val=1)}, + {"customer_id": Value(int64_val=2)}, ] result_df = client.get_online_features( diff --git a/sdk/python/feast/client.py b/sdk/python/feast/client.py index b4a36ae8952..8d49e95ed67 100644 --- a/sdk/python/feast/client.py +++ b/sdk/python/feast/client.py @@ -19,7 +19,6 @@ import tempfile import time import uuid -import warnings from collections import OrderedDict from math import ceil from typing import Any, Dict, List, Optional, Tuple, Union, cast @@ -91,8 +90,6 @@ CPU_COUNT: int = multiprocessing.cpu_count() -warnings.simplefilter("once", DeprecationWarning) - class Client: """ @@ -543,25 +540,6 @@ def list_entities(self) -> Dict[str, Entity]: entities_dict[entity.name] = entity return entities_dict - def get_batch_features( - self, - feature_refs: List[str], - entity_rows: Union[pd.DataFrame, str], - compute_statistics: bool = False, - project: str = None, - ) -> RetrievalJob: - """ - Deprecated. Please see get_historical_features. - """ - warnings.warn( - "The method get_batch_features() is being deprecated. Please use the identical get_historical_features(). " - "Feast 0.7 and onwards will not support get_batch_features().", - DeprecationWarning, - ) - return self.get_historical_features( - feature_refs, entity_rows, compute_statistics, project - ) - def get_historical_features( self, feature_refs: List[str], @@ -683,7 +661,7 @@ def get_historical_features( def get_online_features( self, feature_refs: List[str], - entity_rows: List[Union[GetOnlineFeaturesRequest.EntityRow, Dict[str, Any]]], + entity_rows: List[Dict[str, Any]], project: Optional[str] = None, omit_entities: bool = False, ) -> OnlineResponse: @@ -964,7 +942,7 @@ def _get_grpc_metadata(self): def _infer_online_entity_rows( - entity_rows: List[Union[GetOnlineFeaturesRequest.EntityRow, Dict[str, Any]]], + entity_rows: List[Dict[str, Any]], ) -> List[GetOnlineFeaturesRequest.EntityRow]: """ Builds a list of EntityRow protos from Python native type format passed by user. @@ -976,18 +954,6 @@ def _infer_online_entity_rows( Returns: A list of EntityRow protos parsed from args. """ - - # Maintain backward compatibility with users providing EntityRow Proto - if entity_rows and isinstance(entity_rows[0], GetOnlineFeaturesRequest.EntityRow): - warnings.warn( - "entity_rows parameter will only be accepting Dict format from Feast v0.7 onwards", - DeprecationWarning, - ) - entity_rows_proto = cast( - List[Union[GetOnlineFeaturesRequest.EntityRow]], entity_rows - ) - return entity_rows_proto - entity_rows_dicts = cast(List[Dict[str, Any]], entity_rows) entity_row_list = [] entity_type_map = dict() diff --git a/sdk/python/tests/test_client.py b/sdk/python/tests/test_client.py index 8d591d26b9e..b9ef22b95b0 100644 --- a/sdk/python/tests/test_client.py +++ b/sdk/python/tests/test_client.py @@ -342,12 +342,14 @@ def int_val(x): ] ) recieve_response = GetOnlineFeaturesResponse() + entity_rows = [] for row_number in range(1, ROW_COUNT + 1): request.entity_rows.append( GetOnlineFeaturesRequest.EntityRow( fields={"driver_id": int_val(row_number)} ) - ), + ) + entity_rows.append({"driver_id": int_val(row_number)}) field_values = GetOnlineFeaturesResponse.FieldValues( fields={ "driver_id": int_val(row_number), @@ -370,7 +372,7 @@ def int_val(x): return_value=recieve_response, ) got_response = mocked_client.get_online_features( - entity_rows=request.entity_rows, + entity_rows=entity_rows, feature_refs=["driver:age", "rating", "null_value"], project="driver_project", ) # type: GetOnlineFeaturesResponse diff --git a/tests/e2e/redis/basic-ingest-redis-serving.py b/tests/e2e/redis/basic-ingest-redis-serving.py index 1c115cba1ef..92134af6daa 100644 --- a/tests/e2e/redis/basic-ingest-redis-serving.py +++ b/tests/e2e/redis/basic-ingest-redis-serving.py @@ -26,10 +26,7 @@ from feast.feature import Feature from feast.feature_set import FeatureSet, FeatureSetRef from feast.grpc.auth import get_auth_metadata_plugin -from feast.serving.ServingService_pb2 import ( - GetOnlineFeaturesRequest, - GetOnlineFeaturesResponse, -) +from feast.serving.ServingService_pb2 import GetOnlineFeaturesResponse from feast.source import KafkaSource from feast.type_map import ValueType from feast.types.Value_pb2 import Int64List @@ -264,13 +261,7 @@ def test_basic_retrieve_online_success(client, cust_trans_df): def try_get_features(): response = client.get_online_features( entity_rows=[ - GetOnlineFeaturesRequest.EntityRow( - fields={ - "customer_id": Value( - int64_val=cust_trans_df.iloc[0]["customer_id"] - ) - } - ) + {"customer_id": Value(int64_val=cust_trans_df.iloc[0]["customer_id"])} ], feature_refs=feature_refs, ) # type: GetOnlineFeaturesResponse @@ -305,14 +296,12 @@ def try_get_features(): feature_refs = [mapping[0] for mapping in feature_ref_df_mapping] response = client.get_online_features( entity_rows=[ - GetOnlineFeaturesRequest.EntityRow( - fields={ - "customer_id": Value( - int64_val=cust_trans_df.iloc[0]["customer_id"] - ), - "driver_id": Value(int64_val=driver_df.iloc[0]["driver_id"]), - } - ) + { + "customer_id": Value( + int64_val=cust_trans_df.iloc[0]["customer_id"] + ), + "driver_id": Value(int64_val=driver_df.iloc[0]["driver_id"]), + } ], feature_refs=feature_refs, ) # type: GetOnlineFeaturesResponse @@ -986,13 +975,7 @@ def test_all_types_retrieve_online_success(client, all_types_dataframe): def try_get_features(): response = client.get_online_features( entity_rows=[ - GetOnlineFeaturesRequest.EntityRow( - fields={ - "user_id": Value( - int64_val=all_types_dataframe.iloc[0]["user_id"] - ) - } - ) + {"user_id": Value(int64_val=all_types_dataframe.iloc[0]["user_id"])} ], feature_refs=feature_refs, ) # type: GetOnlineFeaturesResponse @@ -1134,13 +1117,11 @@ def test_large_volume_retrieve_online_success(client, large_volume_dataframe): while True: response = client.get_online_features( entity_rows=[ - GetOnlineFeaturesRequest.EntityRow( - fields={ - "customer_id": Value( - int64_val=large_volume_dataframe.iloc[0]["customer_id"] - ) - } - ) + { + "customer_id": Value( + int64_val=large_volume_dataframe.iloc[0]["customer_id"] + ) + } ], feature_refs=feature_refs, ) # type: GetOnlineFeaturesResponse @@ -1432,11 +1413,7 @@ def test_sink_writes_only_recent_rows(client): def try_get_features(): response = client.get_online_features( - entity_rows=[ - GetOnlineFeaturesRequest.EntityRow( - fields={"driver_id": Value(int64_val=later_df.iloc[0]["driver_id"])} - ) - ], + entity_rows=[{"driver_id": Value(int64_val=later_df.iloc[0]["driver_id"])}], feature_refs=feature_refs, ) # type: GetOnlineFeaturesResponse is_ok = all(