fix(wqp): repair WQP_Metadata.site_info (was always None)#305
Draft
thodson-usgs wants to merge 1 commit into
Draft
fix(wqp): repair WQP_Metadata.site_info (was always None)#305thodson-usgs wants to merge 1 commit into
thodson-usgs wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WQP_Metadata.site_infonever returned anything — it was alwaysNone, for every query. Two compounding bugs:The call sites passed no parameters. All nine WQP getters built
WQP_Metadata(response)(no**kwargs), soself._parameterswas always{}and the property always fell through toelse: 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 assertedsite_info is None, which masked it.)The property keyed on the wrong parameter. It checked
sites/site/site_noand calledwhat_sites(sites=...), but WQP's site identifier issiteid(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
WQP_Metadata(response, **kwargs).site_infokeys onsiteidand callswhat_sites(siteid=...).commentnotcomments;WQP_MetadatanotNWIS_Metadata;siteidnotsites).Verification
df, md = what_sites(siteid="WIDNR_WQX-10032762")→md._parametersnow carriessiteid, andmd.site_inforeturns a populated(DataFrame, WQP_Metadata)tuple (previouslyNone).siteidkey; added a regression assertion thatget_resultsthreadssiteidinto the metadata. All 14wqptests pass;ruffclean.🤖 Generated with Claude Code