Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions sdk/python/feast/feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class FeatureView(BaseFeatureView):
materialization_intervals: List[Tuple[datetime, datetime]]
mode: Optional[Union["TransformationMode", str]]
enable_validation: bool
_raw_feature_transformation_proto: Optional[Message] = None

def __init__(
self,
Expand Down Expand Up @@ -481,7 +482,9 @@ def to_proto_spec(
]

feature_transformation_proto = None
if hasattr(self, "feature_transformation") and self.feature_transformation:
if getattr(self, "_raw_feature_transformation_proto", None) is not None:
feature_transformation_proto = self._raw_feature_transformation_proto
elif hasattr(self, "feature_transformation") and self.feature_transformation:
feature_transformation_proto = transformation_to_proto(
self.feature_transformation
)
Expand Down Expand Up @@ -636,8 +639,14 @@ def _from_proto_internal(
source=source_views if source_views else batch_source, # type: ignore[arg-type]
sink_source=batch_source if source_views else None,
mode=mode,
feature_transformation=transformation,
feature_transformation=transformation
if not skip_udf
else feature_transformation_proto, # type: ignore[arg-type]
)
if skip_udf:
feature_view._raw_feature_transformation_proto = (
feature_transformation_proto
)
else:
mode_from_spec = (
feature_view_proto.spec.mode if feature_view_proto.spec.mode else None
Expand Down
8 changes: 8 additions & 0 deletions sdk/python/feast/infra/registry/base_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def list_stream_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[StreamFeatureView]:
"""
Retrieve a list of stream feature views from the registry
Expand All @@ -376,6 +377,7 @@ def list_stream_feature_views(
project: Filter stream feature views based on project name
allow_cache: Whether to allow returning stream feature views from a cached registry
tags: Filter by tags
skip_udf: Skip deserializing UDFs (for metadata-only operations)

Returns:
List of stream feature views
Expand Down Expand Up @@ -407,6 +409,7 @@ def list_on_demand_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[OnDemandFeatureView]:
"""
Retrieve a list of on demand feature views from the registry
Expand All @@ -415,6 +418,7 @@ def list_on_demand_feature_views(
project: Filter on demand feature views based on project name
allow_cache: Whether to allow returning on demand feature views from a cached registry
tags: Filter by tags
skip_udf: Skip deserializing UDFs (for metadata-only operations)

Returns:
List of on demand feature views
Expand Down Expand Up @@ -446,6 +450,7 @@ def list_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[FeatureView]:
"""
Retrieve a list of feature views from the registry
Expand All @@ -454,6 +459,7 @@ def list_feature_views(
allow_cache: Allow returning feature views from the cached registry
project: Filter feature views based on project name
tags: Filter by tags
skip_udf: Skip deserializing UDFs (for metadata-only operations)

Returns:
List of feature views
Expand Down Expand Up @@ -484,6 +490,7 @@ def list_all_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[BaseFeatureView]:
"""
Retrieve a list of feature views of all types from the registry
Expand All @@ -492,6 +499,7 @@ def list_all_feature_views(
allow_cache: Allow returning feature views from the cached registry
project: Filter feature views based on project name
tags: Filter by tags
skip_udf: Skip deserializing UDFs (for metadata-only operations)

Returns:
List of feature views
Expand Down
28 changes: 16 additions & 12 deletions sdk/python/feast/infra/registry/caching_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_any_feature_view(

@abstractmethod
def _list_all_feature_views(
self, project: str, tags: Optional[dict[str, str]]
self, project: str, tags: Optional[dict[str, str]], **kwargs: Any
) -> List[BaseFeatureView]:
pass

Expand All @@ -130,13 +130,14 @@ def list_all_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[BaseFeatureView]:
if allow_cache:
self._refresh_cached_registry_if_necessary()
return proto_registry_utils.list_all_feature_views(
self.cached_registry_proto, project, tags
self.cached_registry_proto, project, tags, skip_udf=skip_udf
)
return self._list_all_feature_views(project, tags)
return self._list_all_feature_views(project, tags, skip_udf=skip_udf)

@abstractmethod
def _get_feature_view(self, name: str, project: str) -> FeatureView:
Expand All @@ -154,7 +155,7 @@ def get_feature_view(

@abstractmethod
def _list_feature_views(
self, project: str, tags: Optional[dict[str, str]]
self, project: str, tags: Optional[dict[str, str]], **kwargs: Any
) -> List[FeatureView]:
pass

Expand All @@ -163,13 +164,14 @@ def list_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[FeatureView]:
if allow_cache:
self._refresh_cached_registry_if_necessary()
return proto_registry_utils.list_feature_views(
self.cached_registry_proto, project, tags
self.cached_registry_proto, project, tags, skip_udf=skip_udf
)
return self._list_feature_views(project, tags)
return self._list_feature_views(project, tags, skip_udf=skip_udf)

@abstractmethod
def _get_on_demand_feature_view(
Expand All @@ -189,7 +191,7 @@ def get_on_demand_feature_view(

@abstractmethod
def _list_on_demand_feature_views(
self, project: str, tags: Optional[dict[str, str]]
self, project: str, tags: Optional[dict[str, str]], **kwargs: Any
) -> List[OnDemandFeatureView]:
pass

Expand All @@ -198,13 +200,14 @@ def list_on_demand_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[OnDemandFeatureView]:
if allow_cache:
self._refresh_cached_registry_if_necessary()
return proto_registry_utils.list_on_demand_feature_views(
self.cached_registry_proto, project, tags
self.cached_registry_proto, project, tags, skip_udf=skip_udf
)
return self._list_on_demand_feature_views(project, tags)
return self._list_on_demand_feature_views(project, tags, skip_udf=skip_udf)

@abstractmethod
def _get_stream_feature_view(self, name: str, project: str) -> StreamFeatureView:
Expand All @@ -222,7 +225,7 @@ def get_stream_feature_view(

@abstractmethod
def _list_stream_feature_views(
self, project: str, tags: Optional[dict[str, str]]
self, project: str, tags: Optional[dict[str, str]], **kwargs: Any
) -> List[StreamFeatureView]:
pass

Expand All @@ -231,13 +234,14 @@ def list_stream_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[StreamFeatureView]:
if allow_cache:
self._refresh_cached_registry_if_necessary()
return proto_registry_utils.list_stream_feature_views(
self.cached_registry_proto, project, tags
self.cached_registry_proto, project, tags, skip_udf=skip_udf
)
return self._list_stream_feature_views(project, tags)
return self._list_stream_feature_views(project, tags, skip_udf=skip_udf)

@abstractmethod
def _get_feature_service(self, name: str, project: str) -> FeatureService:
Expand Down
44 changes: 32 additions & 12 deletions sdk/python/feast/infra/registry/proto_registry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@ def wrapper(
registry_proto: RegistryProto,
project: str,
tags: Optional[dict[str, str]],
**kwargs,
):
nonlocal cache_key, cache_value

key = tuple([id(registry_proto), registry_proto.version_id, project, tags])
kwargs_key = tuple(sorted(kwargs.items())) if kwargs else ()
key = tuple(
[id(registry_proto), registry_proto.version_id, project, tags, kwargs_key]
)

if key == cache_key:
return cache_value
else:
cache_value = func(registry_proto, project, tags)
cache_value = func(registry_proto, project, tags, **kwargs)
cache_key = key
return cache_value

Expand Down Expand Up @@ -279,54 +283,70 @@ def list_feature_services(

@registry_proto_cache_with_tags
def list_all_feature_views(
registry_proto: RegistryProto, project: str, tags: Optional[dict[str, str]]
registry_proto: RegistryProto,
project: str,
tags: Optional[dict[str, str]],
skip_udf: bool = False,
) -> List[BaseFeatureView]:
return (
list_feature_views(registry_proto, project, tags)
+ list_stream_feature_views(registry_proto, project, tags)
+ list_on_demand_feature_views(registry_proto, project, tags)
list_feature_views(registry_proto, project, tags, skip_udf=skip_udf)
+ list_stream_feature_views(registry_proto, project, tags, skip_udf=skip_udf)
+ list_on_demand_feature_views(registry_proto, project, tags, skip_udf=skip_udf)
)


@registry_proto_cache_with_tags
def list_feature_views(
registry_proto: RegistryProto, project: str, tags: Optional[dict[str, str]]
registry_proto: RegistryProto,
project: str,
tags: Optional[dict[str, str]],
skip_udf: bool = False,
) -> List[FeatureView]:
feature_views: List[FeatureView] = []
for feature_view_proto in registry_proto.feature_views:
if feature_view_proto.spec.project == project and utils.has_all_tags(
feature_view_proto.spec.tags, tags
):
feature_views.append(FeatureView.from_proto(feature_view_proto))
feature_views.append(
FeatureView.from_proto(feature_view_proto, skip_udf=skip_udf)
)
return feature_views


@registry_proto_cache_with_tags
def list_stream_feature_views(
registry_proto: RegistryProto, project: str, tags: Optional[dict[str, str]]
registry_proto: RegistryProto,
project: str,
tags: Optional[dict[str, str]],
skip_udf: bool = False,
) -> List[StreamFeatureView]:
stream_feature_views = []
for stream_feature_view in registry_proto.stream_feature_views:
if stream_feature_view.spec.project == project and utils.has_all_tags(
stream_feature_view.spec.tags, tags
):
stream_feature_views.append(
StreamFeatureView.from_proto(stream_feature_view)
StreamFeatureView.from_proto(stream_feature_view, skip_udf=skip_udf)
)
return stream_feature_views


@registry_proto_cache_with_tags
def list_on_demand_feature_views(
registry_proto: RegistryProto, project: str, tags: Optional[dict[str, str]]
registry_proto: RegistryProto,
project: str,
tags: Optional[dict[str, str]],
skip_udf: bool = False,
) -> List[OnDemandFeatureView]:
on_demand_feature_views = []
for on_demand_feature_view in registry_proto.on_demand_feature_views:
if on_demand_feature_view.spec.project == project and utils.has_all_tags(
on_demand_feature_view.spec.tags, tags
):
on_demand_feature_views.append(
OnDemandFeatureView.from_proto(on_demand_feature_view)
OnDemandFeatureView.from_proto(
on_demand_feature_view, skip_udf=skip_udf
)
)
return on_demand_feature_views

Expand Down
14 changes: 10 additions & 4 deletions sdk/python/feast/infra/registry/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,25 +877,27 @@ def list_stream_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[StreamFeatureView]:
registry_proto = self._get_registry_proto(
project=project, allow_cache=allow_cache
)
return proto_registry_utils.list_stream_feature_views(
registry_proto, project, tags
registry_proto, project, tags, skip_udf=skip_udf
)

def list_on_demand_feature_views(
self,
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[OnDemandFeatureView]:
registry_proto = self._get_registry_proto(
project=project, allow_cache=allow_cache
)
return proto_registry_utils.list_on_demand_feature_views(
registry_proto, project, tags
registry_proto, project, tags, skip_udf=skip_udf
)

def get_on_demand_feature_view(
Expand Down Expand Up @@ -978,12 +980,13 @@ def list_all_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[BaseFeatureView]:
registry_proto = self._get_registry_proto(
project=project, allow_cache=allow_cache
)
return proto_registry_utils.list_all_feature_views(
registry_proto, project, tags
registry_proto, project, tags, skip_udf=skip_udf
)

def get_any_feature_view(
Expand All @@ -999,11 +1002,14 @@ def list_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[FeatureView]:
registry_proto = self._get_registry_proto(
project=project, allow_cache=allow_cache
)
return proto_registry_utils.list_feature_views(registry_proto, project, tags)
return proto_registry_utils.list_feature_views(
registry_proto, project, tags, skip_udf=skip_udf
)

def get_feature_view(
self, name: str, project: str, allow_cache: bool = False
Expand Down
4 changes: 4 additions & 0 deletions sdk/python/feast/infra/registry/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def list_stream_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[StreamFeatureView]:
request = RegistryServer_pb2.ListStreamFeatureViewsRequest(
project=project, allow_cache=allow_cache, tags=tags
Expand All @@ -292,6 +293,7 @@ def list_on_demand_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[OnDemandFeatureView]:
request = RegistryServer_pb2.ListOnDemandFeatureViewsRequest(
project=project, allow_cache=allow_cache, tags=tags
Expand Down Expand Up @@ -320,6 +322,7 @@ def list_all_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[BaseFeatureView]:
request = RegistryServer_pb2.ListAllFeatureViewsRequest(
project=project, allow_cache=allow_cache, tags=tags
Expand Down Expand Up @@ -347,6 +350,7 @@ def list_feature_views(
project: str,
allow_cache: bool = False,
tags: Optional[dict[str, str]] = None,
skip_udf: bool = False,
) -> List[FeatureView]:
request = RegistryServer_pb2.ListFeatureViewsRequest(
project=project, allow_cache=allow_cache, tags=tags
Expand Down
Loading
Loading