Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions dataretrieval/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,15 @@ def _attach_datetime_columns(df: pd.DataFrame) -> pd.DataFrame:


class BaseMetadata:
"""Base class for metadata.
"""Base class for the metadata returned alongside a service's data.

A concrete value object holding the response URL, query time, and headers;
the modern ``waterdata`` getters return it directly.

``site_info`` and ``variable_info`` are legacy hooks: the ``nwis`` / ``wqp``
metadata subclasses override them to look up site (or, historically,
variable) details for the query. They are not part of the modern
``waterdata`` contract, so on the base they raise ``NotImplementedError``.

Attributes
----------
Expand All @@ -212,7 +220,6 @@ class BaseMetadata:
Response elapsed time
header: httpx.Headers
Response headers

"""

def __init__(self, response) -> None:
Expand Down
7 changes: 7 additions & 0 deletions dataretrieval/wqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,13 @@ def site_info(self) -> tuple[DataFrame, WQP_Metadata] | None:
return None
return what_sites(siteid=siteid)

@property
def variable_info(self) -> None:
"""WQP exposes no variable/parameter catalog through metadata, so this
is always ``None`` (overriding the :class:`~dataretrieval.utils.BaseMetadata`
stub, which would otherwise raise ``NotImplementedError``)."""
return None


def _check_kwargs(kwargs):
"""Private function to check kwargs for unsupported parameters."""
Expand Down
7 changes: 7 additions & 0 deletions tests/wqp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ def test_wqp_metadata_site_info_is_accessible_property():
assert _wqp_metadata().site_info is None # must NOT raise


def test_wqp_metadata_variable_info_is_none():
"""Regression: WQP has no variable catalog, so ``variable_info`` must
return ``None`` rather than inheriting (and raising) the
``BaseMetadata.variable_info`` NotImplementedError stub."""
assert _wqp_metadata().variable_info is None # must NOT raise


def test_wqp_metadata_site_info_routes_to_what_sites(monkeypatch):
"""When the query carried a ``siteid`` (WQP's site identifier),
``site_info`` delegates to ``wqp.what_sites`` with that identifier."""
Expand Down
Loading