berkeley-dsep-infra / datahub

JupyterHubs for use by Berkeley enrolled students
https://docs.datahub.berkeley.edu
BSD 3-Clause "New" or "Revised" License
62 stars 37 forks source link

Cant do new windowing on Jupyterhub - Julia FUND model for Data 100 #3079

Closed ericvd-ucb closed 2 years ago

ericvd-ucb commented 2 years ago

Bug description

My understanding is that Jupyterhub as deployed cannot popup a new window from the session. There are profs from time to time who need this functionality becaused they use it on their local install.

I worked with a couple of folks on Getting JuliaHub set up to run the FUND model that David Anthoff uses for the Social Cost of Carbon models, and was hoping to make a Demo for Data 100.

In the end - they did not use a Julia hub demo because a key part of the workflow is to run the model and then go in to a model variable explorer mode, which pops out a different window. Which doesnt seem to work on our deployment. I am putting this issue here for us to think about how to work around this in the future? @yuvipanda

This issue is not urgent in any way, and my most sincere apologies if I am out of my depth and cannot get something simple to run because of my lack of knowledge

Environment & setup

Julia Hub

How to reproduce

[<!--

  1. Go to '...'
  2. Change '....'
  3. Run '....'
  4. See error --> https://julia.datahub.berkeley.edu/hub/login?next=%2Fhub%2Fuser-redirect%2Fgit-pull%3Frepo%3Dhttps%253A%252F%252Fgithub.com%252Fdavidanthoff%252Fteaching-2019-aere-workshop%26urlpath%3Dlab%252Ftree%252Fteaching-2019-aere-workshop%252F

Then try to run Notebook 2 - Hands on session and you can't "explore the model"

felder commented 2 years ago

When I attempt to do this I get the following error before:

Screen Shot 2021-12-13 at 10 41 01 AM

balajialg commented 2 years ago

I am also getting the same error when I run the notebook!

ericvd-ucb commented 2 years ago

Right. So none of us really get Julia nor FUND so can debug. But. My understanding is that part of the issue is not popping out an additional window to display things. They might need to program things on the Julia side to solve this it might have nothing to do with Jupyterhub.

felder commented 2 years ago

@ericvd-ucb What I am trying to say is it's unclear from your bug description what steps need to be taken to reproduce this and what visual confirmation of the error actually looks like. Note that the error I've listed above occurs BEFORE running the step that would permit you to "explore the model"

You bug description seems to assume knowledge of how the notebook is supposed to work that your support personnel does not possess. Can you please describe in a bit more detail which step in the notebook fails and what I should see when it does?

In short the most useful bug descriptions provide (within reason) step by step instructions that reliably reproduce the error and a good description (or screen shot) of what the error you're receiving looks like. That information allows me to reproduce the error with a high a degree of certainty that what you're describing is what I'm seeing.

ryanlovett commented 2 years ago

@ericvd-ucb Regarding:

If you are running this notebook on your local computer, you can explore the results of your model interactively:

if use_explore
explore(m)
end

It looks like the explore function provided by the Mimi package wants to launch an electron window.

If I ignore the plot_comp_graph issue that others ran into and run explore(m) directly, I see:

/opt/julia/pkg/artifacts/8731693ea495ec92614ea8a5da62f8e66909f0c1/electron: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory

Since electron is a graphical desktop app, I can see why it'd work on a desktop computer but not within a non-desktop jupyter session. (the glib error also means that electron won't execute properly either) It'd be ideal if the explore function had an option to render HTML within a notebook cell. At worst, if explore was starting a web server then it could use jupyter-server-proxy to proxy it. This is what we did for a cogneuro connector ages ago which started up a local webgl service.

ryanlovett commented 2 years ago

This is where jupyter could proxy the explorer web app: https://github.com/mimiframework/Mimi.jl/blob/master/src/explorer/explore.jl#L33 https://github.com/mimiframework/Mimi.jl/blob/master/src/explorer/explore.jl#L111

But the explore function would have to be altered significantly.

ericvd-ucb commented 2 years ago

@ryanlovett thanks so much for your explanation, much appreciated, you rock

@felder apologies on my side for not being more clear or articulate. I had misdiagnosed what the blocker was

yuvipanda commented 2 years ago

We actually already do this for EECS - they have some circuit diagramming stuff that pops up a window. We run a Linux desktop environment in there (see https://discourse.jupyter.org/t/run-linux-desktop-apps-in-mybinder-org-your-jupyterhub/11964?u=yuvipanda for a recent blog post on how that works). So you open the linux desktop environment in a tab (https://eecs.datahub.berkeley.edu/hub/user-redirect/desktop opens it), run your notebook on another tab, and when the window pops up, it shows up in the first tab!

We could try to enable this on the Julia hub. It isn't super complicated.

yuvipanda commented 2 years ago

I got it to work now! Woohoo :D

image

How to test this:

  1. Open the desktop view in Julia. You can do this from the launcher in JupyterLab, or go to this URL:
  2. Use the provided nbgitpuller URL to fetch the notebooks
  3. Go to src/2_HandsOnSession_RunningModels.ipynb
  4. Change use_explore = false; to use_explore = true;
  5. Start running cells, one by one. Some might take upto a minute.
  6. Run the cell that has this code:
    if use_explore
        explore(m)
    end
  7. In the desktop tab you opened in step 1, the visualizer will open! It might take a few seconds to render for the first time, but it should work fine and reasonably low latency

This is pretty cool :D Try it out and let me know?

ryanlovett commented 2 years ago

That's awesome!

It'd be cool if there could be an in-kernel, but kernel-agnostic, way of launching the desktop proxy to prep GUIs. I guess !desktop-proxy or %desktop wouldn't work outside of ipython kernel.

ericvd-ucb commented 2 years ago

Thanks - this is cool! I hope @davidanthoff and @lrennels check this out!

balajialg commented 2 years ago

@yuvipanda super cool stuff!

balajialg commented 2 years ago

Closing this bug considering the amazing hack done by @yuvipanda!