Skip to content
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

annual statistics creates invalid URL #118

Closed
mroberge opened this issue Jun 30, 2022 · 1 comment
Closed

annual statistics creates invalid URL #118

mroberge opened this issue Jun 30, 2022 · 1 comment

Comments

@mroberge
Copy link
Owner

  • HydroFunctions version: 0.2.3

Description

When I added the 'statYearType' parameter to a request for annual statistics, it printed the wrong URL but still returned something.

What I Did

hf.stats('01542500', 'annual', parameterCd='00060', statYearType='water')

Retrieved annual statistics for site #01542500 from https://waterservices.usgs.gov/nwis/stat//

Although it prints the wrong URL, it still seems to return the correct data.

@mroberge
Copy link
Owner Author

The problem is that the stats function in the USGS RDB module is the only one that sends a base URL and a dict of parameters to Requests and lets that package construct the full URL. All of the other functions construct the full URL themselves.

The result is that the stats function is the only one that doesn't know the full URL until after Requests returns a response.

The basic fix is to initially print just the base URL; once the response is returned print the response.url.
If the USGS returns a non-200 code, it doesn't raise an error, hf just prints the error screen the the USGS sends, and then hf returns the response. So you can still print the response.url

So, change the end of line 641 to {response.url} instead of {url}.

mroberge added a commit that referenced this issue Jun 30, 2022
Issue #118  the hf.stats function prints the incorrect url when it requests data. This fix will print the correct URL. None of the other functions in this module are affected.
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

No branches or pull requests

1 participant