Repository navigation
[MRG]: openml, Adds retrying if reading from cache fails - #12526
Conversation
| return os.path.join(data_home, 'openml.org', openml_path + ".gz") | ||
|
|
||
|
|
||
| def _retry_if_error_with_cache_removed(openml_path, data_home): |
There was a problem hiding this comment.
how about calling this _retry_with_clean_cache
|
Sorry for checking in so late on this PR. I am currently trying to find out whether the following two cases hold:
Not sure if this is part of this PR, but this gives me an error: (dataset with if 100000 does not exist yet) last part trace: I will contribute test-cases for the first 2 examples as well. |
|
Fun fact. I tried to download the following two files. In both cases, there are no (unwanted) residuals in the cache folder, except for the aforementioned error. Indeed, for dataset 40864 the features and data description are available, but there is no harm there. Additionally, I faked an error on the test server. Upon fetching the dataset for the first time, it failed and cached the failed reply. After fixing the response, it succeeded with warning message. After trying it again, it succeeded. Apart from the error message (does that belong to this PR?) this LGTM. |
| with gzip.GzipFile(local_path, 'wb') as fdst: | ||
| shutil.copyfileobj(fsrc, fdst) | ||
| except Exception: | ||
| os.unlink(local_path) |
There was a problem hiding this comment.
This line can throw an error if the file in local_path does not exists
There was a problem hiding this comment.
So we should probably only unlink if it exists and otherwise do nothing?
There was a problem hiding this comment.
This PR was updated to check if the file exists before unlinking it.
|
can you please add a test for that case as well? |
|
@amueller This PR was updated with a test: |
|
cool, merge? |
|
Thanks @thomasjpfan |
…ikit-learn#12526)" This reverts commit fd13f9f.
…ikit-learn#12526)" This reverts commit fd13f9f.
Reference Issues/PRs
Resolves #12517
What does this implement/fix? Explain your changes.
Adds a decorator called
_retry_if_error_with_cache_removedto implement the retry logic, when the read from cache fails.This PR includes a minor refactoring to use
contextlib.closingto make sure streams are closed, when an exception gets raised.