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

request compression #2959

Merged
merged 37 commits into from
Jul 27, 2023
Merged

request compression #2959

merged 37 commits into from
Jul 27, 2023

Conversation

dlm6693
Copy link
Contributor

@dlm6693 dlm6693 commented May 26, 2023

This pull request enables request compression in the AWS Python SDK. It is on by default, but only used if the requestcompression trait is attached to the operation being called. At the moment, the only compression algorithm supported is gzip, but this is subject to change in the future. This also addresses a few typos I discovered while working on this project. Below is a summary of the new features in this PR.

  • Add request_min_compression_size_bytes setting to Config object and config file, and support for AWS_REQUEST_MIN_COMPRESSION_SIZE_BYTES environment variable.
    • If not provided by a user, the value will default to 10240. The value MUST be a parseable integer between 0 and 1048576 (1024**2).
  • Add disable_request_compression setting to Config object and config file, and support for AWS_DISABLE_REQUEST_COMPRESSION environment variable.
    • If not provided by a user, the value will default to False. If not a parseable boolean, the value will be coerced to False, similar to other config settings that are boolean types in botocore.
  • Add request_compression property to OperationModel. This will allow the SDK to check for the presence of this operation trait and run compression if so.
  • Add the compress.py file. This file contains logic that is actually responsible for compressing requests. It has one public API:
    • maybe_compress_request: This checks whether compression should be performed, actually does compression if so and injects the corresponding Content-Encoding header if needed.
  • Compression is supported for all types of bodies the SDK already supports: str, bytes, bytearray, and file-like objects like io.StringIO and io.BytesIO for example.
  • Compression is called just before flexible checksums are calculated in BaseClient._make_api_call
  • Besides the above new settings, compression will also not occur if a customer has configured signature_version to be v2
  • In order to support compression for services using the query protocol, dictionary bodies are serialized to bytes if the operation supports compression and the customer hasn't explicitly disabled compression.

@dlm6693 dlm6693 requested a review from jonemo May 26, 2023 19:13
@codecov-commenter
Copy link

codecov-commenter commented May 26, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.05% 🎉

Comparison is base (6bd4e24) 93.36% compared to head (494c7e3) 93.41%.
Report is 34 commits behind head on develop.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2959      +/-   ##
===========================================
+ Coverage    93.36%   93.41%   +0.05%     
===========================================
  Files           65       66       +1     
  Lines        13841    13948     +107     
===========================================
+ Hits         12923    13030     +107     
  Misses         918      918              
Files Changed Coverage Δ
botocore/config.py 100.00% <ø> (ø)
botocore/args.py 100.00% <100.00%> (ø)
botocore/client.py 97.68% <100.00%> (+<0.01%) ⬆️
botocore/compress.py 100.00% <100.00%> (ø)
botocore/configprovider.py 94.78% <100.00%> (ø)
botocore/model.py 98.38% <100.00%> (+0.01%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/endpoint.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jonemo jonemo left a comment

Choose a reason for hiding this comment

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

I focused on how config values are handled and the AWSRequestCompressor class so far. Taking a break now and will continue with the other parts in the next review session.

botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/configprovider.py Outdated Show resolved Hide resolved
botocore/configprovider.py Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/config.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/endpoint.py Outdated Show resolved Hide resolved
botocore/exceptions.py Outdated Show resolved Hide resolved
botocore/utils.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/awsrequest.py Outdated Show resolved Hide resolved
botocore/endpoint.py Outdated Show resolved Hide resolved
botocore/exceptions.py Outdated Show resolved Hide resolved
botocore/exceptions.py Outdated Show resolved Hide resolved
botocore/model.py Show resolved Hide resolved
botocore/utils.py Outdated Show resolved Hide resolved
@dlm6693 dlm6693 force-pushed the request-compression branch 2 times, most recently from ff749a1 to 0680e36 Compare June 6, 2023 23:00
@dlm6693 dlm6693 force-pushed the request-compression branch 5 times, most recently from 084193d to 9ef2d48 Compare July 7, 2023 17:38
botocore/args.py Outdated Show resolved Hide resolved
botocore/args.py Show resolved Hide resolved
botocore/args.py Outdated Show resolved Hide resolved
botocore/args.py Outdated Show resolved Hide resolved
botocore/compress.py Outdated Show resolved Hide resolved
botocore/compress.py Outdated Show resolved Hide resolved
botocore/compress.py Outdated Show resolved Hide resolved
botocore/config.py Outdated Show resolved Hide resolved
botocore/config.py Outdated Show resolved Hide resolved
botocore/configprovider.py Outdated Show resolved Hide resolved
tests/unit/test_utils.py Outdated Show resolved Hide resolved
tests/unit/test_compress.py Outdated Show resolved Hide resolved
tests/unit/test_compress.py Outdated Show resolved Hide resolved
botocore/compress.py Outdated Show resolved Hide resolved
botocore/args.py Outdated Show resolved Hide resolved
@dlm6693 dlm6693 removed the request for review from jonemo July 25, 2023 20:44
tests/unit/test_compress.py Outdated Show resolved Hide resolved
@dlm6693 dlm6693 requested a review from nateprewitt July 26, 2023 16:42
botocore/compress.py Show resolved Hide resolved
tests/functional/test_compress.py Outdated Show resolved Hide resolved
tests/functional/test_compress.py Outdated Show resolved Hide resolved
tests/unit/test_compress.py Outdated Show resolved Hide resolved
tests/unit/test_compress.py Show resolved Hide resolved
tests/unit/test_compress.py Outdated Show resolved Hide resolved
@nateprewitt
Copy link
Contributor

One minor comment, but once tests pass, I think this should be set.

Copy link
Contributor

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

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

Looks good pending passing tests, thanks @dlm6693!

@dlm6693 dlm6693 merged commit bf00aa7 into boto:develop Jul 27, 2023
33 checks passed
@dlm6693 dlm6693 deleted the request-compression branch July 27, 2023 23:20
aws-sdk-python-automation added a commit that referenced this pull request Jul 28, 2023
* release-1.31.14:
  Bumping version to 1.31.14
  Update to latest models
  request compression (#2959)
kyleknap added a commit to kyleknap/aws-cli that referenced this pull request Sep 25, 2023
This is a port of this pull request from the botocore repository:
boto/botocore#2959
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.

4 participants