Repository navigation
Fix WQX3 array parameter serialization #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thodson-usgs
merged 3 commits into
DOI-USGS:main
from
thodson-usgs:fix/wqx3-array-parameters-389
Aug 26, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,7 +29,7 @@ | |||||
| from dataretrieval.credentials import refuse_credential_keywords | ||||||
| from dataretrieval.exceptions import DataCurrencyWarning | ||||||
|
|
||||||
| from ._querying import _query_with_retry | ||||||
| from ._querying import _materialize_query_iterables, _query_with_retry | ||||||
| from ._wqx import _attach_datetime_columns | ||||||
|
|
||||||
| __all__ = [ | ||||||
|
|
@@ -138,8 +138,8 @@ def get_results( | |||||
| US state FIPS code (Example: Illinois is "US:17"). | ||||||
| countycode : string | ||||||
| US county FIPS code. | ||||||
| huc : string | ||||||
| Eight-digit hydrologic unit (HUC), delimited by semicolons. | ||||||
| huc : string or iterable of strings | ||||||
| Eight-digit hydrologic unit (HUC). | ||||||
| bBox : string | ||||||
| Search bounding box (Example: bBox=-92.8,44.2,-88.9,46.0). | ||||||
| lat : string | ||||||
|
|
@@ -148,18 +148,17 @@ def get_results( | |||||
| Radial-search central longitude in WGS84 decimal degrees. | ||||||
| within : string | ||||||
| Radial-search distance in decimal miles. | ||||||
| pCode : string | ||||||
| Five-digit USGS parameter code, delimited by semicolons. | ||||||
| NWIS only. | ||||||
| pCode : string or iterable of strings | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Five-digit USGS parameter code. NWIS only. | ||||||
| startDateLo : string | ||||||
| Date of the earliest desired data-collection activity, | ||||||
| expressed as 'MM-DD-YYYY'. | ||||||
| startDateHi : string | ||||||
| Date of the last desired data-collection activity, | ||||||
| expressed as 'MM-DD-YYYY'. | ||||||
| characteristicName : string | ||||||
| One or more case-sensitive characteristic names, separated by | ||||||
| semicolons (https://www.waterqualitydata.us/public_srsnames/). | ||||||
| characteristicName : string or iterable of strings | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| One or more case-sensitive characteristic names | ||||||
| (https://www.waterqualitydata.us/public_srsnames/). | ||||||
| mimeType : string | ||||||
| Output format. Only 'csv' is supported at this time. | ||||||
|
|
||||||
|
|
@@ -202,10 +201,12 @@ def get_results( | |||||
| valid_profiles = result_profiles_legacy | ||||||
| kind = "legacy" | ||||||
| url = wqp_url("Result") | ||||||
| delimiter = ";" | ||||||
| else: | ||||||
| valid_profiles = result_profiles_wqx3 | ||||||
| kind = "WQX3.0" | ||||||
| url = wqx3_url("Result") | ||||||
| delimiter = None | ||||||
|
|
||||||
| profile = kwargs.get("dataProfile") | ||||||
| if profile is not None: | ||||||
|
|
@@ -216,7 +217,7 @@ def get_results( | |||||
| kwargs["dataProfile"] = "fullPhysChem" | ||||||
|
|
||||||
| response = _query_with_retry( | ||||||
| url, kwargs, delimiter=";", ssl_check=ssl_check, adapter="wqp" | ||||||
| url, kwargs, delimiter=delimiter, ssl_check=ssl_check, adapter="wqp" | ||||||
| ) | ||||||
|
|
||||||
| df = _read_wqp_csv(response.text) | ||||||
|
|
@@ -241,13 +242,18 @@ def _what( | |||||
| """ | ||||||
| kwargs = _check_kwargs(kwargs) | ||||||
|
|
||||||
| if service in services_wqx3: | ||||||
| url = wqp_url(service) if legacy else wqx3_url(service) | ||||||
| else: | ||||||
| if service not in services_wqx3: | ||||||
| url = _legacy_only_url(service, legacy=legacy) | ||||||
| delimiter = ";" | ||||||
| elif legacy: | ||||||
| url = wqp_url(service) | ||||||
| delimiter = ";" | ||||||
| else: | ||||||
| url = wqx3_url(service) | ||||||
| delimiter = None | ||||||
|
|
||||||
| response = _query_with_retry( | ||||||
| url, payload=kwargs, delimiter=";", ssl_check=ssl_check, adapter="wqp" | ||||||
| url, payload=kwargs, delimiter=delimiter, ssl_check=ssl_check, adapter="wqp" | ||||||
| ) | ||||||
| df = _read_wqp_csv(response.text) | ||||||
| return df, WQP_Metadata(response, **kwargs) | ||||||
|
|
@@ -738,7 +744,9 @@ def _check_kwargs(kwargs: dict[str, Any]) -> dict[str, Any]: | |||||
| ``**queryables`` passthrough: ``api_key=`` is a plausible guess on any | ||||||
| getter now that ``configure(Configuration(api_key=...))`` is the spelling, | ||||||
| and this is the adapter with the widest passthrough -- ten getters, whose | ||||||
| filter names the portal rather than this package defines. | ||||||
| filter names the portal rather than this package defines. The returned | ||||||
| payload materializes non-string iterables as lists so one-shot iterators | ||||||
| remain reusable by both request serialization and response metadata. | ||||||
| """ | ||||||
| refuse_credential_keywords(kwargs) | ||||||
|
|
||||||
|
|
@@ -750,7 +758,7 @@ def _check_kwargs(kwargs: dict[str, Any]) -> dict[str, Any]: | |||||
| else: | ||||||
| kwargs["mimeType"] = "csv" | ||||||
|
|
||||||
| return kwargs | ||||||
| return _materialize_query_iterables(kwargs) | ||||||
|
|
||||||
|
|
||||||
| def _warn_wqx3_use() -> None: | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.