jupyterhub / jupyter-rsession-proxy

Jupyter extensions for running an RStudio rsession proxy
BSD 3-Clause "New" or "Revised" License
118 stars 87 forks source link

Removed custom jupyterlab extension? #51

Closed vnijs closed 5 years ago

vnijs commented 5 years ago

Prior to some of the latest commits we could start Rstudio from JupyterLab but that no longer seems to work. We noticed the commit message "Remove custom jupyterlab extension". Is this functionality coming back?

cc @tbpetersen @yuvipanda

yuvipanda commented 5 years ago

Heya, @vnijs / @tbpetersen. It's been moved to https://github.com/jupyterhub/jupyter-server-proxy/tree/master/jupyterlab-server-proxy, where it's more generic and usable by everyone. Here's a screenshot: https://pbs.twimg.com/media/DvyL3wkVsAAPcMg.jpg

@vnijs you should install from the last released version until, say, tomorrow - where we'll make a new release with a new name. Are you currently installing from master?

vnijs commented 5 years ago

That looks great! Thanks @yuvipanda! From the icons show it seems this could also be used to launch specific Shiny apps correct?

FYI I just tried adding jupyter labextension install jupyterlab-server-proxy to our Dockerfile but that currently gives the message below

> /usr/bin/npm pack jupyterlab-server-proxy
npm ERR! code E404
npm ERR! 404 Not Found: jupyterlab-server-proxy@latest

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-01-02T21_29_09_873Z-debug.log

Errored, use --debug for full output:
ValueError: "jupyterlab-server-proxy" is not a valid npm package
yuvipanda commented 5 years ago

@vnijs I've just made some beta style releases. Try https://jupyter-server-proxy.readthedocs.io/en/latest/launchers.html? You can install RStudio support with pip install jupyter-rsession-proxy (rather than nbrsessionproxy)

vnijs commented 5 years ago

@yuvipanda I was able to install jupyter-rsession-proxy. Rstudio and Shiny work from Jupyter Notebook (nice!) but I don't see any extra launcher icons in Jupyter Lab for some reason. Any suggestions? I used the following in our Dockerfile

RUN pip3 install jupyterhub jupyter-rsession-proxy \
  && jupyter labextension install jupyterlab-server-proxy

Related question: Starting Shiny from Jupyter Notebook it tries runs an app from the (mounted) home directory. Is there a way to explicitly set the directory to use (e.g., /srv/shiny-server/radiant/inst/app)?

ryanlovett commented 5 years ago

The shiny component looks for the app in the current working directory. If it doesn't find one there, you can browse its built-in filesystem viewer until it finds and runs an app in alternative location.

In binder you can set urlpath to an alternative location, e.g. http://mybinder.org/v2/gh/binder-examples/r/master?urlpath=shiny/bus-dashboard/

In JupyterHub with notebook, you just replace "tree" in the URL with "shiny", e.g. https://example.org/hub/user-redirect/shiny/path/to/shiny/app/.

JupyterLab uses workspaces and I can never get those URLs right.

mathematicalmichael commented 5 years ago

This has been pretty hard for me to get configured... would appreciate some help. What would need to be added to a dockerfile that pulls the docker-stacks/datascience-notebook in order to get rstudio and rshiny installed, with lab showing the additional icons discussed here? i tried adding RUN pip3 install jupyterhub jupyter-rsession-proxy \ && jupyter labextension install jupyterlab-server-proxy as per @vnijs

vnijs commented 5 years ago

For shiny to work take a look at rocker on Github. I'm not using conda but take a look at my docker file to download and install Rstudio and Shiny. You will need at least those I assume.

https://github.com/radiant-rstats/docker/tree/master/r-bionic

The URLs that @ryanlovett posted do work but I would love some additional information about how to get this working with the launcher icons as @yuvipanda posted.

yuvipanda commented 5 years ago

@vnijs I just made https://github.com/yuvipanda/jupyter-launcher-shortcuts to help you add multiple custom launcher icons to JupyterLab :) You can add as many as you want to as many shiny applications - just set target to {base_url}shiny/<path-to-application>/ (trailing slash is important).

Let me know how it goes.

vnijs commented 5 years ago

That looks great! Will try it out tomorrow

mathematicalmichael commented 5 years ago

@vnijs thanks for the heads up. Still not quite able to add it on top of the datascience notebooks, but I added some of the pre-built images as options for dockerspawner when i log into jupyterhub, so it's at least functioning, if not in the same environment. that's fine, though. the datascience-notebook stacks come with r kernel already, I just couldn't get the rstudio/shiny aspect working, even when adding installation instructions to the dockerfiles that started from datascience-notebook

@yuvipanda thanks for being so awesome. I've gotten so much learning done by going through your repos.

vnijs commented 5 years ago

@yuvipanda I'm trying out your new "shortcuts" option. Partial success so far I'd say using the code below.

RUN pip3 install jupyterhub jupyter-rsession-proxy jupyter-launcher-shortcuts \
  && jupyter labextension install jupyterlab-server-proxy \
  && jupyter labextension install jupyterlab-launcher-shortcuts
  1. I don't see an option to launch Rstudio in Jupyter Notebook or in Jupyter Lab and am gettting some JS errors.

image

  1. There is a new icon for the shiny app (nice!). However, I'm not sure how to set the 'target' in this case. The path to the app is in /srv/shiny-server/radiant/inst/app/ in the docker container but the below results in a 404. Does the path only work relative to the (mounted) home directory of the user?

'{base_url}shiny/srv/shiny-server/radiant/inst/app/`

Would something like the following be possible?

c.LauncherShortcuts.shortcuts = {
    'Radiant': {
        'title': 'Radiant: Business analytics using R and Shiny',
        'path': '/srv/shiny-server/radiant/inst/app/'
        'target': '{base_url}radiant',
    }
}

image

yuvipanda commented 5 years ago

@vnijs yay re: shiny. You are right that currently you can only have the base be based off current working directory. Possible ways around this include symlinks (ugh), or starting the notebook server with working directory of / while setting default URL to the directory you actually want. There's also a security issue here of being able to access literally any file on the system as a user through the web, which is something to avoid.

Maybe the thing to do is 'how to launch shiny with a custom shiny.conf', since that lets you control where you want the shiny server to be run from (and other params). Does that sound right?

I'll investigate the notebook extensions later. As for RStudio - can you tell me what's the output of jupyter serverextension list and jupyter labextension list?

Thanks.

vnijs commented 5 years ago

A shortcut wouldn't work well in my setting I think because the container mounts the users home director on the host os. I do actually have a shiny.conf file. If jupyter could read/parse it that could work.

https://github.com/radiant-rstats/docker/blob/master/radiant/shiny-server.conf

Results from the commands you mentioned:

jovyan@74682dab1f69:~$ jupyter serverextension list
config dir: /usr/local/etc/jupyter
    jupyterlab  enabled
    - Validating...
      jupyterlab 0.35.4 OK
    jupyter_launcher_shortcuts  enabled
    - Validating...
      jupyter_launcher_shortcuts  OK
    jupyterlab_git  enabled
    - Validating...
      jupyterlab_git  OK
jovyan@74682dab1f69:~$ jupyter labextension list
JupyterLab v0.35.4
Known labextensions:
   app dir: /usr/local/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v0.38.1  enabled  OK
        @jupyterlab/git v0.5.0  enabled  OK
        jupyterlab-launcher-shortcuts v1.0.0-beta1  enabled  OK
        jupyterlab-server-proxy v0.1.0-beta2  enabled  OK
yuvipanda commented 5 years ago

@vnijs can you explicitly pip install jupyter-server-proxy too and see if that makes the RStudio icons show up?

vnijs commented 5 years ago

I think that is actually what I did already :) See code chunk below. Just built the image again to double check. JS errors shown in image.

image

RUN pip3 install jupyterhub jupyter-server-proxy jupyter-rsession-proxy jupyter-launcher-shortcuts \
  && jupyter labextension install jupyterlab-server-proxy \
  && jupyter labextension install jupyterlab-launcher-shortcuts
yuvipanda commented 5 years ago

Ah, in your earlier comment I see:

RUN pip3 install jupyterhub jupyter-rsession-proxy jupyter-launcher-shortcuts \

but no jupyter-server-proxy. The nbextension needs more work probably, but did it change anything in Lab?

Thank you for testing somewhat beta quality software :)

vnijs commented 5 years ago

Nope. No changes in lab. Happy to test something that will be really useful to me and my students :)

On Fri, Jan 4, 2019, 11:31 AM Yuvi Panda notifications@github.com wrote:

Ah, in your earlier comment I see:

RUN pip3 install jupyterhub jupyter-rsession-proxy jupyter-launcher-shortcuts \

but no jupyter-server-proxy. The nbextension needs more work probably, but did it change anything in Lab?

Thank you for testing somewhat beta quality software :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jupyterhub/jupyter-rsession-proxy/issues/51#issuecomment-451544498, or mute the thread https://github.com/notifications/unsubscribe-auth/AC3CrG34xJiTtegPpNDq-MNA6gwg_3Nbks5u_6vmgaJpZM4ZnOGJ .

yuvipanda commented 5 years ago

@vnijs thank you for testing! Can you tell me what version of python you are using?

yuvipanda commented 5 years ago

And in your python, can you run 'import jupyter_server_proxy'?

vnijs commented 5 years ago

Importing works in python 3.6.7 (ubuntu 18.04) in a docker container.

image

yuvipanda commented 5 years ago

@vnijs hmm, curious. The underlying issue seems to be that jupyter-server-proxy isn't visible in jupyter serverextension list for some reason.

I pushed a couple of new releases just now with some fixes, can you try again?

vnijs commented 5 years ago

Thanks @yuvipanda. I just re-built the image but get the same results (see screen shots below). I'm not 100% sure, however, if I got the updated version. Is there a way to check? jupyter_server_proxy doesn't seem to have a .version attribute.

In case it is useful, the Dockerfile is linked below. I haven't push the image to docker hub yet but can do so it that would be helpful.

https://github.com/radiant-rstats/docker/tree/master/rsm-jupyterhub

image

image

yuvipanda commented 5 years ago

@vnijs hah, I think I know what's happening! If you don't install jupyter-launcher-shortcuts, it should work. Try it and let me know? I'll try fixing it upstream shortly.

vnijs commented 5 years ago

@tbpetesen built his own version of the image (yesterday?) and we now see the icons for Rstudio and Shiny showing up in JupyterLab. However, if I use the below code now I do not.

RUN pip3 install jupyterhub jupyter-rsession-proxy \
  && jupyter labextension install jupyterlab-server-proxy
vnijs commented 5 years ago

FYI Just got a report from @tbpetesen that rebuilding with the code below does not work the currently available versions of jupyter-rsession-proxy & extension jupyterlab-server-proxy but did with a (slightly) earlier version. Unfortunately I don't know which version(s) worked.

RUN pip3 install jupyterhub jupyter-rsession-proxy \ && jupyter labextension install jupyterlab-server-proxy

vnijs commented 5 years ago

Just ran the build step again with the code below and it is working now! I'd still love to be able to add a custom shortcut if is is possible to add a path to the shiny app that is, for example, in /srv but for now I have the main thing I need for upcoming classes. Thanks @yuvipanda!!!

RUN pip3 install jupyterhub jupyter-rsession-proxy \
  && jupyter labextension install jupyterlab-server-proxy

image

vnijs commented 5 years ago

FYI When launching a shiny app from Rstudio there is an issue with parcing the url it seems (see screenshot below). This does work when using Rstudio server directly (i.e., not through jupyterhub). Let me know if I should file this as a separate issue.

image

yuvipanda commented 5 years ago

@vnijs please do file it as a separate issue. I wonder if we switched from 'rsession' to 'rstudio' because of this issue...

vnijs commented 5 years ago

Thanks @yuvipanda. I opened two new issues and will close this one.