Skip to content
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

Default thumbnail asset not found #796

Closed
wpbonelli opened this issue May 7, 2024 · 8 comments · Fixed by #797
Closed

Default thumbnail asset not found #796

wpbonelli opened this issue May 7, 2024 · 8 comments · Fixed by #797

Comments

@wpbonelli
Copy link
Contributor

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

@mgeier
Copy link
Member

mgeier commented May 9, 2024

Thanks for reporting this!

I don't know yet how to solve this, but it might have something to do with jupyter/nbconvert#2089, which caused #776 a.k.a. jupyter/nbconvert#2092, and which was (partially?) fixed in jupyter/nbconvert#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.

@mgeier
Copy link
Member

mgeier commented May 9, 2024

I think it works with nbconvert==7.16.3, but it doesn't work with nbconvert<7.14 nor with nbconvert==7.16.4.

wpbonelli added a commit to MODFLOW-USGS/modflow6-examples that referenced this issue May 11, 2024
* render pathlines as tubes in 3d plots to minimize path point color artifacts
* use vtk with setup-headless-display-action instead of vtk-osmesa
* improve zoom and legend font size in 3d plots
* export 3d plots as PNG instead of PDF/SVG
* wrap long comments in P04
* try pinning nbconvert==7.16.3 to fix notebook thumbnails as suggested in spatialaudio/nbsphinx#796
@wpbonelli
Copy link
Contributor Author

nbconvert 7.16.3 does work! thanks for the tip.

@mgeier
Copy link
Member

mgeier commented May 13, 2024

#797 should fix this problem for nbconvert>=7.14.

@mgeier
Copy link
Member

mgeier commented May 13, 2024

converting python scripts to notebooks with jupytext in 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).

@wpbonelli
Copy link
Contributor Author

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

@mgeier
Copy link
Member

mgeier commented May 16, 2024

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.

@wpbonelli
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants