Skip to content

Add SiteTypeCode and StatisticCode enums for waterdata parameters - #234

Closed
thodson-usgs wants to merge 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix-enums-site-type
Closed

thodson-usgs wants to merge 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix-enums-site-type

Conversation

@thodson-usgs

Copy link
Copy Markdown
Collaborator

Summary

  • Adds SiteTypeCode and StatisticCode as str-based enums in dataretrieval/waterdata/enums.py
  • Exports both from dataretrieval.waterdata public API
  • Both enums extend str, so existing callers passing plain strings are unaffected — the enums are purely additive
  • SiteTypeCode covers all 56 site types from get_reference_table("site-types")
  • StatisticCode covers the 17 named statistic codes (excluding the 90+ numeric percentile entries)

Usage example:

from dataretrieval.waterdata import SiteTypeCode, StatisticCode, get_monitoring_locations, get_daily

df, _ = get_monitoring_locations(site_type_code=SiteTypeCode.WELL)
df, _ = get_daily(statistic_id=StatisticCode.MEAN)

Closes #98

Test plan

  • python -m pytest tests/waterdata_test.py — all 26 tests pass
  • Live smoke test: get_monitoring_locations(state_name="Connecticut", site_type_code=SiteTypeCode.WELL) returns only GW sites
  • Verified requests serializes enum values correctly (uses native string value, not __repr__)

Exposes discoverable constants for the `site_type_code` and `statistic_id`
parameters so callers get IDE autocompletion without breaking any existing
string-based usage (both enums extend `str`).

Closes DOI-USGS#98

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thodson-usgs
thodson-usgs force-pushed the fix-enums-site-type branch from f224666 to 33bd889 Compare June 25, 2026 13:48
@thodson-usgs

Copy link
Copy Markdown
Collaborator Author

Closing as superseded.

Hardcoding SiteTypeCode / StatisticCode as static enums has been overtaken by the API-driven path on main: get_codes (#301) returns the reference tables live, and get_queryables (#333) exposes the per-collection parameter domains. A pinned enum list would now be a second source of truth that silently drifts from the service.

The PR's own module docstring points readers at get_reference_table("site-types"), which is no longer part of the public API — a good sign of how far the surface has moved since April.

If discoverable constants are still wanted for IDE autocompletion, the better shape is generating or validating them against get_codes rather than checking in a hand-maintained table. Branch fix-enums-site-type is retained.

@thodson-usgs
thodson-usgs deleted the fix-enums-site-type branch September 2, 2026 18:34
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.

enums for site type, county, etc.

1 participant