Skip to content

fix(waterdata): scope the ratings catalog search to its collection - #474

Merged
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/ratings-scope-collection
Nov 24, 2026
Merged

thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/ratings-scope-collection

Conversation

@thodson-usgs

@thodson-usgs thodson-usgs commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

waterdata.get_ratings() sends STAC /search without collections=. /search spans every collection in the catalog. In October 2026 USGS added daily and continuous (announcement), so those items now match too.

Ratings items and the new items share monitoring_location_id. When file_type is a list, no server-side file_type filter is sent, and with download_and_parse=False the raw items are returned unfiltered:

waterdata.get_ratings(
    monitoring_location_id="USGS-01104475",
    file_type=["exsa", "corr"],
    download_and_parse=False,
)
# before: 5 items: 3 ratings, plus the site's daily and continuous items
# after:  3 ratings items

A single file_type was not affected. Neither was the default download_and_parse=True, which filters items by file_type locally, although it still fetched the extra items.

Fix

Send collections=ratings with every search. The diff is one parameter, a regression test that checks the sent query, and a NEWS entry.

Checks

  • Live: the call above returns 3 ratings items, and the download path returns the exsa and corr frames.
  • ruff, ruff format, mypy, lint-imports, xenon, complexipy, and pre-commit pass. 1661 tests pass, and coverage is 99.05%.

This also lands in #475 as part of moving the search into a shared module. This PR is the minimal version so the fix can merge first.

get_ratings() sent /search with no collections= parameter, and /search
spans every collection in the Water Data STAC catalog. Since USGS added
the daily and continuous collections in October 2026, a call with a list
of file types (which sends no server-side file_type filter) also returned
each monitoring location's daily and continuous items when
download_and_parse=False: USGS-01104475 with file_type=["exsa", "corr"]
returned 5 items instead of 3.

Send collections=ratings with every search.
@thodson-usgs thodson-usgs added the v1 Non-breaking: can merge for the next 1.x release label Nov 23, 2026
@thodson-usgs
thodson-usgs marked this pull request as ready for review November 24, 2026 19:10
@thodson-usgs
thodson-usgs merged commit 6a00922 into DOI-USGS:main Nov 24, 2026
11 checks passed
@thodson-usgs
thodson-usgs deleted the fix/ratings-scope-collection branch November 24, 2026 19:10
thodson-usgs added a commit to thodson-usgs/dataretrieval-python that referenced this pull request Dec 1, 2026
- catalog: build each search through ogc.planning._try_build, so a filter
  over the 64 KB httpx can put in one URL component raises the ValueError
  with its remedy instead of httpx.InvalidURL.
- One _as_list, in catalog, for ratings, catalog.search and _retrieval.
- catalog.__all__ lists the names the bulk modules import.
- One masked renderer for api_key and files_api_key in show_configuration.
- ogc.errors._error_body reads the request URL and its key variables once.
- _change_clauses builds the set of changing locations once and floors the
  cutoffs as one DatetimeIndex.
- Without geopandas, the file rows' geometry is looked up once per location
  (pd.factorize), as with geopandas, instead of Series.map per row.
- qualifier: only the non-null lists are converted to Python objects
  (1.4M rows, 3% non-null: 27 ms to 12 ms).
- Wording: "the bulk getters" instead of "the files route".
- Tests: the ratings scoping test duplicated DOI-USGS#474's and is removed; the
  world-readable warning test covers both keys; the no-pyarrow fixture
  leaves conftest for a monkeypatch in its one test; _response uses
  inert_response.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Non-breaking: can merge for the next 1.x release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant