Skip to content

fix(waterdata): accept field-measurements sublocation_identifier - #436

Merged
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/field-measurements-sublocation-identifier
Oct 7, 2026
Merged

thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/field-measurements-sublocation-identifier

Conversation

@thodson-usgs

Copy link
Copy Markdown
Collaborator

Summary

The scheduled live-API run 37105829876 failed in test_queryables_match_snapshot for field-measurements and field-measurements-metadata: USGS added a sublocation_identifier queryable to both collections. It appeared on field-measurements-metadata by the 09/30 run and on field-measurements by the 10/03 run. No other collection's queryables changed.

Following the pattern of #423 (method_category):

  • Regenerate tests/data/waterdata_queryables.json with the script in waterdata_queryables_test.py. The only change is the two sublocation_identifier entries.
  • Add sublocation_identifier as a named, documented parameter on get_field_measurements() and get_field_measurements_metadata(). Before this, it could only be passed through **queryables.
  • Add the field to the two OGC fixtures as null, which is what the live service returns for those USGS-05427718 records.
  • Add one offline test per getter checking that the parameter is sent as a filter and comes back as a column.
  • Add a NEWS entry.

The live field-measurements-metadata failure in the 09/30–10/02 runs was the same cause. Those runs also had the continuous failure that #423 fixed.

Testing

  • pytest tests/ (offline): 1242 passed. Coverage is 98.96%, and the ratchet holds.
  • pytest -m live tests/waterdata_queryables_test.py::test_queryables_match_snapshot: 11 passed.
  • I ran both getters against the live service with sublocation_identifier="UPSTREAM". Each returned only UPSTREAM rows.
  • ruff, mypy, lint-imports, xenon, and complexipy pass (pre-commit).

@thodson-usgs
thodson-usgs force-pushed the fix/field-measurements-sublocation-identifier branch from f2806d7 to 75bcad3 Compare October 3, 2026 12:55
Comment thread tests/waterdata_test.py Outdated
@thodson-usgs
thodson-usgs force-pushed the fix/field-measurements-sublocation-identifier branch from 75bcad3 to 1f7fc21 Compare October 3, 2026 13:03
…queryable

USGS added sublocation_identifier to the field-measurements and
field-measurements-metadata collections at the end of September 2026,
which failed the live queryables snapshot monitor. Regenerate the
snapshot, and add sublocation_identifier as a named, documented
parameter on get_field_measurements and get_field_measurements_metadata.
@thodson-usgs
thodson-usgs force-pushed the fix/field-measurements-sublocation-identifier branch from 1f7fc21 to 4e86db6 Compare October 3, 2026 13:06
@thodson-usgs
thodson-usgs requested a review from ehinman October 3, 2026 13:07
@thodson-usgs
thodson-usgs marked this pull request as ready for review October 3, 2026 13:07

@ehinman ehinman 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.

LGTM. I'm struggling to find a monitoring location in the field measurements/field metadata endpoints that has a non-NA sublocation identifier populated, but I passed sublocation_identifier=None to get_field_measurements() and it returned all rows. Thanks for adding this.

