Skip to content

Commit

Permalink
feat: List all feature views (#4256)
Browse files Browse the repository at this point in the history
* feature: Adding type to base feature view

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

* fixed linter

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

* fixed type and meta

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

* adding new listing

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

* updated

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

* cleaning up changes

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

* reverting FV proto

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

* doing simple way

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

* added a test

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

* updated to add warnings

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>

---------

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
  • Loading branch information
franciscojavierarceo committed Jun 8, 2024
1 parent 4891f76 commit 36a574d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
53 changes: 53 additions & 0 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import copy
import itertools
import logging
import os
import warnings
from collections import Counter, defaultdict
Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions sdk/python/tests/unit/test_on_demand_python_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 36a574d

Please sign in to comment.