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
merge baseurl and pattern for scraper clients (#7077) #7227
base: main
Are you sure you want to change the base?
Conversation
The windows test fails look real fwiw. |
Oh yeah, I forgot. I will debug that and see what the problem is. |
Outside of that, what are your thoughts on my questions/todo list in the main body? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we really have to go through a deprecation period here for the old behaviour. One way I can see of doing this is:
- Make
pattern
optional (ie., pattern=None
) - Add a new keyword-only argument,
format
, to take the new format - Raise an error if both
pattern
andformat
are provided - Use old behaviour, and raise a deprecation warning saying to use new
format=...
instead if onlypattern
passed - Use new behaviour if only
format
passed.
f883a0d
to
07514ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to what @dstansby said need a small migration guide even just pulling some examples of the changes from this PR could work.
Also need to clean way to deprecate as I know of at at least two packages that use scraper outside of sunpy core.
|
||
def extract_timestep(directoryPattern): | ||
""" | ||
Obtain the smaller time step for the given pattern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obtain the smaller time step for the given pattern. | |
Obtain the smallest time step for the given pattern. |
date_parts = [int(p) for p in date.strftime('%Y,%m,%d,%H,%M,%S').split(',')] | ||
date_parts[-1] = date_parts[-1] % 60 | ||
date = datetime(*date_parts) | ||
orig_time_tup = date.timetuple() | ||
time_tup = [orig_time_tup.tm_year, orig_time_tup.tm_mon, orig_time_tup.tm_mday, | ||
orig_time_tup.tm_hour, orig_time_tup.tm_min, orig_time_tup.tm_sec] | ||
if timestep == relativedelta(minutes=1): | ||
time_tup[-1] = 0 | ||
elif timestep == relativedelta(hours=1): | ||
time_tup[-2:] = [0, 0] | ||
elif timestep == relativedelta(days=1): | ||
time_tup[-3:] = [0, 0, 0] | ||
elif timestep == relativedelta(months=1): | ||
time_tup[-4:] = [1, 0, 0, 0] | ||
elif timestep == relativedelta(years=1): | ||
time_tup[-5:] = [1, 1, 0, 0, 0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm originally responsible for this mess I think it can be done in cleaner way something like
def date_floor(date, step):
floor_date = date.copy()
if step >= relativedelta(minutes=1):
floor_date.replace(minutes=0)
if step >= relativedelta(hours=1):
floor_date.replace(hours=0)
...
return floor_date
07514ae
to
b66235d
Compare
b66235d
to
b393491
Compare
* merge baseurl and pattern for scraper clients (#7077) * precommit fixes * added some bit of error handling in the scraper * Update sunpy/net/dataretriever/client.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * made some minor changes * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * added some changes to the scraper and also added the tentative tests * modified tests * added some bit of error handling in the scraper * made some minor changes * Update sunpy/net/dataretriever/client.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * added some changes to the scraper and also added the tentative tests * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * modified tests * refactored the tests to scraper test files and restored the scraper code * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * clean ups * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * made tests offline * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * added urlerror test * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * resolved conflicts * clean ups * parametrized * clean ups * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * clean ups * added explanation * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * added 404 test * parametrized the tests * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * log level set * Update sunpy/net/scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * log level using caplog * log level using caplog * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> * Update sunpy/net/tests/test_scraper.py Co-authored-by: Nabil Freij <nabil.freij@gmail.com> --------- Co-authored-by: Akshit Tyagi <37214399+exitflynn@users.noreply.github.com> Co-authored-by: Nabil Freij <nabil.freij@gmail.com>
hey everyone, got superbusy with some other stuff for a while but i'd love to get involved again. i just figured out why the windows tests were failing, gonna make a quick PR to the scraper branch for that |
fix failing windows tests
I tried fixing the failing doctests but i cannot seem to figure them out. Let me know if i can help out in any other way with this feature! |
Let us see if merging in main helps. |
This is the main PR to update the scarper, we want this in for 5.1 but we have two questions to solve:
a. We can create a "Scraper 2" and deprecate the old class?
b. We could YOLO it but I do not want to do that.