-
-
Notifications
You must be signed in to change notification settings - Fork 26k
ENH Add a retry mechanism in fetch_openml #21901
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
ENH Add a retry mechanism in fetch_openml #21901
Conversation
I have not checked this PR but I recently discovered that there is already a "retry once" mechanism named I am not sure it plays well with the new concurrency aware download and cache mechanism of #21833 though. |
The concurrency aware download works as expected with As for this PR, scikit-learn/sklearn/datasets/_openml.py Lines 62 to 63 in 6c9f165
to catch |
Thank you @thomasjpfan for clarifying the purpose of those two decorators. I have applied the correct changes and now I have looked into the failed pipeline and I am not sure about the trouble. The error message caught by pytest look like one from another test. + unclosed file <_io.FileIO name='/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pytest-of-runner/pytest-0/popen-gw2/test_fetch_openml_verify_check0/test_invalid_checksum.arff' mode='rb' closefd=True> Is it possible that another test is failing to close a file and that the error message is caught by our test ? I am not very familiar with pytest and therefore am having trouble isolating the problem. |
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.
for r in record: | ||
assert ( | ||
r.message.args[0] | ||
== "A network error occured while downloading a file. Retrying..." | ||
) | ||
assert len(record) == 3 |
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.
Since match=
it set in the context manager, the message is already matched. Here only need to check the number of retries:
assert len(record) == 3
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.
Corrected in last commit. Thanks a lot for reviewing my work !
I merged #22005 in main, so it should be possible to merge an updated |
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.
LGTM once the comments below and the one remaining by @thomasjpfan (https://github.com/scikit-learn/scikit-learn/pull/21901/files#r770951394) are addressed.
5e14d8e
to
a48d74c
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.
Thanks!
9460520
to
46f6190
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.
Thank you for the update @Rileran!
A minor comment, otherwise LGTM!
a6f9302
to
6691632
Compare
FIX Changed default parameter type to float Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
6691632
to
d6ea453
Compare
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Reference Issues/PRs
Fixes #21397
Retry mechanism for other fetch_* functions : #21691
What does this implement/fix? Explain your changes.
Added a retry mechanism for the function
fetch_openml
in case of a network error.This is done by adding
n_retries
anddelay
arguments to the function. (similar to #21691).If a call to
urlopen
would result in a network error (URLError
), we will call the function again, up ton_retries
times and with adelay
between each call.Any other comments?
As this is specific to OpenML, the retry mechanism will be bypassed if the network error has a status code
412
, as it is the generic error returned by the OpenML API.