@thodson-usgs
thodson-usgs merged commit 26f147e into DOI-USGS:main Oct 7, 2026
11 checks passed
@thodson-usgs
thodson-usgs deleted the fix/field-measurements-sublocation-identifier branch October 7, 2026 13:08
thodson-usgs added a commit that referenced this pull request Oct 12, 2026
…arguments (#447)

Follow-ups from review of #436, which is unreleased:

- Move sublocation_identifier to the end of the get_field_measurements and
  get_field_measurements_metadata signatures. Inserted mid-signature, it
  shifted every later positional argument: a positional skip_geometry or
  properties would have been sent as a sublocation filter.
- Test against real features from USGS-05435943 (Backup, HWM, Primary)
  and assert the values; the shared fixture's site records no sublocation,
  so the old test only checked a hand-added null column.
- Describe the parameter in get_time_series_metadata and
  get_combined_metadata, and use observed values in the examples.
- Date the NEWS entry by its land date (10/07), unwrap it, and note that
  the field already worked through **queryables.


Claude-Session: https://claude.ai/code/session_01HBt3Ee7eneKtdKQWq2T3YK

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 Oct 13, 2026
Twenty columns that the Water Data OGC collections return could be
passed only through **queryables, so their getters documented neither
the column nor the filter. Each is now a named parameter of the getter
that returns it, documented from the collection's /schema; NEWS.md lists
them. day, month and year are typed as integers, as in get_peaks.
Monitoring-location attributes that every collection accepts as filters
but does not return stay in **queryables.

The new parameters are keyword-only, after a bare * at the end of each
signature, so every parameter released in v1.4.0 keeps its position and
an existing call, positional or keyword, sends the same request.
sublocation_identifier (unreleased, DOI-USGS#436) moves after the * too.
tests/contracts/public_api_test.py now requires each Water Data
getter's positional parameters to match their v1.4.0 order, recorded in
tests/data/waterdata_positional_parameters.json, and the module
docstring no longer calls a reorder harmless.

The properties lists of get_monitoring_locations and get_channel now
include their missing columns. get_peaks' qualifier and value, and the
parameter_description of get_combined_metadata and
get_field_measurements_metadata, use the same wording as the other
getters and the service's /schema.

tests/waterdata_properties_test.py now holds one table of the eleven
OGC getters by collection, and checks:
- offline, that every named parameter of each getter reaches the OGC
  engine (derived from the signatures, so a new parameter is covered
  when it is added);
- live, that every column a collection's /schema publishes, other than
  its id and geometry, is a named parameter of its getter. Run against
  main, this fails on exactly the 20 columns named here;
- live, that the documented column lists match the schema, now for
  get_monitoring_locations and get_channel too. The schema's id and the
  name the getter returns it under are left out of both sides, and a
  list ends at the sentence that follows it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HBt3Ee7eneKtdKQWq2T3YK
thodson-usgs added a commit to thodson-usgs/dataretrieval-python that referenced this pull request Oct 13, 2026
Twenty columns that the Water Data OGC collections return could be
passed only through **queryables, so their getters documented neither
the column nor the filter. Each is now a named parameter of the getter
that returns it, documented from the collection's /schema; NEWS.md lists
them. day, month and year are typed as integers, as in get_peaks.
Monitoring-location attributes that every collection accepts as filters
but does not return stay in **queryables.

The new parameters are keyword-only, after a bare * at the end of each
signature, so every parameter released in v1.4.0 keeps its position and
an existing call, positional or keyword, sends the same request.
sublocation_identifier (unreleased, DOI-USGS#436) moves after the * too, and so
do statistics_begin (DOI-USGS#422) and method_category (DOI-USGS#423). Those two shipped
mid-signature in v1.4.0 eleven days ago; moving them shifts the later
positional parameters of get_time_series_metadata and get_continuous by
one, which NEWS marks as a behavior change.
tests/contracts/public_api_test.py now requires each Water Data
getter's positional parameters to match their v1.4.0 order (less those
two), recorded in
tests/data/waterdata_positional_parameters.json, and the module
docstring no longer calls a reorder harmless.

The properties lists of get_monitoring_locations and get_channel now
include their missing columns. get_peaks' qualifier and value, and the
parameter_description of get_combined_metadata and
get_field_measurements_metadata, use the same wording as the other
getters and the service's /schema.

tests/waterdata_properties_test.py now holds one table of the eleven
OGC getters by collection, and checks:
- offline, that every named parameter of each getter reaches the OGC
  engine (derived from the signatures, so a new parameter is covered
  when it is added);
- live, that every column a collection's /schema publishes, other than
  its id and geometry, is a named parameter of its getter. Run against
  main, this fails on exactly the 20 columns named here;
- live, that the documented column lists match the schema, now for
  get_monitoring_locations and get_channel too. The schema's id and the
  name the getter returns it under are left out of both sides, and a
  list ends at the sentence that follows it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HBt3Ee7eneKtdKQWq2T3YK
thodson-usgs added a commit to thodson-usgs/dataretrieval-python that referenced this pull request Oct 13, 2026
Twenty columns that the Water Data OGC collections return could be
passed only through **queryables, so their getters documented neither
the column nor the filter. Each is now a named parameter of the getter
that returns it, documented from the collection's /schema; NEWS.md lists
them. day, month and year are typed as integers, as in get_peaks.
Monitoring-location attributes that every collection accepts as filters
but does not return stay in **queryables.

The new parameters are keyword-only, after a bare * at the end of each
signature, so every parameter released in v1.4.0 keeps its position and
an existing call, positional or keyword, sends the same request.
sublocation_identifier (unreleased, DOI-USGS#436) moves after the * too, and so
do statistics_begin (DOI-USGS#422) and method_category (DOI-USGS#423). Those two shipped
mid-signature in v1.4.0 eleven days ago; moving them shifts the later
positional parameters of get_time_series_metadata and get_continuous by
one, which NEWS marks as a behavior change.
tests/contracts/public_api_test.py now records how many parameters each
Water Data getter accepts by position and fails if that changes, and
its module docstring no longer calls a reorder harmless.

The properties lists of get_monitoring_locations and get_channel now
include their missing columns. get_peaks' qualifier and value, and the
parameter_description of get_combined_metadata and
get_field_measurements_metadata, use the same wording as the other
getters and the service's /schema.

tests/waterdata_properties_test.py now holds one table of the eleven
OGC getters by collection, and checks:
- offline, that every named parameter of each getter reaches the OGC
  engine (derived from the signatures, so a new parameter is covered
  when it is added);
- live, that every column a collection's /schema publishes, other than
  its id and geometry, is a named parameter of its getter. Run against
  main, this fails on exactly the 20 columns named here;
- live, that the documented column lists match the schema, now for
  get_monitoring_locations and get_channel too. The schema's id and the
  name the getter returns it under are left out of both sides, and a
  list ends at the sentence that follows it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HBt3Ee7eneKtdKQWq2T3YK
thodson-usgs added a commit that referenced this pull request Oct 13, 2026
Twenty columns that the Water Data OGC collections return could be
passed only through **queryables, so their getters documented neither
the column nor the filter. Each is now a named parameter of the getter
that returns it, documented from the collection's /schema; NEWS.md lists
them. day, month and year are typed as integers, as in get_peaks.
Monitoring-location attributes that every collection accepts as filters
but does not return stay in **queryables.

The new parameters are keyword-only, after a bare * at the end of each
signature, so every parameter released in v1.4.0 keeps its position and
an existing call, positional or keyword, sends the same request.
sublocation_identifier (unreleased, #436) moves after the * too, and so
do statistics_begin (#422) and method_category (#423). Those two shipped
mid-signature in v1.4.0 eleven days ago; moving them shifts the later
positional parameters of get_time_series_metadata and get_continuous by
one, which NEWS marks as a behavior change.
tests/contracts/public_api_test.py now records how many parameters each
Water Data getter accepts by position and fails if that changes, and
its module docstring no longer calls a reorder harmless.

The properties lists of get_monitoring_locations and get_channel now
include their missing columns. get_peaks' qualifier and value, and the
parameter_description of get_combined_metadata and
get_field_measurements_metadata, use the same wording as the other
getters and the service's /schema.

tests/waterdata_properties_test.py now holds one table of the eleven
OGC getters by collection, and checks:
- offline, that every named parameter of each getter reaches the OGC
  engine (derived from the signatures, so a new parameter is covered
  when it is added);
- live, that every column a collection's /schema publishes, other than
  its id and geometry, is a named parameter of its getter. Run against
  main, this fails on exactly the 20 columns named here;
- live, that the documented column lists match the schema, now for
  get_monitoring_locations and get_channel too. The schema's id and the
  name the getter returns it under are left out of both sides, and a
  list ends at the sentence that follows it.


Claude-Session: https://claude.ai/code/session_01HBt3Ee7eneKtdKQWq2T3YK

Co-authored-by: Claude Opus 5.5 (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.

2 participants