Skip to content

Commit

Permalink
implement proto
Browse files Browse the repository at this point in the history
  • Loading branch information
Rostifar committed Oct 10, 2023
1 parent 62fc1e6 commit 3f8ecd5
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions sdk/python/feast/infra/registry/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,17 @@ def _get_feature_view_registry(self, feature_view: BaseFeatureView) -> Dict[str,
raise FeatureViewNotFoundException(feature_view)

def _maybe_init_project_metadata(self, project: str) -> None:
# updates `usage` project uuid to match requested project
if project not in self.project_metadata:
self.project_metadata[project] = ProjectMetadata(project_name=project)
usage.set_current_project_uuid(self.project_metadata[project].project_uuid)

def _delete_object(
self, name: str, project: str, registry: Dict[str, FeastResource], on_miss_exc: Exception
) -> None:
# deletes a key from `registry`, or `on_miss_exc` is raised if the object doesn't exist in the registry
self._maybe_init_project_metadata(project)

# deletes a key from `registry`, or `on_miss_exc` is raised if the object doesn't exist in the registry
key = project_key(project, name)
if key not in registry:
raise on_miss_exc
Expand All @@ -144,9 +145,9 @@ def _delete_object(
def _get_object(
self, name: str, project: str, registry: Dict[str, FeastResource], on_miss_exc: Exception
) -> FeastResource:
# returns a `FeastResource` from the registry, or `on_miss_exc` if the object doesn't exist in the registry
self._maybe_init_project_metadata(project)

# returns a `FeastResource` from the registry, or `on_miss_exc` if the object doesn't exist in the registry
if not self.is_built:
raise RegistryNotBuiltException(registry_name=self.__class__.__name__)
key = project_key(project, name)
Expand Down Expand Up @@ -720,17 +721,16 @@ def get_infra(self, project: str, allow_cache: bool = False) -> Infra:
return self.infra[project]

def apply_user_metadata(self, project: str, feature_view: BaseFeatureView, metadata_bytes: Optional[bytes]) -> None:
# not supported for in-memory objects
# not supported for BaseFeatureView in-memory objects
pass

def get_user_metadata(self, project: str, feature_view: BaseFeatureView) -> Optional[bytes]:
# not supported for in-memory objects
# not supported for BaseFeatureView in-memory objects
pass

def proto(self) -> RegistryProto:
r = RegistryProto()
last_updated_timestamps = []
for project in :
for project in self.project_metadata:
for lister, registry_proto_field in [
(self.list_entities, r.entities),
(self.list_feature_views, r.feature_views),
Expand All @@ -743,10 +743,7 @@ def proto(self) -> RegistryProto:
(self.list_validation_references, r.validation_references),
(self.list_project_metadata, r.project_metadata),
]:
lister_has_udf = lister in {self.list_on_demand_feature_views, self.list_stream_feature_views}
ignore_udfs = self._in_feast_apply_context
objs: List[Any] = lister(project, ignore_udfs=ignore_udfs) if lister_has_udf else lister(
project) # type: ignore
objs: List[Any] = lister(project)
if objs:
registry_proto_field_data = []
for obj in objs:
Expand All @@ -758,12 +755,6 @@ def proto(self) -> RegistryProto:

registry_proto_field.extend(registry_proto_field_data)
r.infra.CopyFrom(self.get_infra(project).to_proto())
last_updated_metadata = self._get_last_updated_metadata(project)
if last_updated_metadata is not None:
last_updated_timestamps.append(self._get_last_updated_metadata(project))

if last_updated_timestamps:
r.last_updated.FromDatetime(max(last_updated_timestamps))
return r

def commit(self) -> None:
Expand Down

0 comments on commit 3f8ecd5

Please sign in to comment.