-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add page_size arg to list_subscriptions() #1096
Conversation
Would it make sense to add page_size to the CLI for parody with the client? |
@HenryW95 yes, added! |
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 |
@HenryW95 Updated 👍 |
This MR adds a new
page_size
arg 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.py
that I used to test and record execution times: