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

Feat: Add "auto" checksum option and make default #1383

Merged
merged 5 commits into from
Nov 21, 2024

Conversation

andrewsg
Copy link
Contributor

No description provided.

@andrewsg andrewsg requested review from a team as code owners November 16, 2024 06:03
@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 Nov 16, 2024
@andrewsg andrewsg force-pushed the 3.0-checksum-defaults branch from 7c76ff3 to a82d9b8 Compare November 16, 2024 06:11
@andrewsg andrewsg force-pushed the 3.0-checksum-defaults branch from a82d9b8 to 25e1109 Compare November 18, 2024 18:18
Copy link
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.

LGTM, thanks for adding clear documentation too! Just a question on adding a parametrized checksum "auto" to the system test.

downloads and None for most uploads. Note that ranged downloads ("start" or
"end" set) still do not support any checksumming, and some features in
`transfer_manager.py` still support crc32c only.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this! This will make 3.0 release notes really clear

if self.checksum == "auto":
self.checksum = (
"crc32c" if _helpers._is_crc32c_available_and_fast() else "md5"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like how this is handled in the constructor 🎉

google/cloud/storage/_media/_helpers.py Show resolved Hide resolved
@@ -191,7 +191,7 @@ def test_constructor_defaults(self):
upload = _upload.MultipartUpload(MULTIPART_URL)
assert upload.upload_url == MULTIPART_URL
assert upload._headers == {}
assert upload._checksum_type is None
assert upload._checksum_type == "crc32c" # converted from "auto"
Copy link
Contributor

Choose a reason for hiding this comment

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

nice 😄

@@ -62,7 +64,7 @@ class CorruptingAuthorizedSession(tr_requests.AuthorizedSession):
"""

EMPTY_MD5 = base64.b64encode(hashlib.md5(b"").digest()).decode("utf-8")
crc32c = _helpers._get_crc32c_object()
crc32c = google_crc32c.Checksum()
Copy link
Contributor

Choose a reason for hiding this comment

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

For system tests, maybe we can add a parametrized checksum "auto" here?

@pytest.mark.parametrize("checksum", ["md5", "crc32c", None])
def test_download_full(self, add_files, authorized_transport, checksum):

Can do the same for an upload integration test here as well

@pytest.mark.parametrize("checksum", ["md5", "crc32c", None])
def test_multipart_upload(authorized_transport, bucket, cleanup, checksum):

@andrewsg andrewsg force-pushed the 3.0-checksum-defaults branch from b2bb316 to c4201c6 Compare November 21, 2024 01:38
@andrewsg andrewsg merged commit 8d32f25 into 3.0-devel Nov 21, 2024
7 checks passed
@andrewsg andrewsg deleted the 3.0-checksum-defaults branch November 21, 2024 01:53
@andrewsg andrewsg mentioned this pull request Dec 12, 2024
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: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants