Colab notebooks with widget outputs fail due to missing state var
I'm building a simple Jupyter book with one notebook that was created and downloaded from Google Colab (also opened and saved locally).
For jupyter book I have execute set to off and have no widgets in my notebook.
reading sources... [100%] Stereoscope
Exception occurred:
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/jupyter_sphinx/execute.py", line 283, in contains_widgets
return widgets and widgets["state"]
KeyError: 'state'
The full traceback has been saved in /var/folders/1y/1rd4wh5x3hz548vp04mqdqy80000gn/T/sphinx-err-g82hh2tk.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Traceback (most recent call last):
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/jupyter_book/sphinx.py", line 150, in build_sphinx
app.build(force_all, filenames)
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/sphinx/application.py", line 348, in build
self.builder.build_update()
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 299, in build_update
len(to_build))
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 311, in build
updated_docnames = set(self.read())
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 418, in read
self._read_serial(docnames)
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 439, in _read_serial
self.read_doc(docname)
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 479, in read_doc
doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/sphinx/io.py", line 223, in read_doc
pub.publish()
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/docutils/core.py", line 218, in publish
self.settings)
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/sphinx/io.py", line 128, in read
self.parse()
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/docutils/readers/__init__.py", line 77, in parse
self.parser.parse(self.input, document)
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/myst_nb/parser.py", line 84, in parse
self.env.config["nb_render_plugin"],
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/myst_nb/parser.py", line 203, in nb_to_tokens
if contains_widgets(ntbk):
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/jupyter_sphinx/execute.py", line 283, in contains_widgets
return widgets and widgets["state"]
KeyError: 'state'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/adamgayoso/.pyenv/versions/3.7.6/bin/jupyter-book", line 8, in <module>
sys.exit(main())
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/jupyter_book/commands/__init__.py", line 305, in build
result, builder, OUTPUT_PATH, build_type, PAGE_NAME, click.echo
File "/Users/adamgayoso/.pyenv/versions/3.7.6/lib/python3.7/site-packages/jupyter_book/commands/__init__.py", line 546, in builder_specific_actions
raise RuntimeError(_message_box(msg, color="red", doprint=False)) from result
RuntimeError:
===============================================================================
There was an error in building your book. Look above for the cause.
===============================================================================
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Hey @adamgayoso - I'm guessing that this has to do with how Colab is saving widgets in the notebook metadata, we've had a few inconsistencies with how Colab handles this in the past. I'd recommend generating the notebooks from a Jupyter interface to make sure the widget state is properly saved in the notebook.