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

wr.s3.list_objects not able to limit results by setting s3_additional_kwargs={"MaxKeys": num} #955

Closed
mccauleyp opened this issue Oct 11, 2021 · 2 comments · Fixed by #963
Assignees
Labels
bug Something isn't working minor release Will be addressed in the next minor release
Milestone

Comments

@mccauleyp
Copy link

Describe the bug

It's not possible to limit the number of keys returned by wr.s3.list_objects using the MaxKeys keyword from list_objects_v2 or the MaxItems keyword from the ListObjectsV2 paginator. It's getting passed through but I think isn't compatible with the paginator implementation:

https:/awslabs/aws-data-wrangler/blob/066b81a5778cca7ce5ea8d889a2fec9824d8996a/awswrangler/s3/_list.py#L97

You might consider making "PaginationConfig" configurable to the caller so that MaxItems can be set there, and/or maybe adding a flag to skip the paginator entirely if s3_additional_kwargs["MaxKeys"] < args["PaginationConfig"]["PageSize"].

P.S. Thanks for this great resource :)

Environment

Using wrangler version 2.11.0 in a Python 3.8 Lambda.

To Reproduce

This returns more than MaxKeys results:

wr.s3.list_objects(data_prefix, s3_additional_kwargs={"MaxKeys": 1})

This returns MaxKeys results:

client = boto3.client('s3')
client.list_objects_v2(Bucket=bucket, Prefix=prefix, MaxKeys=1)

Steps to reproduce the behavior.

P.S. Please do not attach files as it's considered a security risk. Add code snippets directly in the message body as much as possible.

@mccauleyp mccauleyp added the bug Something isn't working label Oct 11, 2021
@jaidisido jaidisido self-assigned this Oct 19, 2021
@jaidisido jaidisido added this to the 2.13.0 milestone Oct 19, 2021
@jaidisido
Copy link
Contributor

Thanks for raising this @mccauleyp, it will be addressed in the PR above

@mccauleyp
Copy link
Author

Awesome, thanks!

@jaidisido jaidisido linked a pull request Oct 19, 2021 that will close this issue
@jaidisido jaidisido added the minor release Will be addressed in the next minor release label Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working minor release Will be addressed in the next minor release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants