spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
453 stars 130 forks source link

AssertionError in `depart_codearea_latex()` #781

Closed hakonanes closed 4 months ago

hakonanes commented 6 months ago

Hi, and thanks again for creating and maintaining nbsphinx.

The RTD LaTeX builds of orix (https://beta.readthedocs.org/projects/orix/builds/23890511/) have started throwing an AssertionError in these lines:

https://github.com/spatialaudio/nbsphinx/blob/53be5e632f0c9483ba65ba6690da9b137f9c1120/src/nbsphinx/__init__.py#L1870-L1875

The traceback:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/sphinx/cmd/build.py", line 298, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/sphinx/application.py", line 355, in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 290, in build_update
    self.build(['__all__'], to_build)
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 363, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/sphinx/builders/latex/__init__.py", line 318, in write
    docwriter.write(doctree, destination)
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/sphinx/writers/latex.py", line 88, in translate
    self.document.walkabout(visitor)
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 10 more times]
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/docutils/nodes.py", line 199, in walkabout
    visitor.dispatch_departure(self)
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/sphinx/util/docutils.py", line 599, in dispatch_departure
    method(node)
  File "/home/docs/checkouts/readthedocs.org/user_builds/orix/conda/latest/lib/python3.11/site-packages/nbsphinx/__init__.py", line 1875, in depart_codearea_latex
    assert False
AssertionError

Versions:

~Note that I can't reproduce locally on macOS, so I'm not sure how easy it will be to debug this.~ I can reproduce this on my Mac. If necessary, I can create a MWE. Any insight from nbsphinx developers would be appreciated.

For reference, we're tracking our issue here: https://github.com/pyxem/orix/issues/475.

mgeier commented 6 months ago

Thanks for the report!

It would be ideal if you could provide a minimal .ipynb file that reproduces the problem. Even if it's not minimal, it would also help if you could provide a notebook with the code cell outputs.

hakonanes commented 5 months ago

I'm 99% certain this issue results from tqdm compatibility as reported in https://github.com/spatialaudio/nbsphinx/issues/776.

This is how the progressbars look in our online docs now (here):

bilde

mgeier commented 5 months ago

776 has been fixed in nbconvert release v7.16.4. Can you please check if that happens to fix your problem as well?

hakonanes commented 4 months ago

I can confirm that using nbconvert 7.16.4 fixed our problem, thanks!