MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.42k stars 313 forks source link

WGLMakie on remote Jupyterlab via Jupyterhub #2464

Open marius311 opened 1 year ago

marius311 commented 1 year ago

WGLMakie runs great locally, but when trying it on a remote Jupyterlab launched via the cluster's Jupyterhub instance, I get this:

Screenshot from 2022-12-03 00-52-57

https://github.com/JuliaPlots/WGLMakie.jl/issues/90 seems related but couldn't figure out what I'm supposed to do.

Is there a way to make this set up work?

julia 1.8.3 / WGLMakie v0.7.4 / Jupyterlab 3.4.7

SimonDanisch commented 1 year ago

You need something like this:

JSServe.configure_server!(listen_url="0.0.0.0", listen_port=9284, forwarded_port=80, external_url=ENV["JH_APP_URL"] * "proxy/9284")

from: https://github.com/MakieOrg/Makie.jl/issues/2358#issue-1420772643

See:

help?> JSServe.configure_server!
  configure_server!(;
          listen_url::String=JSSERVE_CONFIGURATION.listen_url[],
          listen_port::Integer=JSSERVE_CONFIGURATION.listen_port[],
          forwarded_port::Integer=listen_port,
          external_url=nothing,
          content_delivery_url=nothing
      )

  Configures the parameters for the automatically started server.

  Parameters:

  * listen_url=JSSERVE_CONFIGURATION.listen_url[]
      The address the server listens to.
      must be 0.0.0.0, 127.0.0.1, ::, ::1, or localhost.
      If not set differently by an ENV variable, will default to 127.0.0.1

  * listen_port::Integer=JSSERVE_CONFIGURATION.listen_port[],
      The Port to which the default server listens to
      If not set differently by an ENV variable, will default to 9284

  * forwarded_port::Integer=listen_port,
      if port gets forwarded to some other port, set it here!

  * external_url=nothing
      The url from which the server is reachable.
      If served on "127.0.0.1", this will default to http://localhost:forwarded_port
      if listen_url is "0.0.0.0", this will default to http://$(Sockets.getipaddr()):forwarded_port
      so that the server is reachable inside the local network.
      If the server should be reachable from some external dns server,
      this needs to be set here.

  * content_delivery_url=nothing
      You can server files from another server.
      Make sure any file referenced from Julia is reachable at
      content_delivery_url * "/the_file"

This may improve quite a bit with https://github.com/MakieOrg/Makie.jl/pull/2428 and https://github.com/SimonDanisch/JSServe.jl/pull/118

SimonDanisch commented 1 year ago

Make sure to read: https://docs.makie.org/v0.19.0/documentation/backends/wglmakie/index.html#plutoijulia

marius311 commented 1 year ago

Many thanks for the info. However I think its possible you misread? Those instructions seem to be for JuliaHub, whereas here I'm talking about JupyterHub (or maybe the former uses the latter?)

In any case, I don't have a JH_APP_URL to try the above suggestion directly.

I can offer this, from a notebook in the remote Jupyterlab, here's the environment variables I have involving Jupyter or URL that seem relevant:

"JUPYTERHUB_ACTIVITY_URL" => "https://jupyter.nersc.gov/hub/api/users/marius/activity"
"JUPYTERHUB_API_URL" => "https://jupyter.nersc.gov/hub/api"
"JUPYTERHUB_BASE_URL" => "/"
"JUPYTERHUB_CLIENT_ID" => "jupyterhub-user-marius-perlmutter-shared-node-cpu"
"JUPYTERHUB_DEFAULT_URL" => "/lab/tree/global/homes/m/marius"
"JUPYTERHUB_OAUTH_CALLBACK_URL" => "/user/marius/perlmutter-shared-node-cpu/oauth_callback"
"JUPYTERHUB_SERVICE_PREFIX" => "/user/marius/perlmutter-shared-node-cpu/"
"JUPYTERHUB_SERVICE_URL" => "http://0.0.0.0:45149/user/marius/perlmutter-shared-node-cpu/"
"JUPYTERHUB_SINGLEUSER_APP" => "jupyter_server.serverapp.ServerApp"

Any of these potentially should be used? I tied substituting JH_APP_URL with the ones that might make sense and none work as is. Thanks for any advice.

frankier commented 1 year ago

You can use jupyter_server_proxy if only certain ports are allowed to your University's cluster instance https://github.com/MakieOrg/Makie.jl/issues/2405

Obviously it would be nice to streamline this at least a little bit, but for now we're holding out until the rehaul of JSServe makes its way into Makie.