-
Notifications
You must be signed in to change notification settings - Fork 207
Executing and capturing rich output using notebook / nbconvert #421
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
Comments
Thanks for the positive feedback.
One challenge is that I really don't like adding dependencies. More
dependencies make setting this up in a CI more difficult. For instance it
creates unsolvable constraints in the set of conda requirements (we have
a lot of this in scipy-lectures, where each time we change our
requirements we need to fiddle with it for a couple of hours before we
get in a stable situation).
nbconvert comes with a pretty deep set of dependencies. It scares me a
lot. I fear that the consequence is that sphinx-gallery is going to
become impossible to use for projects that already have a complex set of
dependencies.
|
What are the dependencies that you worry about specifically? Is this something that maybe can be fixed in nbconvert, by having optional dependencies? What I like about the suggested approach is that nbconvert solves a problem that we need, and I would rather improve the whole jupyter ecosystem (that is nbconvert) than trying to solve the same issue in multiple packages. I feel your pain, and I'm not saying nbconvert is the only way to go, but if we can make the pain go away it will be a win for all. Do you see a way that would make everybody happy? Maybe a concrete series of steps that need to be taken before you are willing to take nbconvert as a dependency? |
What are the dependencies that you worry about specifically?
Overall the very long list of additional ones.
Is this something that maybe can be fixed in nbconvert, by having
optional dependencies?
That would absolutely help.
What I like about the suggested approach is that nbconvert solves a problem
that we need, and I would rather improve the whole jupyter ecosystem (that is
nbconvert) than trying to solve the same issue in multiple packages.
Yes, but the jupyter ecosystem is a fairly heavy tool :).
Maybe a concrete series of steps that need to be taken before you are
willing to take nbconvert as a dependency?
The most important thing is loosening up the dependencies, both with less
dependencies, and with a flexible set of required version. I just tried
installing nbconvert in one of our working environments, and was really
amazed by what it brought it.
If you're curious, try it in the following environment:
https://github.com/scipy-lectures/scipy-lecture-notes/blob/master/environment.yml
I am right in parallel working to fix a broken CI on a big project, and I
really frown on making this more complex. The situation is that I am the
only one in the group that has enough expertise to do it.
|
These are the packages that nbconvert needed to install for me (in a fresh conda environment with only
No idea which of these is more/less beefy than others, just an FYI :-) |
One path forward is to nest any It does increase our overhead a bit. However, I have a keen interest in getting this to work for MNE, so I can volunteer to take care of the sphinx-gallery CIs. @GaelVaroquaux does that sound like a viable path forward? @maartenbreddels still interested in working toward this? |
I am working on this but trying a different, less opinionated approach.
This seems to me as the path of least resistance. I'm still in doubt if I should do a PR to this repo, or if is should be a new package. I'm trying to reuse as much as possible from sphinx_gallery. |
This new proposal looks like a generalization of what we already have: our existing / default If so, then this sounds like a nice, reasonable generalization of #313. Then perhaps the |
(This would allow SG to stay relatively lean and backward compatible, and s-g-e could have the heavier CI dependencies needed to test and build the docs for the |
indeed, that could be 1 implementation.
That might be a good idea. I'll keep that in mind. My focus is to get something lightweight working, with minimal code and effort. |
Unfortunately this will probably conflict with the refactoring idea, since I think it would be a bit of effort to get all of the interfaces/APIs right at the Sphinx-gallery end in the first place (i.e., just supporting the existing Python workflows properly). For long-term sustainability it would be nice to avoid people having to fork and/or copy-paste bits of sphinx-gallery to get the functionality that they need. So hopefully we can make it work at some point! |
Absolutely agree that would be perfect, but I cannot make promises. The most practical solution for me is I push this to a repo, but not release on PyPI yet, or just deprecate the package once it lands in sge. |
Just a note that this is one reason we created sphinx-gallery-extra...it's a place to play around with useful-but-less-stable code, require more complex dependencies, not support as many older versions of python, etc. Happy to iterate on contributions there @maartenbreddels |
@maartenbreddels not sure if you are still working on this or have new ideas, but basically I lay out a plan in #441 (comment) about how we can support other modules. Basically the idea is to keep code for other scrapers in the modules that need scraping as much as possible, and "just" ensure that SG provides the interfaces necessary to do so. I think this is perhaps the direction we were already headed with the discussion here. If you have an idea for how the APIs of SG would need to be generalized for |
@lesteve : @SylvainCorlay suggested I ping you to include you in the conversation
Dear all,
Let me start with saying this is a really awesome project, and I've already managed to get it working with ipyolume (#420) quite easily.
Together with @SylvainCorlay we have been thinking of how we can have general ipywidgets support, and even xwidget (using C++ kernels).
In parallel to this, there is this PR jupyter/jupyter-sphinx#22 that uses the notebook/nbconvert system to execute code using an arbitrary kernel. If we also take into account the discussion about including HTML output from for instance pandas dataframes, #396 you can probably see an obvious direction to take.
Using the notebook/nbconvert to execute code blocks
Leveraging nbconvert to execute code seems like a very good way forward, since you get many things for free:
Note that we do not require the examples to be in a notebook, just that the code blocks as extracted by sphinx-gallary from the
.py
files to be injected into a (temporary in memory?) notebook, which can be executed by nbconvert as done in jupyter/jupyter-sphinx#22.Screenshots/thumbnails using headless chrome
Since one of the really nice things about the sphinx-gallary is the thumbnail preview, we probably also want to have screenshots generated for rich output (such as widgets). This should be possible to do with headless chrome, as shown in #420. The method should be made more general, and also requires a headless browser (chrome?) to run at readthedocs. This
Summary
The ideal future we see would be:
I/we would like to know if people are on board with this idea, and maybe get input from dev main developers who may have already thought of these ideas. Looking forward to your ideas/comments/blessings/rants.
Regards,
Maarten Breddels
The text was updated successfully, but these errors were encountered: