jupyterhub / jupyter-server-proxy

Jupyter notebook server extension to proxy web services.
https://jupyter-server-proxy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
354 stars 147 forks source link

500 error for Theia IDE #120

Open vnijs opened 5 years ago

vnijs commented 5 years ago

Just tried out the Theia IDE extensions which looks really interesting. Unfortunately I got a 500 error. The developer console shows the following:

image

betatim commented 5 years ago

Could you post a link to reproduce this (if it was on mybinder.org) or more details on your setup if this was a local error?

vnijs commented 5 years ago

Thanks for following up @betatim. Below the information to reproduce. If you need any additional information please let me know.

Docker file:

FROM vnijs/rsm-msba:latest
MAINTAINER Vincent Nijs "radiant@rady.ucsd.edu"
RUN pip3 install jupyter-theia-proxy
EXPOSE 8080 8787 8989 8765
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

Launch command: docker run --rm -p 8989:8989 vnijs/rsm-editors

To view jupyter lab go to http://localhost:8989 and log in using "jupyter" as the password

This builds on another image:

https://cloud.docker.com/u/vnijs/repository/docker/vnijs/rsm-msba

justinmoon commented 5 years ago

I'm having this same error. I'm not sure whether I'm correctly installing the extension. I'm using "the littlest jupyterhub" installed using these instructions BTW.

Within the Jupyter terminal I ran this to attempt to install the relevant extensions:

pip install --user jupyter-server-proxy jupyter-theia-proxy

I installed Theia according to these instructions within the jupyter user's home directory (I tried installing in opt/theia but kept getting Error: ENOENT: no such file or directory, open '/home/jupyter-user2/p ackage.json' errors when I tried to run it from other directories). At this point I can run node_modules/.bin/theia start from the jupyter terminal in my jupyter user's home directory and Theia is accessible at /user/{username}/proxy/3000/#.

But if I try to launch Theia here I get a 500 that doesn't show up in the journalctl logs. The browser inspector shows same error as OP.

theia

These are the last couple lines of the output of running sudo journalctl -u jupyterhub on the server. Nothing regarding the 500 ...

19-05-07 02:18:50.603 JupyterHub proxy:242] Adding user user3 to proxy /user/user3/ => http://127.0.0.1:48223
19-05-07 02:18:50.606 JupyterHub proxy:114] Waiting for /user/user3/ to register with traefik
19-05-07 02:18:50.619 JupyterHub log:158] 200 GET /hub/api (@127.0.0.1) 2.55ms
19-05-07 02:18:50.622 JupyterHub log:158] 302 GET /hub/user/user3/ -> /user/user3/?redirects=1 (user3@70.113.80.71) 2367.26ms
19-05-07 02:18:50.882 JupyterHub log:158] 302 GET /hub/api/oauth2/authorize?client_id=jupyterhub-user-user3&redirect_uri=%2Fuser%2Fuser3%2Foauth_callback&response_type=code&state=[secret] -> /user/user3/oauth_callback?code=[secret]&state=[secret] (user3@70.113.80.71) 18.16ms
19-05-07 02:18:50.984 JupyterHub log:158] 200 POST /hub/api/oauth2/token (user3@127.0.0.1) 24.19ms
19-05-07 02:18:51.012 JupyterHub log:158] 200 GET /hub/api/authorizations/token/[secret] (user3@127.0.0.1) 19.65ms

Server running at http://159.203.110.74 with choose-your-password logins (though I'll probably continue fiddling with it)

Your help is much appreciated (cc @yuvipanda)

justinmoon commented 5 years ago

Do I need to run some variant of jupyter nbextension enable ...? Everything I try generates something like the error below:

$ jupyter nbextension enable --py jupyter_theia_proxy
Traceback (most recent call last):
  File "/opt/tljh/user/bin/jupyter-nbextension", line 11, in <module>
    sys.exit(main())
  File "/opt/tljh/user/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/opt/tljh/user/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/opt/tljh/user/lib/python3.6/site-packages/notebook/nbextensions.py", line 988, in start
    super(NBExtensionApp, self).start()
  File "/opt/tljh/user/lib/python3.6/site-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/opt/tljh/user/lib/python3.6/site-packages/notebook/nbextensions.py", line 896, in start
    self.toggle_nbextension_python(self.extra_args[0])
  File "/opt/tljh/user/lib/python3.6/site-packages/notebook/nbextensions.py", line 872, in toggle_nbextension_python
    logger=self.log)
  File "/opt/tljh/user/lib/python3.6/site-packages/notebook/nbextensions.py", line 483, in enable_nbextension_python
    logger=logger)
  File "/opt/tljh/user/lib/python3.6/site-packages/notebook/nbextensions.py", line 380, in _set_nbextension_state_python
    m, nbexts = _get_nbextension_metadata(module)
  File "/opt/tljh/user/lib/python3.6/site-packages/notebook/nbextensions.py", line 1125, in _get_nbextension_metadata
    'it is missing the `_jupyter_nbextension_paths()` method.'.format(module))
