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

Proposal: move API-methods to client #38

Closed
tswast opened this issue Apr 22, 2019 · 7 comments · Fixed by #311
Closed

Proposal: move API-methods to client #38

tswast opened this issue Apr 22, 2019 · 7 comments · Fixed by #311
Assignees
Labels
api: storage Issues related to the googleapis/python-storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tswast
Copy link
Contributor

tswast commented Apr 22, 2019

The Cloud Storage Python client was one of the first google-cloud-python clients, intended to be more reliable and more Pythonic than the google-api-client that it replaced. It is also a 100% hand-written client. Because it predates the auto-generated google-cloud-python clients, the Cloud Storage Python client has inconsistencies with other google-cloud-python clients.

This design proposal is to bring the Cloud Storage client further into alignment with other google-cloud-python clients and make the eventual inclusion of an auto-generated gRPC transport layer less disruptive to users of the Cloud Storage client.

Design document:

https://docs.google.com/document/d/1A4FIxThZK_enK7OV9ChY54IPrlpbdHwuhvVEu6iTHxM/edit?usp=sharing

Please share your feedback on the specifics of this as comments in the design document.

CC @crwilcox @frankyn @lbristol88

Update: according to comment, we need to update samples for moved methods before deprecating the old ones.

@tswast tswast changed the title Storage: redesign proposal Storage: client redesign proposal Apr 22, 2019
@IlyaFaer IlyaFaer self-assigned this Aug 2, 2019
IlyaFaer referenced this issue in googleapis/google-cloud-python Nov 8, 2019
@crwilcox crwilcox transferred this issue from googleapis/google-cloud-python Jan 31, 2020
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/python-storage API. label Jan 31, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Feb 3, 2020
@busunkim96 busunkim96 removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Feb 4, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Feb 4, 2020
@frankyn frankyn added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Feb 4, 2020
@frankyn
Copy link
Member

frankyn commented Mar 23, 2020

@IlyaFaer I believe this is complete. I'm closing FR.

If there's something that I missed please reopen.

@frankyn frankyn closed this as completed Mar 23, 2020
@IlyaFaer
Copy link

@frankyn, I've delegated the last part to @paul1319
@paul1319, do you have something to push for this issue?

@frankyn frankyn reopened this Mar 23, 2020
@frankyn
Copy link
Member

frankyn commented Mar 23, 2020

Reopening in case there's something pending.

@frankyn
Copy link
Member

frankyn commented Mar 31, 2020

@IlyaFaer haven't heard back for a bit. What's remaining?

@paul1319
Copy link

paul1319 commented Mar 31, 2020

@frankyn as I see it, Blob class Refactor and Deprecate part.

@tseaver
Copy link
Contributor

tseaver commented May 4, 2021

ISTM that this effort is not complete: e.g., the client does not have a get_blob method, nor any of the notification-related methods for buckets.

