yuvipanda / notebooksharing.space

BSD 3-Clause "New" or "Revised" License
84 stars 10 forks source link

Notebooks with attachments fail to render #22

Open yuvipanda opened 3 years ago

yuvipanda commented 3 years ago

I learnt that nbformat has support for 'attachments', to add arbitrary files in there. TIL!

But https://notebooksharing.space/view/3a6fa233239a26ac5d6b56ef4066ab93503ee7535e20e08d92a32fac2b8b9d37#displayOptions= has them, and fails miserably. Need to investigate


ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 396, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/fastapi/applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/starlette/applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/content_size_limit_asgi/middleware.py", line 56, in __call__
    await self.app(scope, wrapper, send)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/starlette/routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/fastapi/routing.py", line 201, in app
    raw_response = await run_endpoint_function(
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/fastapi/routing.py", line 148, in run_endpoint_function
    return await dependant.call(**values)
  File "./app.py", line 187, in render
    output, resources = exporter.from_notebook_node(
  File "/Users/yuvipanda/code/nbconvert/nbconvert/exporters/html.py", line 119, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "/Users/yuvipanda/code/nbconvert/nbconvert/exporters/templateexporter.py", line 384, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/Users/yuvipanda/code/notebook-static-renderer/nbconvert-template/index.html.j2", line 1, in top-level template code
    {% extends "lab/index.html.j2" %}
  File "/Users/yuvipanda/code/nbconvert/share/jupyter/nbconvert/templates/lab/index.html.j2", line 3, in top-level template code
    {% from 'jupyter_widgets.html.j2' import jupyter_widgets %}
  File "/Users/yuvipanda/code/nbconvert/share/jupyter/nbconvert/templates/lab/base.html.j2", line 224, in top-level template code
    {% set div_id = uuid4() %}
  File "/Users/yuvipanda/code/nbconvert/share/jupyter/nbconvert/templates/base/display_priority.j2", line 1, in top-level template code
    {%- extends 'base/null.j2' -%}
  File "/Users/yuvipanda/code/nbconvert/share/jupyter/nbconvert/templates/base/null.j2", line 26, in top-level template code
    {%- block body -%}
  File "/Users/yuvipanda/code/nbconvert/share/jupyter/nbconvert/templates/base/null.j2", line 29, in block "body"
    {%- block body_loop -%}
  File "/Users/yuvipanda/code/nbconvert/share/jupyter/nbconvert/templates/base/null.j2", line 31, in block "body_loop"
    {%- block any_cell scoped -%}
  File "/Users/yuvipanda/code/nbconvert/share/jupyter/nbconvert/templates/base/null.j2", line 84, in block "any_cell"
    {%- block markdowncell scoped-%} {%- endblock markdowncell -%}
  File "/Users/yuvipanda/code/nbconvert/share/jupyter/nbconvert/templates/lab/base.html.j2", line 93, in block "markdowncell"
    {{ cell.source  | markdown2html | strip_files_prefix }}
  File "/Users/yuvipanda/code/nbconvert/nbconvert/exporters/html.py", line 107, in markdown2html
    return MarkdownWithMath(renderer=renderer).render(source)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 1001, in render
    return self.parse(text)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 1004, in parse
    out = self.output(preprocessing(text))
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 1053, in output
    out += self.tok()
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 1063, in tok
    return getattr(self, 'output_%s' % t)()
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 1168, in output_paragraph
    return self.renderer.paragraph(self.inline(self.token['text']))
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 555, in __call__
    return self.output(text, rules)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 585, in output
    ret = manipulate(text)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 579, in manipulate
    out = getattr(self, 'output_%s' % key)(m)
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 641, in output_link
    return self._process_link(m, m.group(3), m.group(4))
  File "/Users/yuvipanda/.local/share/virtualenvs/notebook-static-renderer/lib/python3.9/site-packages/mistune.py", line 661, in _process_link
    return self.renderer.image(link, title, text)
  File "/Users/yuvipanda/code/nbconvert/nbconvert/filters/markdown_mistune.py", line 163, in image
    assert name in attachments, "missing attachment: {}".format(name)
AssertionError: missing attachment: Untitled_files/figure-markdown/unnamed-chunk-2-1.png