-
Notifications
You must be signed in to change notification settings - Fork 57
Stabilize NWIS Tests and Improve 5xx Error Handling #223
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
Open
thodson-usgs
wants to merge
8
commits into
DOI-USGS:main
Choose a base branch
from
thodson-usgs:ci-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
14a56f4
Deprecate defunct NWIS functions, update tests, and improve 5xx error…
thodson-usgs fd013ff
Ruff
thodson-usgs 5cf5366
Refactor NWIS tests to use external JSON mock data
thodson-usgs cbf7075
Implement Copilot improvements: preserve tracebacks, robust HTML dete…
thodson-usgs dd98537
Fix NWIS test regression and resolve WQP DtypeWarning
thodson-usgs cecf4a4
Implement final Copilot refinements: robust mocking, refined error ha…
thodson-usgs 82e6c8a
Update get_record
thodson-usgs 2348a19
Optimize WaterData pagination and centralize parameter handling
thodson-usgs 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Recreate PR #216: Remove Defunct NWIS Functions | ||
|
|
||
| This PR resubmits the changes from [PR #216](https://github.com/DOI-USGS/dataretrieval-python/pull/216) which removes four defunct NWIS legacy functions (`get_gwlevels`, `get_discharge_measurements`, `get_pmcodes`, and `get_water_use`) by replacing them with `NameError` exceptions that point users to the modernized `waterdata` equivalents. | ||
|
|
||
| The original PR #216 was superseded by linting changes (PR #219) on the `main` branch before being merged, which caused conflicts. This PR correctly recreates the exact logical changes from PR #216 directly on top of the newly linted `main` branch, ensuring we maintain `ruff` compliance while formally deprecating the defunct functions as planned. | ||
|
|
||
| All related tests and defunct data files have been removed, and the README has been updated to reflect the new API announcements identically to PR #216. | ||
|
|
||
| ### Notebook Modernization | ||
|
|
||
| In addition to the core API changes, a comprehensive review and modernization of **16 demo notebooks** (including all legacy `hydroshare` examples) was performed: | ||
|
|
||
| - **API Migration**: Legacy `nwis.get_dv()`, `nwis.get_iv()`, and `nwis.get_info()` calls were upgraded to their modern `waterdata` equivalents. | ||
| - **Defunct Removal**: Defunct functions (`get_water_use`, `get_pmcodes`) were commented out or replaced with modern alternatives (`get_reference_table`) across all demos (e.g., `R Python Vignette`, `WaterUse` suite). | ||
| - **Execution Validation**: All notebooks were successfully re-executed using `jupyter nbconvert` in the local `.venv` environment to ensure they remain functional and generate correct plots with the new OGC long-format data schema. | ||
| - **Clean State**: Each notebook was processed with `nb-clean` to strip execution outputs and counts, ensuring a clean version-controlled state. | ||
| - **Dependencies**: `scipy` and `mapclassify` were added to the environment to support advanced plotting and analytical features now required by the modernized examples. | ||
|
|
||
| ### Performance & Maintenance Optimizations | ||
|
|
||
| A series of internal architectural improvements were implemented to enhance scalability and maintainability: | ||
|
|
||
| - **Efficient Pagination**: Refactored `_walk_pages` in `waterdata/utils.py` to use list-based aggregation, reducing memory copying overhead from $O(n^2)$ to $O(n)$. | ||
| - **Centralized Parameter Handling**: Introduced a shared `_get_args` helper and refactored all 11 API functions in `waterdata/api.py` to use it, eliminating over 100 lines of redundant dictionary comprehension logic. | ||
| - **Utility Optimization**: Enhanced `to_str` in `utils.py` with `map(str, ...)` and broader iterable support (sets, tuples, generators), verified with new comprehensive unit tests. | ||
| - **Improved Testing**: Added [waterdata_utils_test.py](file:///Users/thodson/Desktop/dev/software/dataretrieval-python/tests/waterdata_utils_test.py) and expanded `tests/utils_test.py` to ensure long-term stability of the new utility logic. |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.