Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Chore: refactor client.download_blob_to_file#1052

Merged
andrewsg merged 7 commits intogoogleapis:tm-metricsfrom
MiaCY:transfer_manager_usage_metrics
Jun 13, 2023
Merged

Chore: refactor client.download_blob_to_file#1052
andrewsg merged 7 commits intogoogleapis:tm-metricsfrom
MiaCY:transfer_manager_usage_metrics

Conversation

@MiaCY
Copy link
Copy Markdown
Contributor

@MiaCY MiaCY commented May 25, 2023

  • Create new method blob._prep_and_do_download
  • Refactor business logic of client.download_blob_to_file into blob._prep_and_do_download
  • Refactor blob.download_to_file, blob.download_to_filename, and blob.download_as_bytes to call blob._prep_and_do_download
  • Refactor related blob and client unit tests

@MiaCY MiaCY added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label May 25, 2023
@MiaCY MiaCY requested a review from andrewsg May 25, 2023 17:53
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/python-storage API. labels May 25, 2023
Copy link
Copy Markdown
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.

We may later have to tune download_to_filename() to put the business logic of opening the file and handling exceptions behind a private barrier, but to keep things simple let's save that for after this PR.

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: m Pull request size is medium. labels Jun 6, 2023
@MiaCY MiaCY requested a review from andrewsg June 6, 2023 18:51
@MiaCY MiaCY removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 6, 2023
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Jun 7, 2023
@MiaCY MiaCY marked this pull request as ready for review June 7, 2023 20:39
@MiaCY MiaCY requested a review from a team as a code owner June 7, 2023 20:39
@MiaCY MiaCY requested a review from a team June 7, 2023 20:39
Copy link
Copy Markdown
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.

Other than the unresolved naming question, looks good!

Copy link
Copy Markdown
Contributor

@cojenco cojenco left a comment

Choose a reason for hiding this comment

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

The updated tests using the mock.patch.object context looks good 🙌
Left a few comments. Let me know if you have any questions.

Copy link
Copy Markdown
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.

Good work!

@andrewsg andrewsg merged commit 2f8716b into googleapis:tm-metrics Jun 13, 2023
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
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 <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: storage Issues related to the googleapis/python-storage API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants