Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use CopyFrom() instead of __deepycopy__() for creating a copy of protobuf object. #3999

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
from feast.infra.registry.sql import SqlRegistry
from feast.on_demand_feature_view import OnDemandFeatureView
from feast.online_response import OnlineResponse
from feast.protos.feast.core.Registry_pb2 import Registry as RegistryProto
from feast.protos.feast.serving.ServingService_pb2 import (
FieldStatus,
GetOnlineFeaturesResponse,
Expand Down Expand Up @@ -745,7 +746,8 @@ 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 = self._registry.proto().infra.__deepcopy__()
current_infra_proto = RegistryProto().infra
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use Infra proto object directly instead of getting it from RegistryProto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right. Let me improve it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will review this to check. Need to check some behaviors of doing that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you have to be careful when you call self._registry.proto() you're referencing the FeatureStore class and you want to make sure that the initialization was done so it could be fetched from the database.

All of the initialization happens within the FeatureStore.__init__() method.

If this still behaves as expected using that, then I'm fine with this but it doesn't seem like it would but I only briefly looked at this.

I knew to check this because my team found that this implementation of the registry has some bottlenecks I intend on fixing.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me it should be fine in this scenario. There's even a self._registry.refresh() call before. It would have failed then if called on an uninitialized FeatureStore object.

current_infra_proto.CopyFrom(self._registry.proto().infra)
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()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"numpy>=1.22,<1.25",
"pandas>=1.4.3,<3",
# Higher than 4.23.4 seems to cause a seg fault
"protobuf<4.23.4,>3.20",
"protobuf>=4.24.0",
"proto-plus>=1.20.0,<2",
"pyarrow>=4",
"pydantic>=2.0.0",
Expand Down
Loading