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

change error for missing crt. use list of crt checksums instead #2906

Merged
merged 7 commits into from
Apr 26, 2023

Conversation

dlm6693
Copy link
Contributor

@dlm6693 dlm6693 commented Apr 11, 2023

Follow up to #2905. Use MissingDependencyException and check against extendible list of CRT checksums rather than single strings. Added test to validate CRT checksum list is in sync with checksum class dictionary keys.

@codecov-commenter
Copy link

codecov-commenter commented Apr 11, 2023

Codecov Report

Patch coverage: 62.50% and project coverage change: -0.04 ⚠️

Comparison is base (25cc865) 93.44% compared to head (a280731) 93.41%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2906      +/-   ##
===========================================
- Coverage    93.44%   93.41%   -0.04%     
===========================================
  Files           63       63              
  Lines        13551    13554       +3     
===========================================
- Hits         12663    12661       -2     
- Misses         888      893       +5     
Impacted Files Coverage Δ
botocore/httpchecksum.py 93.51% <62.50%> (-0.70%) ⬇️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

_CRT_CHECKSUM_CLS = {
"crc32": CrtCrc32Checksum,
"crc32c": CrtCrc32cChecksum,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Saving this to a variable instead lets us validate the keys match the hardcoded list when the CRT is present.

We can't take the list of keys when the CRT is present because it will be empty and is needed for the custom exception.

@dlm6693 dlm6693 requested a review from nateprewitt April 11, 2023 20:15
if not HAS_CRT and algorithm_name in crt_supported_algorithms:
raise MissingDependencyException(
msg=(
"Using CRC32C requires an additional dependency. You will "
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Using CRC32C requires an additional dependency. You will "
f"Using {algorithm_name} requires an additional dependency. You will "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upper cased here for styling. They're upper cased in the documentation as well so I think it should be like that as well in the error message surfaced to the user.

Comment on lines 549 to 555
@requires_crt()
def test_checksum_cls_crt_supported_algorithms_in_sync(self):
self.assertEqual(
sorted(_CRT_SUPPORTED_CHECKSUM_ALGORITHMS),
sorted(list(_CRT_CHECKSUM_CLS.keys())),
)

Copy link
Contributor

Choose a reason for hiding this comment

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

I know Jojo has tests checking _CHECKSUM_CLS but ideally we're minimizing access to private variables in our tests. This seems fine as a runtime check as it's minimal impact and will be caught in the CRT test suite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just curious, can you explain the preference of calling the assertion at runtime instead of exposing a private variable in the test suite? Is this just a design principle or is there potential risk to exposing private attributes outside of runtime?

@nateprewitt nateprewitt merged commit e337519 into boto:develop Apr 26, 2023
@dlm6693 dlm6693 deleted the crc32c-no-crt branch April 26, 2023 15:55
aws-sdk-python-automation added a commit that referenced this pull request Apr 26, 2023
* release-1.29.121:
  Bumping version to 1.29.121
  Update to latest partitions and endpoints
  Update to latest models
  Fix error for when crt is missing(#2906)
  remove xml example files for SQS in preparation of switch to AWS JSON protocol (#2917)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants