Skip to content

Commit 36a574d

Browse files
feat: List all feature views (feast-dev#4256)
* 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>
1 parent 4891f76 commit 36a574d

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

sdk/python/feast/feature_store.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
import copy
1515
import itertools
16+
import logging
1617
import os
1718
import warnings
1819
from collections import Counter, defaultdict
@@ -247,6 +248,20 @@ def list_feature_services(self) -> List[FeatureService]:
247248
"""
248249
return self._registry.list_feature_services(self.project)
249250

251+
def list_all_feature_views(
252+
self, allow_cache: bool = False
253+
) -> List[Union[FeatureView, StreamFeatureView, OnDemandFeatureView]]:
254+
"""
255+
Retrieves the list of feature views from the registry.
256+
257+
Args:
258+
allow_cache: Whether to allow returning entities from a cached registry.
259+
260+
Returns:
261+
A list of feature views.
262+
"""
263+
return self._list_all_feature_views(allow_cache)
264+
250265
def list_feature_views(self, allow_cache: bool = False) -> List[FeatureView]:
251266
"""
252267
Retrieves the list of feature views from the registry.
@@ -257,12 +272,50 @@ def list_feature_views(self, allow_cache: bool = False) -> List[FeatureView]:
257272
Returns:
258273
A list of feature views.
259274
"""
275+
logging.warning(
276+
"list_feature_views will make breaking changes. Please use list_batch_feature_views instead. "
277+
"list_feature_views will behave like list_all_feature_views in the future."
278+
)
260279
return self._list_feature_views(allow_cache)
261280

281+
def _list_all_feature_views(
282+
self,
283+
allow_cache: bool = False,
284+
) -> List[Union[FeatureView, StreamFeatureView, OnDemandFeatureView]]:
285+
all_feature_views = (
286+
self._list_feature_views(allow_cache)
287+
+ self._list_stream_feature_views(allow_cache)
288+
+ self.list_on_demand_feature_views(allow_cache)
289+
)
290+
return all_feature_views
291+
262292
def _list_feature_views(
263293
self,
264294
allow_cache: bool = False,
265295
hide_dummy_entity: bool = True,
296+
) -> List[FeatureView]:
297+
logging.warning(
298+
"_list_feature_views will make breaking changes. Please use _list_batch_feature_views instead. "
299+
"_list_feature_views will behave like _list_all_feature_views in the future."
300+
)
301+
feature_views = []
302+
for fv in self._registry.list_feature_views(
303+
self.project, allow_cache=allow_cache
304+
):
305+
if (
306+
hide_dummy_entity
307+
and fv.entities
308+
and fv.entities[0] == DUMMY_ENTITY_NAME
309+
):
310+
fv.entities = []
311+
fv.entity_columns = []
312+
feature_views.append(fv)
313+
return feature_views
314+
315+
def _list_batch_feature_views(
316+
self,
317+
allow_cache: bool = False,
318+
hide_dummy_entity: bool = True,
266319
) -> List[FeatureView]:
267320
feature_views = []
268321
for fv in self._registry.list_feature_views(

sdk/python/tests/unit/test_on_demand_python_transformation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ def python_singleton_view(inputs: dict[str, Any]) -> dict[str, Any]:
159159
self.store.write_to_online_store(
160160
feature_view_name="driver_hourly_stats", df=driver_df
161161
)
162+
assert len(self.store.list_all_feature_views()) == 4
163+
assert len(self.store.list_feature_views()) == 1
164+
assert len(self.store.list_on_demand_feature_views()) == 3
165+
assert len(self.store.list_stream_feature_views()) == 0
162166

163167
def test_python_pandas_parity(self):
164168
entity_rows = [

0 commit comments

Comments
 (0)