You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue stems from the discussion here: napari/napari#7319 (comment)
Essentially, the idea was to make a notebook example that involves multiple steps each using the same viewer.
As it turns out, the scraper runs for each block, takes a screenshot, and then the viewer is cleaned up, so any following cells referring to it cause exceptions.
Some details on how to implement single viewer for each example:
The current scraper looks for any QtMainWindow instances and takes a screenshot of all of them. AFAICT we can still do this if we persist the viewer between code blocks.
To clean up the viewer we can use the Sphinx-Gallery config reset_modules, which lets you add a function to run (before|after|before and after) each example.
Taking a look at the examples, the following use code block splitters, which may need to be amended if we change how the screenshot-er works:
🧰 Task
This issue stems from the discussion here: napari/napari#7319 (comment)
Essentially, the idea was to make a notebook example that involves multiple steps each using the same viewer.
As it turns out, the scraper runs for each block, takes a screenshot, and then the viewer is cleaned up, so any following cells referring to it cause exceptions.
One can work around it by calling a new viewer in each cell, as done here:
https://github.com/napari/napari/blob/main/examples/dynamic-projections-dask.py
This looks good:
https://napari.org/stable/gallery/dynamic-projections-dask.html#sphx-glr-gallery-dynamic-projections-dask-py
But the actual notebook is awkward and not how a notebook would be used locally?
Ideally, the scraper would work the same way as jupytext/jupyter book parsing of notebooks in our workshop repo, e.g.
https://napari.org/napari-workshop-template/notebooks/spot_detection.html
Here the viewer persists until closed and
nbscreenshot
can be used to show viewer states.The text was updated successfully, but these errors were encountered: