Add page_size arg to list_subscriptions()#1096
Merged
asonnenschein merged 8 commits intomainfrom Jan 31, 2025
Merged
Conversation
Contributor
|
Would it make sense to add page_size to the CLI for parody with the client? |
Contributor
Author
@HenryW95 yes, added! |
Contributor
This docs page also lists the CLI params, so it can be added there: https://github.com/planetlabs/planet-client-python/blob/main/docs/cli/cli-subscriptions.md |
Contributor
Author
@HenryW95 Updated 👍 |
HenryW95
requested changes
Jan 31, 2025
HenryW95
approved these changes
Jan 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This MR adds a new
page_sizearg to theSubscriptionsClient.list_subscriptions()method. Without specifying a page size,list_subscriptions()will fall back on a default page size of 20 subscriptions per page that is defined in the API view handler. For large numbers of subscriptions, this results in long execution times becauselist_subscriptions()is only getting 20 subscriptions per page, which results in more requests (and latency in transport) than is necessary.For example, I tested this out on a sample of 645 subscriptions. The average execution time to get all 645 subscriptions using the default page size of 20 (
list_subscriptions()) takes ~36 seconds becauselist_subscriptions()is making ~33 requests to the API:When I define a page_size of 700 (
list_subscriptions(page_size=700)) the average execution time to get all 645 subscriptions takes only ~3 seconds becauselist_subscriptions()only has to make one request to the API with the larger page size:Here is the contents of
example.pythat I used to test and record execution times: