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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Lazy load Endpoint class #655

Merged
merged 16 commits into from Oct 7, 2021
Merged

feat: Lazy load Endpoint class #655

merged 16 commits into from Oct 7, 2021

Conversation

vinnysenthil
Copy link
Contributor

@vinnysenthil vinnysenthil commented Aug 25, 2021

Fixes b/194435202 馃

@product-auto-label product-auto-label bot added the api: aiplatform Issues related to the AI Platform API. label Aug 25, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 25, 2021
@vinnysenthil vinnysenthil marked this pull request as ready for review August 26, 2021 19:54
Copy link
Member

@sasha-gitg sasha-gitg left a comment

Choose a reason for hiding this comment

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

Couple of thoughts:

  1. It seems like we don't get the benefit of lazy loading because at predict time we're making the get call through predict -> self.resource_name -> self._sync_gca_resource -> self._sync_gca_resource_if_skipped

  2. Perhaps a simpler implementation is to populate _gca_resource in the constructor like so:

endpoint_name = utils.full_resource_name(...)

self._gca_resource = gca_endpoint.Endpoint(name=endpoint_name)
  1. Please extend the integration test to retrieve one of the created models, predict, and assert we didn't get the resource.

endpoint._endpoint_name = endpoint._gca_resource.name

# Building Endpoint from GAPIC object is equivalent to calling getter
endpoint._skipped_getter_call = False
Copy link
Member

Choose a reason for hiding this comment

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

This is creating a new instance attribute but _skipped_getter_call is defined as a class attribute above. Perhaps, _skipped_getter_call should be an instance attribute?

@vinnysenthil vinnysenthil requested a review from a team as a code owner September 2, 2021 23:11
Copy link
Member

@sasha-gitg sasha-gitg left a comment

Choose a reason for hiding this comment

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

Thanks Vinny! I added one comment that may simplify this change.

google/cloud/aiplatform/models.py Show resolved Hide resolved
@vinnysenthil vinnysenthil merged commit c795c6f into main Oct 7, 2021
@vinnysenthil vinnysenthil deleted the lazy-load-ep branch October 7, 2021 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: aiplatform Issues related to the AI Platform API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants