Skip to content
Snippets Groups Projects
Commit d5d6ec9f authored by Romin's avatar Romin :eye:
Browse files

Fix pagination limit

parent b2a6b5f9
No related branches found
No related tags found
No related merge requests found
......@@ -80,3 +80,13 @@ For more information on launching parallel tasks with python refer to
The Client uses caching internally. Sometimes you may run into cache consistency issues.
To clear the cache use:
`ApiClient.session.cache.clear()`
## Pagination
Coscine deals out large amounts of data in a paginated way. The Coscine Python
SDK uses the maximum page size of 50 entries per page. The amount of pages
that can be fetched by the SDK is soft-limited. Upon initialization of the
ApiClient instance, the `max_pages` argument can be set to an appropriate
amount. By default it is set to `65535` and may either be restricted
or extended. The default values allows one to fetch `65535*50=3276750` items.
The limit can be adjusted at runtime by accessing the `max_pages` attribute
of an ApiClient object.
......@@ -12,4 +12,4 @@ Coscine Python SDK package metadata
__author__ = "RWTH Aachen University"
__copyright__ = "RWTH Aachen University"
__license__ = "MIT License"
__version__ = "0.11.4"
__version__ = "0.11.5"
......@@ -166,7 +166,7 @@ class ApiResponse:
response = self
request = self.request
page = 1
while response.has_next and page < 20:
while response.has_next and page < self.client.max_pages:
page += 1
request.params["PageNumber"] = page
response = self.client.send_request(request)
......@@ -296,7 +296,8 @@ class ApiClient:
verify_certificate: bool = True,
timeout: float = 60.0,
retries: int = 3,
use_native: bool = True
use_native: bool = True,
max_pages: int = 65535
) -> None:
self.base_url = base_url
self.language = language
......@@ -336,6 +337,7 @@ class ApiClient:
self.verbose = verbose
self.verify = verify_certificate
self.native = use_native
self.max_pages = max_pages
if not verify_certificate:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if self.verbose:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment