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

Take into consideration the time component in endtime #97

Merged
merged 3 commits into from
Jul 26, 2023

Conversation

pmav99
Copy link
Member

@pmav99 pmav99 commented Jul 25, 2023

This involves several changes:

  1. We rename resolve_date to resolve_timestamp since we no longer only deal with dates
  2. The signature and the type of returned objects inresolve_timestamp() has changed. More specifically the function became quite a bit more capable and complex. It gained extra arguments that allow it to return both timezone-aware and naive Timestamps.
  3. We change the Literal value TODAY to now

Fixes #96

pydantic 2 changed the text of the exception it raises, that's why we need to update the tests, too.
@pmav99 pmav99 self-assigned this Jul 25, 2023
@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Merging #97 (9f35859) into master (78d2847) will increase coverage by 0.03%.
Report is 3 commits behind head on master.
The diff coverage is 90.90%.

@@            Coverage Diff             @@
##           master      #97      +/-   ##
==========================================
+ Coverage   89.98%   90.01%   +0.03%     
==========================================
  Files          13       13              
  Lines        1008     1012       +4     
  Branches      114      150      +36     
==========================================
+ Hits          907      911       +4     
+ Misses         57       55       -2     
- Partials       44       46       +2     
Files Changed Coverage Δ
searvey/erddap.py 95.00% <ø> (ø)
searvey/utils.py 87.30% <83.33%> (-2.53%) ⬇️
searvey/custom_types.py 100.00% <100.00%> (ø)
searvey/ioc.py 90.90% <100.00%> (ø)
searvey/usgs.py 92.59% <100.00%> (ø)

... and 1 file with indirect coverage changes

@@ -48,7 +48,7 @@ def get_erddap_url(
response: str = "csvp",
) -> str:
erddap = erddapy.ERDDAP(
server=dataset.server_url,
server=str(dataset.server_url),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't used ERDDAP module, so I'm not sure if this is relevant. But is it possible for the value to become None and making it str() can break some check downstream?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the ERDDAP stuff hasn't been used/tested in some time. If we decide to add a Provider using an ERDDAP server we will need to revisit it anyhow. For now I just made the change so that the tests pass.

This specific change is actually caused by pydantic 2+ which changed some APIs.

This involves several changes:

1. We rename `resolve_date` to `resolve_timestamp` since we no longer only deal with dates
2. The signature and the type of returned objects in`resolve_timestamp()` has changed.
    More specifically the function became quite a bit more capable and complex.
    It gained extra arguments that allow it to return both timezone-aware and
    naive Timestamps.
3. We change the Literal value `TODAY` to `now`

Fixes oceanmodeling#96
@@ -279,7 +279,7 @@ def get_usgs_station_data(
while rate_limit.reached(identifier="USGS"):
wait()

endtime = resolve_date(endtime)
endtime = resolve_timestamp(endtime, timezone_aware=False).date()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SorooshMani-NOAA AFAI can tell dataretrieval/USGS handle the time component just fine. For example:

import dataretrieval.nwis as nwis

print(len(nwis.get_record(sites='03339000', service='iv', start='2017-12-31', end='2018-01-01')))  # prints 192
print(len(nwis.get_record(sites='03339000', service='iv', start='2017-12-31T12:00:00', end='2018-01-01')))  # prints 144

In that sense we don't need to call .date() in line 282. I only added that in order to keep the old behavior and to let the tests pass. Your call if we keep it as is or we remove .date().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmav99 let's keep the behavior the same as before by adding .date() for now. Thanks for notifying me.

@pmav99 pmav99 merged commit fab0ef0 into oceanmodeling:master Jul 26, 2023
10 checks passed
@pmav99 pmav99 deleted the time_component branch July 26, 2023 15:24
@brey brey mentioned this pull request Sep 3, 2023
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.

IOC: hour component is ignored in endtime
2 participants