KeyError: 'The Python module jupyter_theia_proxy is not a valid nbextension, it is missing the `_jupyter_nbextension_paths()` method.'
gixita commented 4 years ago

It's not clean, but Theia works in my docker container now FROM jupyter/datascience-notebook:6c3390a9292e RUN conda install nbserverproxy python-language-server flake8 autopep8 && \ jupyter serverextension enable --py --sys-prefix nbserverproxy && \ jupyter labextension install jupyterlab-server-proxy USER root RUN sudo apt update RUN sudo apt install -y ssh RUN sudo apt install -y curl RUN sudo apt remove nodejs RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - && sudo apt-get install -y nodejs RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list && \ sudo apt update && sudo apt install yarn USER jovyan RUN mkdir .theia && mkdir .theia/plugins .theia/extensions RUN pip install jupyter-theia-proxy COPY package.json $HOME WORKDIR $HOME RUN yarn RUN export NODE_OPTIONS="–max-old-space-size=4096" RUN yarn theia build RUN yarn theia download:plugins RUN export PATH="$HOME/node_modules/.bin/theia:${PATH}" USER root RUN ln -s /home/jovyan/node_modules/.bin/theia /usr/bin/theia USER jovyan RUN cp -r $HOME/plugins/* $HOME/.theia/plugins/

gixita commented 4 years ago

I have now Theia working with the latest versions of jupyter dockerstacks images. It's also working with JupyterHub on K8s when mounting the volume to the /home/jovyan folder. In your config.yaml, you need to copy back the files to the volumes, this code goes in the singleuser section :

lifecycleHooks: postStart: exec: command: ["/bin/sh", "-c", "test -f /home/jovyan/.copied || cp -Rf /usr/local/homecopy/jovyan/. /home/jovyan/; touch /home/jovyan/.copied"]

For the Dockerfile, they are some shortcuts that I took, mostly the symbolic link, if someone have a better approach. I installed Theai in an hidden folder and then made other symbolic links, it's because I want the root directory of the users in JupyterHub to be as clean as possible and that's the best way I found yet (we have only one directory appearing src-gen and the package.json file).

FROM jupyter/tensorflow-notebook:6d42503c684f RUN conda install jupyter-server-proxy && \ jupyter serverextension enable --py --sys-prefix jupyter_server_proxy && \ mkdir /home/jovyan/.theiaApp && \ mkdir .theia && mkdir .theia/plugins .theia/extensions USER root

RUN apt update RUN apt install -y curl RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - && apt-get install -y nodejs RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list && \ apt update && apt install yarn

USER jovyan ENV PATH="/usr/bin:${PATH}" WORKDIR /home/jovyan/.theiaApp COPY package.json $HOME/.theiaApp RUN pip install jupyter-theia-proxy && \ yarn && \ export NODE_OPTIONS="–max-old-space-size=4096" && \ yarn theia build && \ yarn theia download:plugins && \ cp -r $HOME/.theiaApp/plugins/* $HOME/.theia/plugins/ && rm -rf $HOME/.theiaApp/plugins ENV PATH="$HOME/.theiaApp/node_modules/.bin:${PATH}" USER root RUN ln -s /home/jovyan/.theiaApp/node_modules/.bin/theia /usr/bin/theia && \ jupyter labextension install @jupyterlab/server-proxy && \ apt autoremove && apt clean && \ mkdir /usr/local/homecopy && chown jovyan /usr/local/homecopy USER jovyan WORKDIR $HOME RUN ln -s /home/jovyan/.theiaApp/src-gen /home/jovyan/src-gen && \ ln -s /home/jovyan/.theiaApp/package.json /home/jovyan/package.json && \ cp -r $HOME /usr/local/homecopy/