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

Chore: refactor blob.upload_from_file #1063

Merged
merged 10 commits into from
Jul 10, 2023

Conversation

MiaCY
Copy link
Contributor

@MiaCY MiaCY commented Jun 21, 2023

  • Create new method blob._prep_and_do_upload
  • Refactor business logic of blob.upload_from_file into blob._prep_and_do_upload
  • Refactor blob.upload_from_file and blob.upload_from_filename to call blob._prep_and_do_upload

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/python-storage API. labels Jun 21, 2023
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: l Pull request size is large. labels Jun 21, 2023
@MiaCY MiaCY marked this pull request as ready for review June 26, 2023 18:31
@MiaCY MiaCY requested review from a team as code owners June 26, 2023 18:31
Copy link
Contributor

@andrewsg andrewsg left a comment

Choose a reason for hiding this comment

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

Oh, this is a straightforward and minimal approach. I think this is a good idea. Consider reducing the size of the private method's docstring a bit, possibly just by saying "see upload_from_file docstring for more info" if needed. Compare it to the other major private methods we have - is the docstring way too complex compared to those or is it similar? If it's similar or you think it would be confusing to reduce the size, we can just leave it as is.

I'm going to have to make unrelated changes to this area of the code soonish, so on the week of the 10th of July, let's look at merging the upload and download refactors into the main branch so there are no conflicts.

google/cloud/storage/blob.py Show resolved Hide resolved
@andrewsg andrewsg merged commit 8f08038 into googleapis:tm-metrics Jul 10, 2023
7 checks passed
andrewsg pushed a commit that referenced this pull request Sep 18, 2023
* Refactor client.download_blob_to_file

* Chore: clean up code

* refactor blob and client unit tests

* lint reformat

* Rename _prep_and_do_download

* Refactor blob.upload_from_file

* Lint reformat
cojenco added a commit that referenced this pull request Oct 19, 2023
* Chore: refactor client.download_blob_to_file (#1052)

* Refactor client.download_blob_to_file

* Chore: clean up code

* refactor blob and client unit tests

* lint reformat

* Rename _prep_and_do_download

* Chore: refactor blob.upload_from_file (#1063)

* Refactor client.download_blob_to_file

* Chore: clean up code

* refactor blob and client unit tests

* lint reformat

* Rename _prep_and_do_download

* Refactor blob.upload_from_file

* Lint reformat

* feature: add 'command' argument to private upload/download interface (#1082)

* Refactor client.download_blob_to_file

* Chore: clean up code

* refactor blob and client unit tests

* lint reformat

* Rename _prep_and_do_download

* Refactor blob.upload_from_file

* Lint reformat

* feature: add 'command' argument to private upload/download interface

* lint reformat

* reduce duplication and edit docstring

* feat: add support for custom headers starting with  metadata op

* add custom headers to downloads in client blob modules

* add custom headers to uploads with tests

* update mocks and tests

* test custom headers support tm mpu uploads

* update tm test

* update test

---------

Co-authored-by: MiaCY <97990237+MiaCY@users.noreply.github.com>
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. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants