Skip to content

Commit 4fe29cf

Browse files
author
Tom Augspurger
authored
Restore default max_items behavior (#273)
* Restore default max_items behavior xref #237 (comment) Doesn't close that issue, which also deals with the replacement for the deprecated methods. This just reverts the change to the default `max_items` to return all matching items by default. * vcr * alias
1 parent 2ec0a2d commit 4fe29cf

File tree

5 files changed

+484
-7
lines changed

5 files changed

+484
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
### Fixed
1010

1111
- Fix type annotation of `Client._stac_io` and avoid implicit re-exports in `pystac_client.__init__.py` [#249](https://github.com/stac-utils/pystac-client/pull/249)
12+
- Restored the previous behavior of ``Client.search()`` to return an unlimited number of items by default. [#273](https://github.com/stac-utils/pystac-client/pull/273)
1213
- Added `ItemSearch.item_collection()` as a replacement for the deprecated `ItemSearch.get_all_items()` [#237](https://github.com/stac-utils/pystac-client/issues/237)
1314

1415
## [v0.4.0] - 2022-06-08

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ A Python client for working with [STAC](https://stacspec.org/) Catalogs and APIs
1111

1212
## Table of Contents
1313

14+
- [Table of Contents](#table-of-contents)
1415
- [Installation](#installation)
1516
- [Documentation](#documentation)
1617
- [Development](#development)
17-
- [Pull Requests](#pull-requests)
18+
- [Pull Requests](#pull-requests)
19+
- [Benchmark](#benchmark)
1820

1921
## Installation
2022

@@ -70,7 +72,7 @@ $ git add <new files here>
7072
$ git commit -a -m 'new test episodes'
7173
```
7274

73-
To update pystac-client to use future versions of STAC API, the existing recorded API responsees
75+
To update pystac-client to use future versions of STAC API, the existing recorded API responses
7476
should be "re-recorded":
7577

7678
```shell

pystac_client/item_search.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@
7676

7777
OPS = list(OP_MAP.keys())
7878

79-
DEFAULT_LIMIT_AND_MAX_ITEMS = 100
79+
# Previously named DEFAULT_LIMIT_AND_MAX_ITEMS
80+
# aliased for backwards compat
81+
# https://github.com/stac-utils/pystac-client/pull/273
82+
DEFAUL_LIMIT = DEFAULT_LIMIT_AND_MAX_ITEMS = 100
8083

8184

8285
# from https://gist.github.com/angstwad/bf22d1822c38a92ec0a9#gistcomment-2622319
@@ -140,12 +143,12 @@ class ItemSearch:
140143
the response, it will automatically retry with
141144
``"GET"`` for all subsequent requests.
142145
max_items : The maximum number of items to return from the search, even
143-
if there are more matching results. This client to limit the
146+
if there are more matching results. This allows the client to limit the
144147
total number of Items returned from the :meth:`items`,
145148
:meth:`item_collections`, and :meth:`items_as_dicts methods`. The client
146149
will continue to request pages of items until the number of max items is
147-
reached. This parameter defaults to 100. Setting this to ``None`` will
148-
allow iteration over a possibly very large number of results.
150+
reached. By default (``max_items=None``) all items matching the query
151+
will be returned.
149152
stac_io: An instance of StacIO for retrieving results. Normally comes
150153
from the Client that returns this ItemSearch client: An instance of a
151154
root Client used to set the root on resulting Items.
@@ -217,7 +220,7 @@ def __init__(
217220
url: str,
218221
*,
219222
method: Optional[str] = "POST",
220-
max_items: Optional[int] = DEFAULT_LIMIT_AND_MAX_ITEMS,
223+
max_items: Optional[int] = None,
221224
stac_io: Optional[StacApiIO] = None,
222225
client: Optional["_client.Client"] = None,
223226
limit: Optional[int] = DEFAULT_LIMIT_AND_MAX_ITEMS,

0 commit comments

Comments
 (0)