This partial refactoring complicates the tests a lot -- if it were complete, then bucket / blob unit tests would just use mocked clients and assert that the corresponding method is called correctly, rather than creating mock connections (and real clients, see #416) and grubbing around three layers down.

Basically, any non-client method using the client's _connection to make API requests should instead be calling a method of the client:

$ git grep api_request google/cloud/storage/{_helpers,blob,bucket,hmac_key,notification}.py
google/cloud/storage/_helpers.py:        api_response = client._connection.api_request(
google/cloud/storage/_helpers.py:        api_response = client._connection.api_request(
google/cloud/storage/_helpers.py:        api_response = client._connection.api_request(
google/cloud/storage/blob.py:            client._connection.api_request(
google/cloud/storage/blob.py:        info = client._connection.api_request(
google/cloud/storage/blob.py:        info = client._connection.api_request(
google/cloud/storage/blob.py:        resp = client._connection.api_request(
google/cloud/storage/blob.py:        api_response = client._connection.api_request(
google/cloud/storage/blob.py:        api_response = client._connection.api_request(
google/cloud/storage/bucket.py:            client._connection.api_request(
google/cloud/storage/bucket.py:        api_request = functools.partial(
google/cloud/storage/bucket.py:            client._connection.api_request, timeout=timeout, retry=retry
google/cloud/storage/bucket.py:            api_request=api_request,
google/cloud/storage/bucket.py:        client._connection.api_request(
google/cloud/storage/bucket.py:        client._connection.api_request(
google/cloud/storage/bucket.py:        copy_result = client._connection.api_request(
google/cloud/storage/bucket.py:        info = client._connection.api_request(
google/cloud/storage/bucket.py:        info = client._connection.api_request(
google/cloud/storage/bucket.py:        resp = client._connection.api_request(
google/cloud/storage/bucket.py:        api_response = client._connection.api_request(
google/cloud/storage/hmac_key.py:            self._client._connection.api_request(
google/cloud/storage/hmac_key.py:        self._properties = self._client._connection.api_request(
google/cloud/storage/hmac_key.py:        self._properties = self._client._connection.api_request(
google/cloud/storage/hmac_key.py:        self._client._connection.api_request(
google/cloud/storage/notification.py:        self._properties = client._connection.api_request(
google/cloud/storage/notification.py:            client._connection.api_request(
google/cloud/storage/notification.py:        response = client._connection.api_request(
google/cloud/storage/notification.py:        client._connection.api_request(

@tseaver tseaver reopened this May 4, 2021
tseaver added a commit that referenced this issue Jun 8, 2021
tseaver added a commit that referenced this issue Jun 8, 2021
Also, adjust tests for 'Bucket.list_blobs' not to depend on anything but
calling 'Client.list_blobs'.

Toward #38
tseaver added a commit that referenced this issue Jun 8, 2021
Also, provide explicit coverage for 'client._item_to_bucket' and
'client._item_to_hmack_key_metadata' helpers.

Toward #38
tseaver added a commit that referenced this issue Jun 8, 2021
Also, provide explicit coverage for 'bucket._item_to_notification'.

Toward #38
tseaver added a commit that referenced this issue Jun 8, 2021
tseaver added a commit that referenced this issue Jun 8, 2021
Also, adjust tests for 'Bucket.list_blobs' not to depend on anything but
calling 'Client.list_blobs'.

Toward #38
tseaver added a commit that referenced this issue Jun 8, 2021
Also, provide explicit coverage for 'client._item_to_bucket' and
'client._item_to_hmack_key_metadata' helpers.

Toward #38
tseaver added a commit that referenced this issue Jun 8, 2021
Also, provide explicit coverage for 'bucket._item_to_notification'.

Toward #38
tseaver added a commit that referenced this issue Jun 8, 2021
* Adjust tests for 'Bucket.list_blobs' not to depend on anything but calling 'Client.list_blobs'.
* Provide explicit coverage for 'client._item_to_bucket' and 'client._item_to_hmack_key_metadata' helpers.
* Provide explicit coverage for 'bucket._item_to_notification'.

Toward #38
@tseaver tseaver removed their assignment Sep 30, 2021
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
Use an explicit helper client method for `GET` requests, rather than manipulating client's private `_connection.api_request`.  As a benefit, tests get *way* clearer.

Toward googleapis#38

~~Based on top of the branch from googleapis#430.  I will rebase when that PR merges.~~
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
Add retry support to 'ACL.save', 'ACL.save_predefined', and 'ACL.clear'.

Add 'timeout' and 'retry' support to 'Blob.make_private'.

Toward googleapis#38.
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
Also, forward 'retry' through when deleting blobs during 'Bucket.delete'.

Toward googleapis#38.
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
* Adjust tests for 'Bucket.list_blobs' not to depend on anything but calling 'Client.list_blobs'.
* Provide explicit coverage for 'client._item_to_bucket' and 'client._item_to_hmack_key_metadata' helpers.
* Provide explicit coverage for 'bucket._item_to_notification'.

Toward googleapis#38
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
Use an explicit helper client method for `GET` requests, rather than manipulating client's private `_connection.api_request`.  As a benefit, tests get *way* clearer.

Toward googleapis#38

~~Based on top of the branch from googleapis#430.  I will rebase when that PR merges.~~
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
Add retry support to 'ACL.save', 'ACL.save_predefined', and 'ACL.clear'.

Add 'timeout' and 'retry' support to 'Blob.make_private'.

Toward googleapis#38.
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
Also, forward 'retry' through when deleting blobs during 'Bucket.delete'.

Toward googleapis#38.
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
cojenco pushed a commit to cojenco/python-storage that referenced this issue Oct 13, 2021
* Adjust tests for 'Bucket.list_blobs' not to depend on anything but calling 'Client.list_blobs'.
* Provide explicit coverage for 'client._item_to_bucket' and 'client._item_to_hmack_key_metadata' helpers.
* Provide explicit coverage for 'bucket._item_to_notification'.

Toward googleapis#38
@cojenco
Copy link
Contributor

cojenco commented Aug 10, 2022

I believe the refactor is complete through #431 #436 #441 #442 #443 #446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants