Skip to content

docs: Generate notebook outputs for web display #268

Open

Description

@mihaic

Currently, we do not show notebook outputs. It would be helpful to do so. However, we do not want to store the outputs in Git because they pollute diffs.

We should investigate the solution used by Scikit-learn:

Activity

  1. added 3 commits that reference this issue on Oct 5, 2017
    146b823
    f64f969
    0d48493
  2. mihaic commented on Feb 27, 2018

    @mihaic
    MemberAuthor

    I think Sphinx-gallery, the solution used by Scikit-learn is not ideal, as discussed in PR #270, where I was trying to use it.

    Instead, I think we should use a solution that works directly with Jupyter notebooks, without converters, potentially Nbsphinx:
    https://github.com/spatialaudio/nbsphinx

  3. mshvartsman commented on Apr 23, 2018

    @mshvartsman
    Contributor

    I did some poking at this, but it is (unfortunately) not trivial. WIP in https://github.com/mshvartsman/brainiak/tree/nbsphinx. There's a few issues keeping this from working:

    1. nbsphinx seems to want notebooks in toctree directives rather than ..include directives in the rst files. Using relative paths in ..include works fine to find notebooks under examples but sphinx tries to process them as rst files. Using relative paths under toctree seems to not find anything above docs. As per http://www.sphinx-doc.org/en/1.5.1/markup/toctree.html, Relative document names (not beginning with a slash) are relative to the document the directive occurs in, absolute names are relative to the source directory. This sounds like relative paths with .. should work but sensible things like ../examples/test or /examples/test or examples/test don't seem to work. An easy but hacky workaround is symlinking examples inside docs during the build process (something we can do in the makefile). I'm open to better options here.

    2. With examples symlinked under docs, we run into another issue, which is that notebook rendering doesn't seem to respect environments. We need to figure out a way to tell nbsphinx which nbconvert to use (which should be the one that is in the env that the builder itself created).

  4. mihaic commented on Apr 15, 2021

    @mihaic
    MemberAuthor

    I found a plugin that allows nbsphinx to use notebooks outside docs:
    https://github.com/vidartf/nbsphinx-link

    I tested it and it works fine. Before submitting a PR, I need to figure out how to separate documentation building from unit testing, because it will not be feasible to run them together anymore.

  5. mihaic commented on Apr 15, 2021

    @mihaic
    MemberAuthor

    MyST-NB is a recent project for executing notebooks in Sphinx. It also works in my simple testing. One advantage over nbsphinx is that it does not depend on Pandoc (which is large and not on PyPI). However, it does not appear to support notebooks outside the Sphinx root:
    executablebooks/MyST-NB#297

  6. mihaic commented on May 28, 2021

    @mihaic
    MemberAuthor

    We ended up going with MyST-NB and it seems to be going well:
    https://github.com/brainiak/brainiak/runs/2689575413?check_suite_focus=true#step:6:938

    I will leave this issue open until we integrate all the existing notebooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions