Skip to content

Commit

Permalink
Restore default max_items behavior
Browse files Browse the repository at this point in the history
xref stac-utils#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.
  • Loading branch information
Tom Augspurger committed Jul 25, 2022
1 parent cffb787 commit b72dc8e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed

- 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)
- Restored the previous behavior of ``.search()`` to return an unlimited number of items by default.


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

Expand Down
8 changes: 4 additions & 4 deletions pystac_client/item_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ class ItemSearch:
the response, it will automatically retry with
``"GET"`` for all subsequent requests.
max_items : The maximum number of items to return from the search, even
if there are more matching results. This client to limit the
if there are more matching results. This allows the client to limit the
total number of Items returned from the :meth:`items`,
:meth:`item_collections`, and :meth:`items_as_dicts methods`. The client
will continue to request pages of items until the number of max items is
reached. This parameter defaults to 100. Setting this to ``None`` will
allow iteration over a possibly very large number of results.
reached. By default (``max_items=None``) all items matching the query
will be returned.
stac_io: An instance of StacIO for retrieving results. Normally comes
from the Client that returns this ItemSearch client: An instance of a
root Client used to set the root on resulting Items.
Expand Down Expand Up @@ -217,7 +217,7 @@ def __init__(
url: str,
*,
method: Optional[str] = "POST",
max_items: Optional[int] = DEFAULT_LIMIT_AND_MAX_ITEMS,
max_items: Optional[int] = None,
stac_io: Optional[StacApiIO] = None,
client: Optional["_client.Client"] = None,
limit: Optional[int] = DEFAULT_LIMIT_AND_MAX_ITEMS,
Expand Down
9 changes: 9 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,12 @@ def test_json_search_link(self, api: Client) -> None:
search_link.media_type = MediaType.JSON
api.add_link(search_link)
api.search(limit=1, max_items=1, collections="naip")

def test_search_max_items_unlimited_default(self, api: Client) -> None:
search = api.search(
bbox=[-73.21, 43.99, -73.12, 45.05],
collections="naip",
datetime="2014-01-01/2020-12-31",
)
items = list(search.items())
assert len(items) > 100

0 comments on commit b72dc8e

Please sign in to comment.