DOI-USGS / dataretrieval-python

Python package for retrieving water data from USGS or the multi-agency Water Quality Portal
https://doi-usgs.github.io/dataretrieval-python/
Other
165 stars 41 forks source link

retreiving record using gwlevels fails with ValueError date in wrong format (using example provided online) #166

Open Ben-Choat opened 1 month ago

Ben-Choat commented 1 month ago

Using the example linked below and provided in the official documentation fails with: ValueError: time data '1945-10-12 22:35 +0000' does not match format 'ISO8601' (match).

df = dataretrieval.nwis.get_record( sites="434400121275801", service="gwlevels" )

https://doi-usgs.github.io/dataretrieval-python/reference/nwis.html#dataretrieval.nwis.get_record:~:text=%23%20Get%20latest%20groundwater%20level%20for%20site%20434400121275801%0A%3E%3E%3E%20df%20%3D%20dataretrieval.nwis.get_record(%0A...%20%20%20%20%20sites%3D%22434400121275801%22%2C%20service%3D%22gwlevels%22%0A...%20)

ehinman commented 1 month ago

Hi @Ben-Choat, thanks for identifying an issue. Are you using the latest version of dataretrieval-python? The gwlevels service recently changed, and we made some updates to the package. You can see details in the read me here: https://github.com/DOI-USGS/dataretrieval-python?tab=readme-ov-file#dataretrieval-download-hydrologic-data

I just ran this line of code using the latest version of the package and it worked ok for me, but please let me know if this issue persists for you. Thanks so much!

Ben-Choat commented 1 month ago

Hello @ehinman, Version seemed to be the issue. I just checked the version using dataretrieval.version and it came back as 0.0.0 which is very surprising. I just installed it this past Friday (the 27th) using conda install dataretrieval -c conda-forge.

I just tried updating using conda update dataretrieval but it still says version 0.0.0.

I tried specifying the version conda install dataretrieval=1.0.10 -c conda-forge . I received a message that it is already installed and .version still returns 0.0.0.

Running conda install conda-forge::dataretrieval had the same effect.

Building a new virtual environment with venv and installing via pip install dataretrieval seems to have done the job with .version now showing 1.0.10 and the sample code running as expected.

When I was using conda, I was trying to install in an existing conda environment, so that may have caused issues for some reason. I have not tried installing in a fresh conda environment.

ehinman commented 1 month ago

Thanks for the info, I will investigate on my machine as well.

kallejahn commented 2 days ago

+1 to the 0.0.0 version issue from a conda install I did yesterday.

ehinman commented 1 day ago

Huh, that's really strange. I use a miniforge installation of mamba. I just created a fresh environment and installed dataretrieval via conda-forge and it downloaded v1.0.11 (latest), with python 3.13.0. I did the same thing specifying python=3.12.0 and I received the same version of dataretrieval. That is what shows on the distribution as well. I'm wondering if there are some conflicting dependencies in your environment causing it to download v0.0.0? Sorry this is happening to people!

thodson-usgs commented 11 hours ago

I'll look over the logs on the conda side. I'd hoped this was fixed with the last release, but apparently not.