8000 [MRG+1] plot_stock_market retry on failed download of google data by hakaa1 · Pull Request #9437 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged

Conversation

hakaa1
Copy link
Contributor
@hakaa1 hakaa1 commented Jul 22, 2017

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.

@lesteve
Copy link
Member
lesteve commented Jul 24, 2017

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:
https://figshare.com/articles/scikit-learn_financial_historical_quotes/5092483

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 ?

@lesteve
Copy link
Member
lesteve commented Jul 24, 2017

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 😕

Copy link
Member
@jnothman jnothman left a 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.

@jnothman jnothman added this to the 0.19 milestone Jul 24, 2017
@lesteve
Copy link
Member
lesteve commented Jul 24, 2017

@lesteve, there was an exception but it was only triggered in genfromtext. So this will work.

Good point, sorry I didn't read carefully enough and thought the wrapper only applied to the HTTP request.

Perhaps retry(quotes_historical_google)(...) is a little clearer.

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 ...).

@hakaa1
Copy link
Contributor Author
hakaa1 commented Jul 24, 2017

@lesteve @jnothman
Which one do you think is clearer?

quotes_historical_google = retry(quotes_historical_google)
quotes = [
quotes_historical_google(symbol, d1, d2) for symbol in symbols
]

quotes = [
retry(quotes_historical_google)(symbol, d1, d2) for symbol in symbols
]

Second one would decorate function again for every stock entry. I'm not sure which one is clearer.
I would add comment in both cases :)

@lesteve
Copy link
Member
lesteve commented Jul 24, 2017

I like 2. better in the sense that it does not have any side-effect (i.e. quotes_historical_google is still defined by the function code).

Copy link
Member
@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

LGTM

@jnothman jnothman changed the title [MRG] plot_stock_market retry on failed download of google data [MRG+1] plot_stock_market retry on failed download of google data Jul 25, 2017
@lesteve
Copy link
Member
lesteve commented Jul 25, 2017

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.

@lesteve
Copy link
Member
lesteve commented Jul 25, 2017

Before I forget this should probably be backported in the 0.19.X branch.

@hakaa1
Copy link
Contributor Author
hakaa1 commented Jul 25, 2017

@lesteve changes look good to me, thanks.

@lesteve
Copy link
Member
lesteve commented Jul 25, 2017

Merging this one, thanks @hakaa1 !

@lesteve lesteve merged commit 8811d59 into scikit-learn:master Jul 25, 2017
@hakaa1 hakaa1 deleted the plot_stock_market_example_download_fail branch July 25, 2017 14:04
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Aug 6, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
AishwaryaRK pushed a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plot_stock_market example may fail in quotes_historical_google
3 participants
0