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

appmode with pip installed extension #8

Closed
epifanio opened this issue Mar 27, 2018 · 7 comments
Closed

appmode with pip installed extension #8

epifanio opened this issue Mar 27, 2018 · 7 comments

Comments

@epifanio
Copy link

epifanio commented Mar 27, 2018

I'm trying to run notebooks in appmode but I hit the following error when I try to switch to app mode in the notebook user interface:

[I 03:30:31.695 NotebookApp] Kernel started: 59776d40-ee5f-4c1e-9467-20718c25b8f1
[I 03:30:32.771 NotebookApp] Adapting to protocol v5.1 for kernel 59776d40-ee5f-4c1e-9467-20718c25b8f1
[I 03:30:45.389 NotebookApp] Starting buffering for 59776d40-ee5f-4c1e-9467-20718c25b8f1:870d6b38c4d34de8ae9cfadd26fe146d
[I 03:30:45.897 NotebookApp] Kernel shutdown: 59776d40-ee5f-4c1e-9467-20718c25b8f1
[I 03:30:47.785 NotebookApp] Appmode get: bokeh.ipynb
[I 03:30:47.786 NotebookApp] Appmode creating tmp copy: /.bokeh-1.ipynb
[E 03:30:48.408 NotebookApp] Uncaught exception GET /apps/bokeh.ipynb?appmode_scroll=594 (73.159.130.83)
    HTTPServerRequest(protocol='http', host='epinux.com:8888', method='GET', uri='/apps/bokeh.ipynb?appmode_scroll=594', version='HTTP/1.1', remote_ip='73.159.130.83')
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/dist-packages/tornado/web.py", line 1541, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/usr/local/lib/python3.6/dist-packages/tornado/web.py", line 2949, in wrapper
        return method(self, *args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/appmode/server_extension.py", line 46, in get
        mathjax_config=self.mathjax_config,
      File "/usr/local/lib/python3.6/dist-packages/notebook/base/handlers.py", line 424, in render_template
        return template.render(**ns)
      File "/usr/local/lib/python3.6/dist-packages/jinja2/asyncsupport.py", line 76, in render
        return original_render(self, *args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/jinja2/environment.py", line 1008, in render
        return self.environment.handle_exception(exc_info, True)
      File "/usr/local/lib/python3.6/dist-packages/jinja2/environment.py", line 780, in handle_exception
        reraise(exc_type, exc_value, tb)
      File "/usr/local/lib/python3.6/dist-packages/jinja2/_compat.py", line 37, in reraise
        raise value.with_traceback(tb)
      File "/usr/local/lib/python3.6/dist-packages/appmode/appmode.html", line 1, in top-level template code
        {% extends "notebook.html" %}
      File "/usr/local/lib/python3.6/dist-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/usr/local/lib/python3.6/dist-packages/notebook/templates/page.html", line 153, in top-level template code
        {% block header %}
      File "/usr/local/lib/python3.6/dist-packages/notebook/templates/notebook.html", line 117, in block "header"
        {% for exporter in get_custom_frontend_exporters() %}
    jinja2.exceptions.UndefinedError: 'get_custom_frontend_exporters' is undefined
[E 03:30:48.462 NotebookApp] {
      "Host": "epinux.com:8888",
      "Connection": "keep-alive",
      "Upgrade-Insecure-Requests": "1",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
      "Referer": "http://epinux.com:8888/notebooks/bokeh.ipynb",
      "Accept-Encoding": "gzip, deflate",
      "Accept-Language": "en-US,en;q=0.9,it;q=0.8",
      "Cookie": "_ga=GA1.2.83393038.1521552015; _xsrf=2|e960f8e1|7ed49e6a98d1a1b482c3758a9494a6ce|1521757424; G_ENABLED_IDPS=google; username-epinux-com-8888=\"2|1:0|10:1522114195|24:username-epinux-com-8888|44:OTM0ZjJjZDNiMWY4NGVkYWFjMTc0MzJjNDRiMmRjMWU=|50a3de1b3bb279227518e327e3a506cfc62882cf860d0d0cc583b2b167d99ef2\""
    }
[E 03:30:48.462 NotebookApp] 500 GET /apps/bokeh.ipynb?appmode_scroll=594 (73.159.130.83) 677.95ms referer=http://epinux.com:8888/notebooks/bokeh.ipynb

@oschuett
Copy link
Owner

Hi, which version of Jupyter are you using?

@epifanio
Copy link
Author

jupyter --version
4.4.0

@oschuett
Copy link
Owner

So, I think the root cause is this recent commit: jupyter/notebook@198d74a. It added a new argument get_custom_frontend_exporters to the render_template() call is which replicated in Appmode .

What's puzzling me though is that you are already using this code, because it is only in the master branch and not yet in 5.4.x branch. Therefore, it is also not part of the latest release.

I will however have to adopt Appmode soon. So, thanks for the early warning :-)

@epifanio
Copy link
Author

epifanio commented Mar 27, 2018

yes, true most of my system runs on git:master branch for the main repository. I'll keep an eye on your changes and install appmode from git:master as well. Thanks!

@oschuett
Copy link
Owner

Before I adopt Appmode, I would like to wait until this change actually gets released by the notebook project. In the meantime I would suggest that you patch server_extension.py yourself. It should look kinda like this (haven't tested it):

 from notebook.notebook.handlers import get_custom_frontend_exporters     # new line
...
 self.write(self.render_template('appmode.html',
            notebook_path=tmp_path,
            notebook_name=tmp_name,
            kill_kernel=False,
            mathjax_url=self.mathjax_url,
            mathjax_config=self.mathjax_config,
            get_custom_frontend_exporters=get_custom_frontend_exporters,  # new line
            )
 )

@epifanio
Copy link
Author

Applied the patch, it works great!
on both single user notebook and multiuser jupyterhub.
Thanks!

@oschuett
Copy link
Owner

I just released Appmode 0.3.0 and I decided to include the patch for this issue after all. Hopefully, this minimizes the trouble for everybody else once Jupyter notebook make their release.

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

2 participants