diff --git a/sdk/python/feast/feature_store.py b/sdk/python/feast/feature_store.py index 8a0ebc6ddf..97b7c5456f 100644 --- a/sdk/python/feast/feature_store.py +++ b/sdk/python/feast/feature_store.py @@ -13,6 +13,7 @@ # limitations under the License. import copy import itertools +import logging import os import warnings from collections import Counter, defaultdict @@ -247,6 +248,20 @@ def list_feature_services(self) -> List[FeatureService]: """ return self._registry.list_feature_services(self.project) + def list_all_feature_views( + self, allow_cache: bool = False + ) -> List[Union[FeatureView, StreamFeatureView, OnDemandFeatureView]]: + """ + Retrieves the list of feature views from the registry. + + Args: + allow_cache: Whether to allow returning entities from a cached registry. + + Returns: + A list of feature views. + """ + return self._list_all_feature_views(allow_cache) + def list_feature_views(self, allow_cache: bool = False) -> List[FeatureView]: """ Retrieves the list of feature views from the registry. @@ -257,12 +272,50 @@ def list_feature_views(self, allow_cache: bool = False) -> List[FeatureView]: Returns: A list of feature views. """ + logging.warning( + "list_feature_views will make breaking changes. Please use list_batch_feature_views instead. " + "list_feature_views will behave like list_all_feature_views in the future." + ) return self._list_feature_views(allow_cache) + def _list_all_feature_views( + self, + allow_cache: bool = False, + ) -> List[Union[FeatureView, StreamFeatureView, OnDemandFeatureView]]: + all_feature_views = ( + self._list_feature_views(allow_cache) + + self._list_stream_feature_views(allow_cache) + + self.list_on_demand_feature_views(allow_cache) + ) + return all_feature_views + def _list_feature_views( self, allow_cache: bool = False, hide_dummy_entity: bool = True, + ) -> List[FeatureView]: + logging.warning( + "_list_feature_views will make breaking changes. Please use _list_batch_feature_views instead. " + "_list_feature_views will behave like _list_all_feature_views in the future." + ) + feature_views = [] + for fv in self._registry.list_feature_views( + self.project, allow_cache=allow_cache + ): + if ( + hide_dummy_entity + and fv.entities + and fv.entities[0] == DUMMY_ENTITY_NAME + ): + fv.entities = [] + fv.entity_columns = [] + feature_views.append(fv) + return feature_views + + def _list_batch_feature_views( + self, + allow_cache: bool = False, + hide_dummy_entity: bool = True, ) -> List[FeatureView]: feature_views = [] for fv in self._registry.list_feature_views( diff --git a/sdk/python/tests/unit/test_on_demand_python_transformation.py b/sdk/python/tests/unit/test_on_demand_python_transformation.py index ebe797ffdb..72e9b53a10 100644 --- a/sdk/python/tests/unit/test_on_demand_python_transformation.py +++ b/sdk/python/tests/unit/test_on_demand_python_transformation.py @@ -159,6 +159,10 @@ def python_singleton_view(inputs: dict[str, Any]) -> dict[str, Any]: self.store.write_to_online_store( feature_view_name="driver_hourly_stats", df=driver_df ) + assert len(self.store.list_all_feature_views()) == 4 + assert len(self.store.list_feature_views()) == 1 + assert len(self.store.list_on_demand_feature_views()) == 3 + assert len(self.store.list_stream_feature_views()) == 0 def test_python_pandas_parity(self): entity_rows = [