nbsphinx
nbsphinx copied to clipboard
Default thumbnail asset not found
I'm using nbsphinx to a create a notebook gallery. I am using nbsphinx_execute = "never" and converting python scripts to notebooks with jupytext in GitHub Actions CI, then uploading the notebooks for ReadTheDocs to consume. The reason for this is to avoid timeouts on RTD, some of the notebooks are slow.
Note the empty thumbnails for some of the notebooks, for instance the "Advgwtidal example". I see a request going out for the thumbnail and returning 404:
GET https://modflow6-examples.readthedocs.io/en/latest/_images/_notebooks_ex-gwf-advtidal_10_5.png
Opening the notebook page, all the plots load fine via:
GET https://modflow6-examples.readthedocs.io/en/latest/_images/_notebooks_ex-gwf-advtidal_10_1.png
GET https://modflow6-examples.readthedocs.io/en/latest/_images/_notebooks_ex-gwf-advtidal_10_2.png
GET https://modflow6-examples.readthedocs.io/en/latest/_images/_notebooks_ex-gwf-advtidal_10_3.png
GET https://modflow6-examples.readthedocs.io/en/latest/_images/_notebooks_ex-gwf-advtidal_10_4.png
Why is the thumbnail index 5, when there are only 4 plots in the notebook, and nbsphinx is not re-executing the notebook?
A locally built/served site (with latest sphinx and nbsphinx) shows the correct thumbnails, and the thumbnail retrieved for the gallery page is the same asset as the one shown in the notebook (the index is 626, I presume because I've run the notebook many times).
Thanks for reporting this!
I don't know yet how to solve this, but it might have something to do with https://github.com/jupyter/nbconvert/pull/2089, which caused #776 a.k.a. https://github.com/jupyter/nbconvert/issues/2092, and which was (partially?) fixed in https://github.com/jupyter/nbconvert/pull/2142.
Why is the thumbnail index 5, when there are only 4 plots in the notebook, and nbsphinx is not re-executing the notebook?
Yeah, that's the question!
I guess it has to do with the plain text outputs that come before:
In some situations those seem to be considered as a single output (with index 0), which leads to index 1 to 4 for the plots.
However, in some other situations those seem to be considered two outputs (with index 0 and 1), which would lead to index 2 to 5 for the plots.
The behavior might differ depending on the nbconvert version.
I think it works with nbconvert==7.16.3, but it doesn't work with nbconvert<7.14 nor with nbconvert==7.16.4.
nbconvert 7.16.3 does work! thanks for the tip.
#797 should fix this problem for nbconvert>=7.14.
converting python scripts to notebooks with
jupytextin GitHub Actions CI
Out of curiosity, how exactly do you execute your notebooks?
When I try executing a notebook with two consecutive stream outputs, those get merged into one stream output. So far I wasn't able to create a notebook with consecutive stream outputs (which means that this issue cannot arise in the first place).
how exactly do you execute your notebooks?
With jupytext e.g. jupytext --from py --to ipynb --execute ..., invoked from python with Popen(...), driven by pytest executing in parallel via xdist. Here is a CI run. It's a bit goldberg...
I still can't reproduce this with two print() calls.
How/where it the following line in your output created?
<flopy.mf6.data.mfstructure.MFDataItemStructure object at 0x7fda3d9d2ac0>
BTW, removing this output would also have solved the thumbnail problem.
BTW, removing this output would also have solved the thumbnail problem.
I didn't notice the connection between missing thumbnails and text output in the cell that creates the plot. Thanks!
How/where it the following line in your output created?
Deep inside the flopy package, I will have to dig for it — it should really be suppressed in any case