From c95df7248be62ca30c93b7dd57fbc16fd42ab688 Mon Sep 17 00:00:00 2001 From: Felix Wang Date: Fri, 6 Aug 2021 17:09:31 -0700 Subject: [PATCH] Deprecate the input parameter for FeatureViews Signed-off-by: Felix Wang --- sdk/python/feast/feature_view.py | 34 ++++++------------- .../infra/offline_stores/offline_utils.py | 8 ++--- ..._repo_with_duplicated_featureview_names.py | 4 +-- .../feature_repos/universal/feature_views.py | 2 +- 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/sdk/python/feast/feature_view.py b/sdk/python/feast/feature_view.py index a833c7a5e5b..bccc0d7e296 100644 --- a/sdk/python/feast/feature_view.py +++ b/sdk/python/feast/feature_view.py @@ -51,9 +51,7 @@ class FeatureView: ttl: The amount of time this group of features lives. A ttl of 0 indicates that this group of features lives forever. Note that large ttl's or a ttl of 0 can result in extremely computationally intensive queries. - input: The source of data where this group of features is stored. - batch_source (optional): The batch source of data where this group of features - is stored. + batch_source: The batch source of data where this group of features is stored. stream_source (optional): The stream source of data where this group of features is stored. features (optional): The set of features defined as part of this FeatureView. @@ -67,7 +65,6 @@ class FeatureView: tags: Optional[Dict[str, str]] ttl: timedelta online: bool - input: DataSource batch_source: DataSource stream_source: Optional[DataSource] = None created_timestamp: Optional[datetime] = None @@ -80,8 +77,7 @@ def __init__( name: str, entities: List[str], ttl: Union[Duration, timedelta], - input: Optional[DataSource] = None, - batch_source: Optional[DataSource] = None, + batch_source: DataSource, stream_source: Optional[DataSource] = None, features: Optional[List[Feature]] = None, tags: Optional[Dict[str, str]] = None, @@ -93,26 +89,17 @@ def __init__( Raises: ValueError: A field mapping conflicts with an Entity or a Feature. """ - if input is not None: - warnings.warn( - ( - "The argument 'input' is being deprecated. Please use 'batch_source' " - "instead. Feast 0.13 and onwards will not support the argument 'input'." - ), - DeprecationWarning, - ) - - _input = input or batch_source - assert _input is not None - _features = features or [] cols = [entity for entity in entities] + [feat.name for feat in _features] for col in cols: - if _input.field_mapping is not None and col in _input.field_mapping.keys(): + if ( + batch_source.field_mapping is not None + and col in batch_source.field_mapping.keys() + ): raise ValueError( - f"The field {col} is mapped to {_input.field_mapping[col]} for this data source. " - f"Please either remove this field mapping or use {_input.field_mapping[col]} as the " + f"The field {col} is mapped to {batch_source.field_mapping[col]} for this data source. " + f"Please either remove this field mapping or use {batch_source.field_mapping[col]} as the " f"Entity or Feature name." ) @@ -127,8 +114,7 @@ def __init__( self.ttl = ttl self.online = online - self.input = _input - self.batch_source = _input + self.batch_source = batch_source self.stream_source = stream_source self.materialization_intervals = [] @@ -311,7 +297,7 @@ def most_recent_end_time(self) -> Optional[datetime]: def infer_features_from_batch_source(self, config: RepoConfig): """ - Infers the set of features associated to this feature view from the input source. + Infers the set of features associated to this feature view from the batch source. Args: config: Configuration object used to configure the feature store. diff --git a/sdk/python/feast/infra/offline_stores/offline_utils.py b/sdk/python/feast/infra/offline_stores/offline_utils.py index 304bdc8e912..49f35b4323a 100644 --- a/sdk/python/feast/infra/offline_stores/offline_utils.py +++ b/sdk/python/feast/infra/offline_stores/offline_utils.py @@ -105,7 +105,7 @@ def get_feature_view_query_context( join_keys = [] entity_selections = [] reverse_field_mapping = { - v: k for k, v in feature_view.input.field_mapping.items() + v: k for k, v in feature_view.batch_source.field_mapping.items() } for entity_name in feature_view.entities: entity = registry.get_entity(entity_name, project) @@ -120,8 +120,8 @@ def get_feature_view_query_context( else: ttl_seconds = 0 - event_timestamp_column = feature_view.input.event_timestamp_column - created_timestamp_column = feature_view.input.created_timestamp_column + event_timestamp_column = feature_view.batch_source.event_timestamp_column + created_timestamp_column = feature_view.batch_source.created_timestamp_column context = FeatureViewQueryContext( name=feature_view.name, @@ -135,7 +135,7 @@ def get_feature_view_query_context( created_timestamp_column, created_timestamp_column ), # TODO: Make created column optional and not hardcoded - table_subquery=feature_view.input.get_table_query_string(), + table_subquery=feature_view.batch_source.get_table_query_string(), entity_selections=entity_selections, ) query_context.append(context) diff --git a/sdk/python/tests/example_repos/example_feature_repo_with_duplicated_featureview_names.py b/sdk/python/tests/example_repos/example_feature_repo_with_duplicated_featureview_names.py index e4c7abed0f4..84d57bf0381 100644 --- a/sdk/python/tests/example_repos/example_feature_repo_with_duplicated_featureview_names.py +++ b/sdk/python/tests/example_repos/example_feature_repo_with_duplicated_featureview_names.py @@ -10,7 +10,7 @@ name="driver_hourly_stats", # Intentionally use the same FeatureView name entities=["driver_id"], online=False, - input=driver_hourly_stats, + batch_source=driver_hourly_stats, ttl=Duration(seconds=10), tags={}, ) @@ -19,7 +19,7 @@ name="driver_hourly_stats", # Intentionally use the same FeatureView name entities=["driver_id"], online=False, - input=driver_hourly_stats, + batch_source=driver_hourly_stats, ttl=Duration(seconds=10), tags={}, ) 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 94c80bb84cf..962a99389b3 100644 --- a/sdk/python/tests/integration/feature_repos/universal/feature_views.py +++ b/sdk/python/tests/integration/feature_repos/universal/feature_views.py @@ -10,5 +10,5 @@ def correctness_feature_view(data_source: DataSource) -> FeatureView: entities=["driver"], features=[Feature("value", ValueType.FLOAT)], ttl=timedelta(days=5), - input=data_source, + batch_source=data_source, )