-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG+1] plot_stock_market retry on failed download of google data #9437
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
[MRG+1] plot_stock_market retry on failed download of google data #9437
Conversation
IIRC the error was caused by the data being empty rather than getting an exception so I don't think your PR will work. Something I bumped into in another PR: It looks like @nelson-liu uploaded the data using the Yahoo data (60 stocks). The only problem is that the order is not clear, do you remember which ordering you used @nelson-liu ? |
I quickly looked at this, found an old matplotlib finance cache on my computer but I could not really match the data from figshare to the one from matplotlib finance 😕 |
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.
@lesteve, there was an exception but it was only triggered in genfromtext
. So this will work.
I find the decorator excessively subtle, but I'm not sure of a nice solution. Perhaps retry(quotes_historical_google)(...)
is a little clearer.
Good point, sorry I didn't read carefully enough and thought the wrapper only applied to the HTTP request.
I would be in favour of this. Also, a small comment mentioning that this is to work-around the fact that the Google API can return empty data (although none of us has managed to reproduce it locally ...). |
@lesteve @jnothman quotes_historical_google = retry(quotes_historical_google) quotes = [ Second one would decorate function again for every stock entry. I'm not sure which one is clearer. |
I like 2. better in the sense that it does not have any side-effect (i.e. |
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
I pushed some minor modifications. It should amongst other things fix the flake8 error seen on Travis in the previous commit. I think this is good to merge when the CIs are green. |
Before I forget this should probably be backported in the 0.19.X branch. |
@lesteve changes look good to me, thanks. |
Merging this one, thanks @hakaa1 ! |
Reference Issue
Fixes #9172
What does this implement/fix? Explain your changes.
In case when download of Google data fails or there is something wrong with the response data (e.g. empty response), download will be retried several times before example fails.
Any other comments?
I couldn't reproduce exact errors mentioned in #9172 so I created small decorator that retries to download data after any kind of exception 3 times before it finally fails.