diff --git a/sdk/python/feast/diff/infra_diff.py b/sdk/python/feast/diff/infra_diff.py index bffd655d2f5..b761470905a 100644 --- a/sdk/python/feast/diff/infra_diff.py +++ b/sdk/python/feast/diff/infra_diff.py @@ -1,5 +1,5 @@ from dataclasses import dataclass -from typing import Generic, Iterable, List, Tuple, TypeVar +from typing import Generic, Iterable, List, Optional, Tuple, TypeVar from feast.diff.property_diff import PropertyDiff, TransitionType from feast.infra.infra_object import ( @@ -98,7 +98,9 @@ def tag_infra_proto_objects_for_keep_delete_add( def diff_infra_protos( - current_infra_proto: InfraProto, new_infra_proto: InfraProto + current_infra_proto: InfraProto, + new_infra_proto: InfraProto, + project: Optional[str] = None, ) -> InfraDiff: infra_diff = InfraDiff() @@ -114,6 +116,19 @@ def diff_infra_protos( new_infra_objects = get_infra_object_protos_by_type( new_infra_proto, infra_object_class_type ) + + # Filter infra objects by project prefix when using shared online stores + # Table names include project prefix: {project}_{table_name} + if project: + project_prefix = f"{project}_" + current_infra_objects = [ + obj + for obj in current_infra_objects + if obj.name.startswith(project_prefix) + ] + new_infra_objects = [ + obj for obj in new_infra_objects if obj.name.startswith(project_prefix) + ] ( infra_objects_to_keep, infra_objects_to_delete, diff --git a/sdk/python/feast/feature_store.py b/sdk/python/feast/feature_store.py index 19a86825a62..727b3a28780 100644 --- a/sdk/python/feast/feature_store.py +++ b/sdk/python/feast/feature_store.py @@ -78,7 +78,6 @@ from feast.online_response import OnlineResponse from feast.permissions.permission import Permission from feast.project import Project -from feast.protos.feast.core.InfraObject_pb2 import Infra as InfraProto from feast.protos.feast.serving.ServingService_pb2 import ( FieldStatus, GetOnlineFeaturesResponse, @@ -792,12 +791,13 @@ def plan( # Compute the desired difference between the current infra, as stored in the registry, # and the desired infra. self._registry.refresh(project=self.project) - current_infra_proto = InfraProto() - current_infra_proto.CopyFrom(self._registry.proto().infra) + current_infra_proto = self._registry.get_infra(self.project).to_proto() desired_registry_proto = desired_repo_contents.to_registry_proto() new_infra = self._provider.plan_infra(self.config, desired_registry_proto) new_infra_proto = new_infra.to_proto() - infra_diff = diff_infra_protos(current_infra_proto, new_infra_proto) + infra_diff = diff_infra_protos( + current_infra_proto, new_infra_proto, project=self.project + ) return registry_diff, infra_diff, new_infra