scipy: DOC: Interactive notebooks in stats tutorials are not working in version 1.15 docs.

Issue with current documentation:

It appears that the interactive notebooks in the stats tutorials are not working in the new version 1.15 docs. The kernel selection menu does not list any available kernels. This was first pointed out to me by @mdhaber. The devdocs are still working as expected. See https://docs.scipy.org/doc/scipy/tutorial/stats/hypothesis_chi2_contingency.html for an example of a notebook that isn’t working, and https://scipy.github.io/devdocs/tutorial/stats/hypothesis_chi2_contingency.html for the corresponding working notebook in the devdocs.

The notebooks work properly when I build them locally off the v1.15.0 branch. In the dev console on Firefox, I see an error for the stable docs which doesn’t appear for the dev docs, message pasted in the additional context section below.

Idea or request for content:

@agriyakhetarpal, do you know what might be going on? I remember that you’re working on documentation for how to change the pyodide kernel version for the built documentation, and I think that may be helpful here. As far as I know, I don’t think there is anything special @tylerjereddy needs to do during the release process to make these work.

Additional context (e.g. screenshots, GIFs)

No kernel found in the kernel selection menu:

no_kernel

The error I’m seeing in the dev console

Uncaught (in promise) TypeError: e is undefined
    Ce toc.js:513
    s toc.js:421
    s toc.js:419
    c toc.js:480
    d index.es6.js:555
    emit index.es6.js:513
    emit index.es6.js:112
    _onCellInViewportChanged widget.js:652
    d index.es6.js:555
    emit index.es6.js:513
    emit index.es6.js:112
    set inViewport widget.js:164
    attachWidget windowing.js:198
    insertWidget index.es6.js:2516
    _updateForDeferMode widget.js:758
    _runOnIdleTime widget.js:727
    _runOnIdleTime widget.js:743

Here’s the relevant code from toc.js. Line 513 is the one with if (heading.type === Cell.HeadingType.Markdown) {

/**
 * Get the element id for an heading
 * @param heading Heading
 * @param parser The markdownparser
 * @returns The element id
 */
export async function getIdForHeading(heading, parser, sanitizer) {
    let elementId = null;
    if (heading.type === Cell.HeadingType.Markdown) {
        elementId = await TableOfContentsUtils.Markdown.getHeadingId(parser,
        // Type from TableOfContentsUtils.Markdown.IMarkdownHeading
        heading.raw, heading.level, sanitizer);
    }
    else if (heading.type === Cell.HeadingType.HTML) {
        // Type from TableOfContentsUtils.IHTMLHeading
        elementId = heading.id;
    }
    return elementId;
}

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 22 (22 by maintainers)

Most upvoted comments

I made a PR to jupyterlite-sphinx, https://github.com/jupyterlite/jupyterlite-sphinx/pull/271, with a patch that makes the make dist doc build work locally for me. jupyterlite-sphinx calls jupyter using subprocess.run, and the virtual environment build/env isn’t active when this runs, so at least on my machine, a different jupyter was getting used. I changed it to make it so jupyter gets called with the current Python executable.

Thanks @agriyakhetarpal

or the 404 error you notice in the message immediately above: I’ve seen this happen before, and rebuilding the docs plus clearing the cache/cookies usually helps – could you please try that if you haven’t already? This might be one of our cues to resolve jupyterlite/jupyterlite-sphinx#121 (comment), because the state from an older docs build does quite frequently creep into a new docs build.

~I’ve rebuilt the docs and cleared cache, and now see the same behavior locally as I do on the deployed docs. The devdocs work, but the kernel cannot be found for the version 1.15.0 docs.~ Trying again, I think I did something wrong.

make dist looks like this in the docs makefile,

dist:
	install -d build
	rm -rf build/env
	$(PYTHON) -mvenv --system-site-packages build/env
	$(CURDIR)/build/env/bin/python -mpip install -r ../requirements/doc.txt
	$(CURDIR)/build/env/bin/python -mpip install ..
	make PYTHON="$(CURDIR)/build/env/bin/python" doc-dist

and when running make dist, the logging shows jupyterlite-pyodide-kernel being installed. Perhaps rather than not being installed, the kernel is not being found. ~That the kernel is found for the devdocs makes it seem unlikely the kernel wasn’t installed.~

Nevermind, the devdocs when building locally just link to the actual deployed devdocs, and then when I went back to version 1.15.0, it was the actually deployed stable docs. The only behavior I’m seeing locally is the file not found error for the stable docs, regardless of clearing cache and rebuilding.

Thanks @lesteve.

Not very familiar with the scipy setup, so a bit of a wild guess but a possible reason may be that jupyterlite-pyodide-kernel is not installed when building the scipy 1.15 JupyterLite?

I thought it might be that too, but jupyterlite-pyodide-kernel is in the doc requirements everywhere it should be.

https://github.com/scipy/scipy/blob/6e246d0b54dd55dc69232a0caae6772228a7ac25/requirements/doc.txt#L13-L14

https://github.com/scipy/scipy/blob/6e246d0b54dd55dc69232a0caae6772228a7ac25/pyproject.toml#L114-L115

https://github.com/scipy/scipy/blob/6e246d0b54dd55dc69232a0caae6772228a7ac25/environment.yml#L50-L51

so should be getting installed.

By the way, maybe I misremember, but I thought the sphinx-jupyterlite extension was opening inside the doc page (kind of thebe-like) at one point and now it seems to open a full notebook a new tab? I guess related to jupyterlite/jupyterlite-sphinx#242.

You don’t misremember. There are instances of both. Examples sections are opened inline within the page (though not enabled now), and tutorials are opened in a separate tab.