Skip to content

test(waterdata): assert documented columns match the collection schema - #424

Draft
thodson-usgs wants to merge 3 commits into
DOI-USGS:mainfrom
thodson-usgs:test/documented-properties-monitor
Draft

thodson-usgs wants to merge 3 commits into
DOI-USGS:mainfrom
thodson-usgs:test/documented-properties-monitor

Conversation

@thodson-usgs

@thodson-usgs thodson-usgs commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #422 and #423. This PR's single commit also contains their changes. Review tests/waterdata_properties_test.py, the NEWS.md entry and the tests/contracts/README.md line; the rest belongs to #422 and #423 and will drop out of the diff once they merge.

Why

get_daily, get_continuous and get_time_series_metadata list their returned columns in the properties docstring. The list is hand-written, and it had gone stale twice without anything noticing:

Collection Missing column Fixed in
continuous method_category #423
time-series-metadata data_gap_interval #422

The queryables monitor catches new filters, but nothing checks the documented columns.

Change

tests/waterdata_properties_test.py is a live test that compares each getter's list with the collection's /schema. When they differ, it names the docstring to edit. The getter-to-collection table is written out rather than discovered, so a getter that loses its list fails the test instead of being skipped. id is excluded on both sides, because only time-series-metadata lists it in its schema even though all three accept it.

This test detects drift; it does not generate the list. Generating it would make the docs build depend on the live service and would not update help() or IDE tooltips, where these lists are read.

Verification

  • All gates pass. Offline 1178 passed; live monitors pass.
  • Against the pre-fix docstrings, the test failed on continuous and time-series-metadata and passed on daily.

🤖 Generated with Claude Code

@thodson-usgs
thodson-usgs force-pushed the test/documented-properties-monitor branch from d72f7f4 to 55e13d4 Compare September 23, 2026 02:32
thodson-usgs added a commit to thodson-usgs/dataretrieval-python that referenced this pull request Sep 23, 2026
Comparing each collection's /schema with its getter's signature found 20
returned columns that were reachable only through **queryables, so the
getter documented neither the column nor the filter:

- get_field_measurements: control_condition, day,
  field_measurements_series_id, measurement_rated, month, reading_type,
  time_of_day, year
- get_peaks: qualifier, time_of_day, value
- get_monitoring_locations: revision_created, revision_modified,
  revision_note
- get_combined_metadata: data_gap_interval, reading_type
- get_time_series_metadata: data_gap_interval, parameter_description
- get_field_measurements_metadata: reading_type
- get_channel: channel_location_direction

Each is now a named parameter, described in the service's own words. day,
month and year take the integer annotation get_peaks already uses. The
monitoring-location attributes every collection accepts as filters but
does not return stay in **queryables. Existing calls send the same
request as before.

Stacked: this commit also carries DOI-USGS#422 (Water Data API v1), DOI-USGS#423
(continuous method_category and the API-version monitor) and DOI-USGS#424 (the
documented-columns monitor), which merge first.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@thodson-usgs
thodson-usgs force-pushed the test/documented-properties-monitor branch from 55e13d4 to 4f81930 Compare September 23, 2026 02:36
thodson-usgs and others added 3 commits September 24, 2026 09:13
…n setting

The Water Data OGC collections moved to v1 in September 2026; v0 stays
online until June 2027. Every OGC request now goes to /ogcapi/v1.
Statistics and STAC stay on v0, because neither has a v1.

The version is a setting, like base_url, not a getter parameter.
WaterdataConfiguration gains api_version, which can be set in a
configure() block or in the [waterdata] table of the configuration file,
but not from the environment. The file now refuses the settings in
BLOCK_ONLY_SETTINGS rather than all of ADAPTER_ONLY_SETTINGS: base_url
can send requests to another host, and a version cannot.

v1 drops four time-series-metadata queryables (begin_utc, end_utc,
state_name, hydrologic_unit_code) and answers 400 or 500 to them.
get_time_series_metadata sends a call that names any of them (state
resolves to state_name) to v0 and emits a DeprecationWarning; the removal
date is 2027-06-01, when the service retires v0. The v0 URL is set per
request, through an api_version argument to ogc_api_url() and
get_ogc_data(), rather than by entering configure(), so it never
overrides a version the caller set.

Two behavior changes, both in NEWS: time-series-metadata begin/end are
UTC with a time zone, and get_field_measurements returns time as a date.
v1 also adds statistics_begin to time-series-metadata. The queryables
snapshot and the time-series-metadata fixture are regenerated from v1.

Closes DOI-USGS#421.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
USGS added method_category to the continuous collection in September
2026, which failed the nightly queryables snapshot test. It is the RLMS
method category code (STNRD, LMTUS, EXPER, UNKWN). It is returned on
every record and is null for time series that have not been categorized.
latest-continuous does not have it.

- Regenerate waterdata_queryables.json and the continuous fixture.
- Add method_category to get_continuous's signature, its docstring, and
  its list of returned columns.
- Add live tests for the API version each Water Data family serves. The
  OGC and STAC versions are read from the self link in each root
  document, because OGC answers 200 for any version segment. Statistics
  has no root document, so the next version is probed. A second test
  checks that the version the package requests still returns data.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
get_daily, get_continuous and get_time_series_metadata list their
returned columns in the properties docstring. The lists are written by
hand and went out of date twice without any test failing: continuous was
missing method_category (DOI-USGS#423), and time-series-metadata was missing
data_gap_interval (DOI-USGS#422).

Add a live test that compares each list with the collection's /schema
and names the docstring to edit when they differ. id is excluded from
both sides: only time-series-metadata lists it in its schema, though all
three collections accept it.

Stacked on DOI-USGS#422 and DOI-USGS#423, which merge first; review this commit alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
thodson-usgs added a commit to thodson-usgs/dataretrieval-python that referenced this pull request Sep 24, 2026
Comparing each collection's /schema with its getter's signature found 20
returned columns that could be passed only through **queryables, so the
getter documented neither the column nor the filter:

- get_field_measurements: control_condition, day,
  field_measurements_series_id, measurement_rated, month, reading_type,
  time_of_day, year
- get_peaks: qualifier, time_of_day, value
- get_monitoring_locations: revision_created, revision_modified,
  revision_note
- get_combined_metadata: data_gap_interval, reading_type
- get_time_series_metadata: data_gap_interval, parameter_description
- get_field_measurements_metadata: reading_type
- get_channel: channel_location_direction

Each is now a named parameter, described in the service's own words. day,
month and year are typed as integers, as get_peaks already types them.
The monitoring-location attributes that every collection accepts as
filters but does not return stay in **queryables. Existing calls send
the same request as before.

Stacked on DOI-USGS#422, DOI-USGS#423 and DOI-USGS#424, which merge first; review this commit
alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@thodson-usgs
thodson-usgs force-pushed the test/documented-properties-monitor branch from 4f81930 to 016025a Compare September 24, 2026 14:29

This branch has not been deployed

No deployments
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