diff --git a/sdk/python/feast/feature_store.py b/sdk/python/feast/feature_store.py index 74a02d6dbe..11efdf2cac 100644 --- a/sdk/python/feast/feature_store.py +++ b/sdk/python/feast/feature_store.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import os -from collections import OrderedDict, defaultdict +from collections import Counter, OrderedDict, defaultdict from datetime import datetime, timedelta from pathlib import Path from typing import Any, Dict, List, Optional, Tuple, Union @@ -330,7 +330,7 @@ def get_historical_features_by_view( feature_refs: List[str], start_date: Optional[datetime] = None, end_date: Optional[datetime] = None, - full_feature_names: bool=False, + full_feature_names: bool = False, ) -> RetrievalJob: """Retrieve historical feature values for either training or batch scoring based on feature view. @@ -356,6 +356,9 @@ def get_historical_features_by_view( features. end_date (datetime): End date for time range of data to filter the feature view before retrieving features. + full_feature_names: A boolean that provides the option to add the feature view prefixes to the feature names, + changing them from the format "feature" to "feature_view__feature" (e.g., "daily_transactions" changes to + "customer_fv__daily_transactions"). By default, this value is set to False. Returns: RetrievalJob which can be used to materialize the results. @@ -365,14 +368,17 @@ def get_historical_features_by_view( >>> from feast.feature_store import FeatureStore >>> - >>> fs = FeatureStore(config=RepoConfig(provider="gcp")) - >>> retrieval_job = fs.get_historical_features( - >>> entity_df="SELECT event_timestamp, order_id, customer_id from gcp_project.my_ds.customer_orders", + >>> fs = FeatureStore(config=RepoConfig(provider="local")) + >>> retrieval_job = fs.get_historical_features_by_view( + >>> entity_df="customer", >>> feature_refs=["customer:age", "customer:avg_orders_1d", "customer:avg_orders_7d"] >>> ) >>> feature_data = retrieval_job.to_df() >>> model.fit(feature_data) # insert your modeling framework here. """ + warn( + "This API is experimental and may change without any deprecation cycle in a future release." + ) all_feature_views = self._registry.list_feature_views(project=self.project) _validate_feature_refs(feature_refs, full_feature_names) diff --git a/sdk/python/feast/infra/aws.py b/sdk/python/feast/infra/aws.py index 9e86d49011..2633cc49a5 100644 --- a/sdk/python/feast/infra/aws.py +++ b/sdk/python/feast/infra/aws.py @@ -152,6 +152,7 @@ def get_historical_features_by_view( project: str, start_date: Optional[datetime], end_date: Optional[datetime], + full_feature_names: bool, ) -> RetrievalJob: job = self.offline_store.get_historical_features_by_view( config=config, @@ -162,5 +163,6 @@ def get_historical_features_by_view( project=project, start_date=start_date, end_date=end_date, + full_feature_names=full_feature_names, ) return job diff --git a/sdk/python/feast/infra/gcp.py b/sdk/python/feast/infra/gcp.py index 0f161354dd..6e4d417362 100644 --- a/sdk/python/feast/infra/gcp.py +++ b/sdk/python/feast/infra/gcp.py @@ -154,6 +154,7 @@ def get_historical_features_by_view( project: str, start_date: Optional[datetime], end_date: Optional[datetime], + full_feature_names: bool, ) -> RetrievalJob: job = self.offline_store.get_historical_features_by_view( config=config, @@ -164,5 +165,6 @@ def get_historical_features_by_view( project=project, start_date=start_date, end_date=end_date, + full_feature_names=full_feature_names, ) return job diff --git a/sdk/python/feast/infra/local.py b/sdk/python/feast/infra/local.py index 971313218b..f175121be7 100644 --- a/sdk/python/feast/infra/local.py +++ b/sdk/python/feast/infra/local.py @@ -152,6 +152,7 @@ def get_historical_features_by_view( project: str, start_date: Optional[datetime], end_date: Optional[datetime], + full_feature_names: bool, ) -> RetrievalJob: return self.offline_store.get_historical_features_by_view( config=config, @@ -162,6 +163,7 @@ def get_historical_features_by_view( project=project, start_date=start_date, end_date=end_date, + full_feature_names=full_feature_names, ) diff --git a/sdk/python/feast/infra/offline_stores/bigquery.py b/sdk/python/feast/infra/offline_stores/bigquery.py index 17ee526088..fdeb28ef46 100644 --- a/sdk/python/feast/infra/offline_stores/bigquery.py +++ b/sdk/python/feast/infra/offline_stores/bigquery.py @@ -158,6 +158,7 @@ def get_historical_features_by_view( project: str, start_date: Optional[datetime], end_date: Optional[datetime], + full_feature_names: bool, ): raise NotImplementedError diff --git a/sdk/python/feast/infra/offline_stores/file.py b/sdk/python/feast/infra/offline_stores/file.py index 9212429dd0..47fc339bac 100644 --- a/sdk/python/feast/infra/offline_stores/file.py +++ b/sdk/python/feast/infra/offline_stores/file.py @@ -223,6 +223,7 @@ def get_historical_features_by_view( project: str, start_date: Optional[datetime], end_date: Optional[datetime], + full_feature_names: bool, ): if not (isinstance(entity_df, pd.DataFrame) or isinstance(entity_df, str)): raise ValueError( @@ -286,7 +287,13 @@ def get_historical_features_by_view( ) return FileOfflineStore.get_historical_features( - config, feature_views, feature_refs, entity_df, registry, project, + config, + feature_views, + feature_refs, + entity_df, + registry, + project, + full_feature_names, ) @staticmethod diff --git a/sdk/python/feast/infra/offline_stores/offline_store.py b/sdk/python/feast/infra/offline_stores/offline_store.py index f521429965..8f673a6057 100644 --- a/sdk/python/feast/infra/offline_stores/offline_store.py +++ b/sdk/python/feast/infra/offline_stores/offline_store.py @@ -86,5 +86,6 @@ def get_historical_features_by_view( project: str, start_date: Optional[datetime], end_date: Optional[datetime], + full_feature_names: bool, ): pass diff --git a/sdk/python/feast/infra/offline_stores/redshift.py b/sdk/python/feast/infra/offline_stores/redshift.py index f01d2009b2..fd1f05bfa4 100644 --- a/sdk/python/feast/infra/offline_stores/redshift.py +++ b/sdk/python/feast/infra/offline_stores/redshift.py @@ -70,5 +70,6 @@ def get_historical_features_by_view( project: str, start_date: Optional[datetime], end_date: Optional[datetime], + full_feature_names: bool, ): pass diff --git a/sdk/python/feast/infra/provider.py b/sdk/python/feast/infra/provider.py index c2dad20814..58b512dce9 100644 --- a/sdk/python/feast/infra/provider.py +++ b/sdk/python/feast/infra/provider.py @@ -131,6 +131,7 @@ def get_historical_features_by_view( project: str, start_date: Optional[datetime], end_date: Optional[datetime], + full_feature_names: bool, ) -> RetrievalJob: pass diff --git a/sdk/python/tests/foo_provider.py b/sdk/python/tests/foo_provider.py index 8917ea932b..c839997810 100644 --- a/sdk/python/tests/foo_provider.py +++ b/sdk/python/tests/foo_provider.py @@ -77,6 +77,7 @@ def get_historical_features_by_view( project: str, start_date: Optional[datetime], end_date: Optional[datetime], + full_feature_names: bool, ) -> RetrievalJob: pass