Skip to content

Commit 566ef86

Browse files
thodson-usgsclaude
andauthored
chore!: remove the nadp module and the deprecated samples shim (#330)
Ahead of the 1.2.0 release (which allows breaking changes), remove two deprecated modules and every reference to them except the changelog: - `dataretrieval.nadp` — deprecated 2026-05-01. NADP is not a USGS data source; retrieve NADP data directly from https://nadp.slh.wisc.edu/. - `dataretrieval.samples` — the `get_usgs_samples` shim that only forwarded to `waterdata.get_samples()`. Use `waterdata.get_samples()` directly. Deleted: both modules, `tests/nadp_test.py`, and their reference doc pages `docs/source/reference/{nadp,samples}.rst`. Updated references: the `nadp` API-toctree entry, the two NADP rows in the data-portals table, the `nadp`/`samples` entries in `dataretrieval/__init__` (imports, `__all__`, the module-list docstring), the `nadp` mentions in the shared `exceptions`/`utils` docstrings, and the `nadp_test` note in AGENTS.md. A NEWS.md entry records the removal. The modern `waterdata.get_samples()` / `get_samples_summary()` and their demo notebooks are untouched — only the deprecated `samples` shim is removed. (Rebased onto main: the `ngwmn` module + OGC engine added in #324 are kept; the `samples.rst` autodoc page main added for the now-removed module is dropped.) BREAKING CHANGE: `import dataretrieval.nadp` and `import dataretrieval.samples` now raise ModuleNotFoundError; `samples.get_usgs_samples` is gone — use `waterdata.get_samples()`. Claude-Session: https://claude.ai/code/session_01Sjb14HkwuCydKSKMsaXsgd Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5b4c1f0 commit 566ef86

12 files changed

Lines changed: 6 additions & 352 deletions

File tree

AGENTS.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
## Testing Gotchas
2323
- Tests mock HTTP with `pytest-httpx`'s `httpx_mock` fixture and fixtures under `tests/data/`; keep new API tests offline. `tests/conftest.py` relaxes the fixture's strict-mode defaults (unused mocks and unmocked requests are tolerated) so rerun-on-failure works.
2424
- `tests/nwis_test.py::test_nwis_service_live` hits live NWIS.
25-
- `tests/nadp_test.py` is module-skipped (NADP deprecated).
2625
- `tests/waterdata_test.py` and `tests/waterdata_ratings_test.py` skip on Python <3.10, so a 3.9 run does not cover them.
2726

2827
## Implementation Notes

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
**06/23/2026:** **Breaking change (1.2.0):** removed the `nadp` module and the deprecated `samples` module ahead of the 1.2.0 release. `nadp` was deprecated on 05/01/2026 — NADP is not a USGS data source, so retrieve NADP data directly from https://nadp.slh.wisc.edu/. The `samples.get_usgs_samples` shim (a deprecated forward to the modern getter) is gone; use `waterdata.get_samples()` instead. `import dataretrieval.nadp` / `import dataretrieval.samples` now raise `ModuleNotFoundError`.
2+
13
**06/03/2026:** The request-error hierarchy is now unified. Every module (`nwis`, `wqp`, `nldi`, `waterdata`, `nadp`, `streamstats`) raises a subclass of `dataretrieval.DataRetrievalError` on a failed request, so a single `except dataretrieval.DataRetrievalError` spans them all. An HTTP error status surfaces as an `HTTPError` carrying `.status_code` (inspect it to branch on a specific code); the retryable 429/5xx subset is `TransientError` (`RateLimited` / `ServiceUnavailable`, carrying `.retry_after`); and a request too large to satisfy is a `RequestTooLarge` (`URLTooLong` for an over-long single request, `Unchunkable` when the Water Data chunker cannot split a call small enough). Connection-level failures (timeouts, DNS, refused connections) are wrapped as a `NetworkError`, with the underlying `httpx` exception on `__cause__`. Every `DataRetrievalError` also exposes `.status_code` (`None` when there is no HTTP status), `.retry_after`, and `.retryable`, so a single `except dataretrieval.DataRetrievalError as e` clause can branch on the status or retry transient failures without knowing the concrete subclass. **Breaking change:** these exceptions no longer multiply-inherit a built-in — code that caught request failures with `except ValueError` or `except RuntimeError` should switch to `except dataretrieval.DataRetrievalError` (or a specific subclass). A no-data result is **not** an error: the modern getters (`waterdata`, `wqp`, `nldi`) return an empty DataFrame when nothing matches. Only the deprecated `nwis` (waterservices) path still raises `NoSitesError` on no data.
24

35
**05/17/2026:** The OGC `waterdata` getters (`get_daily`, `get_continuous`, `get_field_measurements`, and the rest of the multi-value-capable functions) now transparently chunk requests whose URLs would otherwise exceed the server's ~8 KB byte limit.

dataretrieval/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
df, meta = nwis.get_dv(sites="05427718")
1212
1313
Available service modules: ``waterdata``, ``wqp`` (Water Quality Portal),
14-
``nldi``, ``samples``, ``streamstats``, and the deprecated ``nwis`` and
15-
``nadp``.
14+
``nldi``, ``streamstats``, and the deprecated ``nwis``.
1615
1716
``nldi`` requires geopandas (``pip install dataretrieval[nldi]``) and is
1817
imported on demand: ``from dataretrieval import nldi``.
@@ -58,10 +57,8 @@
5857

5958
from . import (
6059
exceptions,
61-
nadp,
6260
ngwmn,
6361
nwis,
64-
samples,
6562
streamstats,
6663
utils,
6764
waterdata,
@@ -70,10 +67,8 @@
7067

7168
__all__ = [
7269
# service modules
73-
"nadp",
7470
"ngwmn",
7571
"nwis",
76-
"samples",
7772
"streamstats",
7873
"utils",
7974
"waterdata",

dataretrieval/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Exception taxonomy for ``dataretrieval``.
22
3-
Every service module (``nwis``, ``wqp``, ``nldi``, ``waterdata``, ``nadp``,
3+
Every service module (``nwis``, ``wqp``, ``nldi``, ``waterdata``,
44
``streamstats``) raises a subclass of :class:`DataRetrievalError` when a request
55
fails, so one ``except dataretrieval.DataRetrievalError`` catches them all --
66
including connection-level failures (timeouts, DNS, refused connections), which
@@ -267,7 +267,7 @@ def error_for_status(
267267
"""Return the typed :class:`DataRetrievalError` for an HTTP error *status*.
268268
269269
The one status-to-type mapping every request path shares (the legacy
270-
``query`` path, ``waterdata``, ``nadp`` / ``streamstats``), so a given status
270+
``query`` path, ``waterdata``, ``streamstats``), so a given status
271271
becomes the same type everywhere:
272272
273273
* **413, 414** -> :class:`URLTooLong` (a :class:`RequestTooLarge`) -- the

dataretrieval/nadp.py

Lines changed: 0 additions & 235 deletions
This file was deleted.

dataretrieval/samples.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

dataretrieval/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def _raise_for_status(response: httpx.Response) -> None:
311311
"""Raise the typed :class:`DataRetrievalError` for an HTTP error response;
312312
return ``None`` on success.
313313
314-
Shared by the legacy :func:`query` path (and ``nadp`` / ``streamstats``).
314+
Shared by the legacy :func:`query` path (and ``streamstats``).
315315
Delegates the status-to-type mapping to
316316
:func:`dataretrieval.exceptions.error_for_status`, except a too-long-URL
317317
status (413 / 414): that gets the same actionable "split your query"

docs/source/reference/index.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ API reference
88
:maxdepth: 1
99

1010
exceptions
11-
nadp
1211
ngwmn
1312
nldi
1413
nwis
15-
samples
1614
streamstats
1715
utils
1816
waterdata

docs/source/reference/nadp.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/source/reference/samples.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)