Skip to content
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

'state' KeyError when calling html_exporter.from_notebook_node #2127

Open
hussam-i-am opened this issue Mar 20, 2024 · 0 comments
Open

'state' KeyError when calling html_exporter.from_notebook_node #2127

hussam-i-am opened this issue Mar 20, 2024 · 0 comments

Comments

@hussam-i-am
Copy link

hussam-i-am commented Mar 20, 2024

Hi, with the most recent release v7.16.2 I noticed that notebooks that do not have the "state" field are causing exceptions to be thrown:

    (html, resources) = html_exporter.from_notebook_node(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/lib/python3.11/site-packages/nbconvert/exporters/html.py", line 268, in from_notebook_node
    html, resources = super().from_notebook_node(nb, resources, **kw)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/lib/python3.11/site-packages/nbconvert/exporters/templateexporter.py", line 424, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/data/notebooks/.venv/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/data/notebooks/app/templates/nbconvert/safe_html/safe_html_index.html.j2", line 1, in top-level template code
    {%- extends 'index.html.j2' -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/lab/index.html.j2", line 4, in top-level template code
    {% from 'jupyter_widgets.html.j2' import jupyter_widgets %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/lab/base.html.j2", line 3, in top-level template code
    {% from 'cell_id_anchor.j2' import cell_id_anchor %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/display_priority.j2", line 1, in top-level template code
    {%- extends 'base/null.j2' -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/null.j2", line 26, in top-level template code
    {%- block body -%}
  File "/data/notebooks/app/templates/nbconvert/safe_html/safe_html_index.html.j2", line 110, in block 'body'
    {% block body_loop %}
  File "/data/notebooks/app/templates/nbconvert/safe_html/safe_html_index.html.j2", line 112, in block 'body_loop'
    window.NOTEBOOK_DATA = {{ super() | process_html }}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/null.j2", line 31, in block 'body_loop'
    {%- block any_cell scoped -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/null.j2", line 34, in block 'any_cell'
    {%- block codecell scoped -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/lab/base.html.j2", line 13, in block 'codecell'
    {{ super() }}
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/null.j2", line 44, in block 'codecell'
    {%- block output_group -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/lab/base.html.j2", line 39, in block 'output_group'
    {{ super() }}
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/null.j2", line 48, in block 'output_group'
    {%- block outputs scoped -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/lab/base.html.j2", line 45, in block 'outputs'
    {{ super() }}
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/null.j2", line 50, in block 'outputs'
    {%- block output scoped -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/lab/base.html.j2", line 92, in block 'output'
    {{ super() }}
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/null.j2", line 67, in block 'output'
    {%- block display_data scoped -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/null.j2", line 68, in block 'display_data'
    {%- block data_priority scoped -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/lab/base.html.j2", line 131, in block 'data_priority'
    {{ super() }}
  File "/data/notebooks/.venv/share/jupyter/nbconvert/templates/base/display_priority.j2", line 7, in block 'data_priority'
    {%- for type in output.data | filter_data_type -%}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/notebooks/.venv/lib/python3.11/site-packages/nbconvert/filters/widgetsdatatypefilter.py", line 58, in __call__
    metadata["widgets"][WIDGET_STATE_MIMETYPE]["state"]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'state'

cc @yuvipanda

@hussam-i-am hussam-i-am changed the title 'state' error when calling html_exporter.from_notebook_node 'state' KeyError when calling html_exporter.from_notebook_node Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant