Skip to content

fix(wqp): repair WQP_Metadata.site_info (was always None)#305

Draft
thodson-usgs wants to merge 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/wqp-site-info
Draft

fix(wqp): repair WQP_Metadata.site_info (was always None)#305
thodson-usgs wants to merge 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/wqp-site-info

Conversation

@thodson-usgs
Copy link
Copy Markdown
Collaborator

Problem

WQP_Metadata.site_info never returned anything — it was always None, for every query. Two compounding bugs:

  1. The call sites passed no parameters. All nine WQP getters built WQP_Metadata(response) (no **kwargs), so self._parameters was always {} and the property always fell through to else: return None. NWIS does it correctly — NWIS_Metadata(response, **kwargs). (PR fix: repair WQP_Metadata.site_info and streamstats.Watershed #295 fixed the property's location — it had been a discarded local function nested in __init__ — but the call sites still dropped the params, so the feature remained dead; that PR's test even asserted site_info is None, which masked it.)

  2. The property keyed on the wrong parameter. It checked sites/site/site_no and called what_sites(sites=...), but WQP's site identifier is siteid (per the docstring and tests, e.g. get_results(siteid="WIDNR_WQX-10032762")). So even with params threaded through, it could never match a real WQP query.

Fix

  • All getters now pass the query kwargs: WQP_Metadata(response, **kwargs).
  • site_info keys on siteid and calls what_sites(siteid=...).
  • Corrected the class docstring (comment not comments; WQP_Metadata not NWIS_Metadata; siteid not sites).

Verification

  • Live API: df, md = what_sites(siteid="WIDNR_WQX-10032762")md._parameters now carries siteid, and md.site_info returns a populated (DataFrame, WQP_Metadata) tuple (previously None).
  • Tests: updated the routing test to the correct siteid key; added a regression assertion that get_results threads siteid into the metadata. All 14 wqp tests pass; ruff clean.

Note: accessing md.site_info issues a live what_sites request (by design) and carries that call's legacy/WQX3 warning.

🤖 Generated with Claude Code

WQP_Metadata.site_info never returned anything. Two compounding bugs:

1. All nine getters built WQP_Metadata(response) with no parameters, so
   self._parameters was always {} and the property always hit the
   `else: return None` branch -- even for a get_results(siteid=...) query.
   (PR DOI-USGS#295 fixed the property's *location* -- it had been a discarded local
   function inside __init__ -- but the call sites still passed no params, so
   the feature stayed dead.) NWIS does it right: NWIS_Metadata(response,
   **kwargs).

2. The property keyed on `sites`/`site`/`site_no` and called
   what_sites(sites=...), but WQP's site identifier parameter is `siteid`, so
   it could never have matched a real WQP query even with params threaded in.

Fixes:
- All getters now pass the query kwargs: WQP_Metadata(response, **kwargs).
- site_info keys on `siteid` and calls what_sites(siteid=...).
- Corrected the class docstring (comment not comments; WQP_Metadata not
  NWIS_Metadata; siteid not sites).
- Updated the routing test to the correct `siteid` key and added a regression
  assertion that get_results threads siteid into the metadata.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant