Skip to content

Simplify WQP module to share internal functions - #394

Merged
ehinman merged 6 commits into
DOI-USGS:mainfrom
ehinman:simplify-wqp-mod
Aug 27, 2026
Merged

ehinman merged 6 commits into
DOI-USGS:mainfrom
ehinman:simplify-wqp-mod

Conversation

@ehinman

@ehinman ehinman commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Drafted by Kiro. This MR allows all WQP functions to leverage the same internal function, _query_wqp, which validates service + profile, makes the API request, detects and formats datetime columns, and creates a metadata object. Reduces redundant code.

@ehinman
ehinman requested a review from thodson-usgs August 26, 2026 17:31
Fold the WQX3 Result default into _PROFILE_RULES so the table is the
single source of every per-service dataProfile fact, flatten the
validation to one branch per fact, and rename endpoint -> service to
match the vocabulary the rest of the module and its error messages use.
_resolve_profile now returns the payload like its neighbour _check_kwargs
rather than writing into the caller's dict behind a check-shaped name.

Tests: drive the profile parametrize off activity_profiles_legacy, and
replace the hand-built Activity CSV with a fixture comparison inside
test_what_query so the "only Result is post-processed" guard is pinned
for all eight what_* wrappers instead of one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@thodson-usgs thodson-usgs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The autoreview caught a glossary/adr violation and a minor bug. I went ahead and pushed the fix. Good to merge.

Both sides changed the WQP request path. upstream/main co-located the
array-filter delimiter with endpoint selection (WQX3 rejects
semicolon-joined values, so it repeats the key instead) and made
_check_kwargs materialize iterables; this branch collapsed get_results
and _what into the single _query_wqp funnel.

Resolved by keeping the funnel and porting the delimiter rule into it,
so the three-way endpoint branch now selects url and delimiter together:
legacy-only services and legacy WQX3-capable services send ";", the WQX3
interface sends None. Verified that delimiter is None exactly when the
resolved URL is a /wqx3/ one, across every service/legacy pair.

Both sides' tests were added at the same anchor and are kept in full.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ehinman
ehinman merged commit 3b2d968 into DOI-USGS:main Aug 27, 2026
11 checks passed
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.

2 participants