Skip to content

Switch WQP default profile from legacy to WQX3.0#230

Open
thodson-usgs wants to merge 3 commits intoDOI-USGS:mainfrom
thodson-usgs:switch-wqp-default-profile
Open

Switch WQP default profile from legacy to WQX3.0#230
thodson-usgs wants to merge 3 commits intoDOI-USGS:mainfrom
thodson-usgs:switch-wqp-default-profile

Conversation

@thodson-usgs
Copy link
Copy Markdown
Collaborator

@thodson-usgs thodson-usgs commented Apr 13, 2026

Closes #121

Summary

  • Changed all WQP function signatures from legacy=True to legacy=False
  • get_results, what_sites, and what_activities now route to WQX3.0 endpoints by default
  • Functions without a WQX3.0 equivalent (what_organizations, what_projects, what_detection_limits, what_habitat_metrics, what_project_weights, what_activity_metrics) emit a UserWarning when called with the default legacy=False, making it clear the user is getting legacy data
  • legacy=True still works but triggers a DeprecationWarning directing users to remove it
  • Removed the now-unnecessary _warn_wqx3_use() function (WQX3.0 is no longer experimental)

Behavior change demo (live API)

from dataretrieval.wqp import get_results

# Default: now hits the WQX3.0 endpoint
df, md = get_results(siteid="USGS-01646500", startDateLo="01-01-2024", startDateHi="03-01-2024")
print(md.url)
# https://www.waterqualitydata.us/wqx3/Result/search?siteid=USGS-01646500&...

# Explicit legacy=True still works, with a DeprecationWarning:
df, md = get_results(legacy=True, siteid="USGS-01646500", startDateLo="01-01-2024", startDateHi="03-01-2024")
# DeprecationWarning: ... Setting `legacy=False` will remove this warning.
print(md.url)
# https://www.waterqualitydata.us/data/Result/Search?siteid=USGS-01646500&...

Test plan

  • Updated test_what_sites and test_what_activities to mock WQX3.0 URLs
  • Added test_get_results_legacy to verify legacy=True triggers DeprecationWarning
  • Live verification: default get_results call routes to /wqx3/Result/search and returns data; legacy=True routes to /data/Result/Search and emits the expected DeprecationWarning.
  • All unit tests pass

Change all WQP functions from legacy=True to legacy=False so that
get_results, what_sites, and what_activities route to WQX3.0 endpoints
by default. Functions without a WQX3.0 equivalent now emit a UserWarning
instead of silently returning legacy data. legacy=True still works but
triggers a DeprecationWarning. Closes DOI-USGS#121.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thodson-usgs thodson-usgs marked this pull request as ready for review April 13, 2026 23:23
thodson-usgs and others added 2 commits May 5, 2026 10:34
Resolved conflicts in wqp.py: PR 230's intent (default legacy=False)
already preserved in function signatures. Upstream/main refactored the
inline UserWarning blocks for WQX3.0-unavailable services into the
_legacy_only_url() helper; took upstream's version everywhere. All 12
wqp tests pass.

Co-Authored-By: Claude Opus 4.7 (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.

switch default WQP services profile

1 participant