-
Notifications
You must be signed in to change notification settings - Fork 210
MRG: Error on sphinx 1.5 #178
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
Conversation
|
We know sphinx-gallery tests are not passing on Windows ... we have an issue #162 and an ongoing PR. Maybe do not spend too much time on getting the tests to pass on Windows. I have heard of the astropy CI stuff but never looked into it in detail, what do they give us exactly? |
|
I removed the AppVeyor stuff, don't worry. PR forthcoming. CI-helpers simplify Anaconda installation, I'll show you shortly :) In the meantime this should be good to go. |
|
Hmm I do not get any errors on your PR with sphinx 1.5 but I get plenty of "HTTPError 404" printout like this: You can see them in the Travis log actually: I am wondering where they are coming from ... |
|
I see those, too. I've been using the equivalent of this branch for a while and haven't noticed any broken links or anything... Does it only happen for you on this branch? Maybe I need to dig into Sphinx to figure out where it's coming from and have it throw a more explicit error. |
|
Does it only happen for you on this branch? I guess this is the only branch I have which works with sphinx 1.5 ;-) so it is hard to know whether sphinx 1.5 or this PR is the culprit for these noisy HTTPError messages. |
|
Looks like it's coming from |
|
More explicit error generation in latest commit: |
fa5c9b2 to
23a91ea
Compare
|
... so the underlying problem is probably in |
.travis.yml
Outdated
| # which then crashes with pandas and seaborn | ||
| - if [ "$DISTRIB" == "conda" ]; then | ||
| conda create --yes -n testenv python=$PYTHON_VERSION pip nomkl numpy | ||
| conda create --yes -n testenv python=$PYTHON_VERSION pip nomkl numpy scipy |
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 am puzzled: why was adding scipy necessary for this fix?
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.
There were some seaborn errors without it I thought
|
The problem seems to be that SphinxDocLinkResolver tries to get the link to e.g. http://docs.scipy.org/doc/numpy-1.9.1/reference/generated/numpy.html but it doesn't exist. Now it gives a more informative error: In the meantime, this gets Travis passing and SG at least more usable. I'm not sure how to fix the underlying SphinxDocLinkResolver issue. Looks like that's code by @Titan-C? |
|
@Eric89GXL : I do note that this gets travis passing, and I didn't see anything that looked wrong to me, so overall I am 👍 for the merge. But still, I don't get why we need scipy on the CI. Maybe you answered this question, but I didn't understand the answer, then. |
We install seaborn so getting pandas and scipy automatically via the dependency resolver anyway. |
|
We install seaborn so getting pandas and scipy automatically via the
dependency resolver anyway.
OK. Good point.
Still puzzled but it's not really important.
+1 from my side.
|
|
I added a new commit to removes the SciPy change, and it works fine. I thought it threw an error at one point but I must have misread it! |
|
(Also FWIW |
sphinx_gallery/docs_resolv.py
Outdated
| fname = self._searchindex['filenames'][fname_idx] | ||
| try: | ||
| import sphinx | ||
| except Exception: |
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.
Why would the sphinx import fail?
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.
It looked like nowhere in the package did sphinx actually get imported, so I didn't want to add a top-level import. But since this is sphinx-gallery I guess it's okay, eh? :)
sphinx_gallery/docs_resolv.py
Outdated
| except Exception: | ||
| fname = os.path.splitext(fname)[0] | ||
| else: | ||
| if LooseVersion(sphinx.__version__) >= LooseVersion('1.5'): |
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.
Bonus points if you add a comment to clarify why the work-around for 1.5 is needed.
|
@lesteve done |
|
Oh wait, I realized the problem with the link resolution. We will have an issue with building docs with 1.5+ but linking to older doc versions. I can push a fix. |
|
I don't love this fix, but it should work. Eventually once more pages start using 1.5+ we'll end up with a lot of errors being shown for links that couldn't be grabbed even though they work on the second iteration of the |
|
Please open an issue for the unresolved links (or check that there is not one already). They have been annoying me too. OK, I was about to merge this PR, but it seems that you're on something, so I'll hold back a wee bit. |
|
Okay @GaelVaroquaux feel free to merge if you're happy with the |
sphinx_gallery/docs_resolv.py
Outdated
| import re | ||
| import shelve | ||
| import sys | ||
| import sphinx |
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.
Are the sphinx import and the LooseVesion import still useful?
sphinx_gallery/docs_resolv.py
Outdated
| else: | ||
| html = get_data(link, self.gallery_dir) | ||
| self._page_cache[link] = html | ||
| raise 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.
Would raise not be work to raise the last caught exception? My experience is that raise e creates a misleading traceback especially on Python 2.7 since you lose the provenance of the original exception.
| else: | ||
| extra = e.reason | ||
| print("\t\tError resolving %s.%s: %r (%s)" | ||
| % (cobj['module'], cobj['name'], e, extra)) |
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 another PR, but it does seem that it would be useful to have the URL that we tried to access, rather than the module ...
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.
Yeah I agree, but that will require a good bit of refactoring because the URL is a function or two deeper than this. And really it should be refactored to use the proper local filename based on sphinx version, and then check the two possible remote names, rather than trying both in both cases as it does now. But I think that will again require a lot of refactoring to work.
|
Unnecessary imports removed. |
sphinx_gallery/docs_resolv.py
Outdated
| else: | ||
| html = get_data(link, self.gallery_dir) | ||
| self._page_cache[link] = html | ||
| except Exception: |
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.
Do you really want to catch all the exceptions? Can't we be slightly more specific?
Sorry for making a new comment at each round, I am seeing these aspects only gradually.
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.
It's okay, this bit is new :)
Yes I can catch just HTTPError and URLError
|
I think the fix is fine, you could tidy it up by putting the for loop in a function but we can do that later. +1 for merging, thanks a lot @Eric89GXL. I wish I would have paid more attention when #137 was created, I have to admit I have no recollection of it at all :( ... |
And the warnings about not being able to access the URL would make sense inside this function as well, since at this point you know the two URLs you tried to access (rather than catching the exception later and having only one URL). |
|
It's alright, I think Anaconda just rolled out 1.5 so I doubt many people have been hit by it. I also probably should have followed up once the issue didn't magically disappear like I was hoping it would... Exception made less broad, Travis builds look good (green and logs have no complaints). |
|
OK I am going to merge this one, thanks a lot ! |
Starting over on #137.