mljar/mercury

trying to run mercury in jupyterhub with jupyter-server-proxy

Closed this issue · 13 comments

hey,
I am trying to run mercury in jupyterhub with jupyter-server-proxy and we're able to set up the environment in docker container.
but after running the container and launching the mercury server we're getting 404 and 302 error fetching css and js files.
any idea why this is happening?

Hi @kriyanshishah,
I've never tried jupyter-server-proxy, do you have link for docs on how to deploy it? Do you have Dockerfile available, so I can check it?

hey, so here we are running jupyter server proxy[https://github.com/jupyterhub/jupyter-server-proxy] and trying to run mercury under jupyterhub.

we are writing jupyter_server_config along with the jupyterhub docker container. andwhen I am running test python server it works fine. (example below.)

c.ServerProxy.servers = {
    "test-server": {
        "command": ["python3", "-m", "http.server", "{port}"],
        "absolute_url": False
    }
}

Now,
when I set config for mercury server I get error as I am not getting pages at jupyterhub/user/username.

the config for mercury I have set as:

    "mercury-server": {
        "command": ["mercury", "run"],
        "absolute_url": False,
        "launcher_entry": True
    }

to use jupyter-server-proxy:
pip install jupyter-server-proxy

to enable extension
jupyter serverextension enable --sys-prefix jupyter_server_proxy

and then start jupyterhub.

Hi @kriyanshishah,

Thank you for information. Do you have some screenshot from 404 and 302 errors that are fetching css and js files? What is the URL that is in the request?

Mercury is serving all static files by default on main route /, maybe the static files should be build like for deployment on subpath. Here is docs showing deployment for subpath https://runmercury.com/docs/docker-compose/#deploy-on-subpath

It's not limited to building those static files. The tsx files have hard coded 'api/v1' end points and the python code on server side in mercury/apps has also similar end points hard coded because mercury is not only about serving those static files plainly.

@pplonski so what the issue is
when we run mercury with jupyter-server-proxy it runs at 127.0.0.0:8000/user/username/mercury.
and there is no way all the requests are going there. All the requests go directly at port 8000
so that each of the get request should have prefix /user/username/mercury to get the main index.html, and make it work.
is there any easy way to add prefix to each of the request and modify it for each user??
right now the workaround we have done is to hard code prefix for each request and generate build for it, and using http proxy with that particuler sub path. so,
we run jupyterhub at 127.0.0.1:8000 port , and with jupyter-server-proxy we start mercury server at 127.0.0.1:8080 port and using node proxy at port 9000 and listening at at 8080 with /user/jovyan/mercury subpath.
this is just a hacky way it works.
We still have a lot to figure out to make it easy to generate for each username.
please tell us if there is an easy way to add prefix subpath.
cheers,
kriyanshi.

Hi @kriyanshishah,

Please take a look at docs on how to deploy Mercury on subpath https://runmercury.com/docs/docker-compose/#deploy-on-subpath Hope this will help.

did some change with django code and ran with node proxy, and was able to run it from jupyterhub for each user pod.

Great! @kriyanshishah could you please code changes so others with similar problem can benefit? Thank you! 👍

Hi @pplonski , I am also interested running mercury as subpath of user server.
I have proxy installed and mercury is accessible by $hub_address/user/john%20lenon/proxy/8000 (mercury is running on port 8000)
But all links to statics are broken and lead to $hub_address/hub/static/ instead of $hub_address/user/john%20lenon/proxy/8000/static/ making the webpage blank.
I also saw that links at sources index.html are build from PUBLIC_URL and REACT_APP_LOCAL_URL (static)

Maybe I can somehow manipulate PUBLIC_URL per user server and make it be $hub_address/user/john%20lenon/proxy/8000/ and it will work out?
Any other ideas to make it work are highly appreciated
Thank you for this impressive project and your hard work

hey.
https://github.com/kriyanshishah/mercury

this version of mercury works within jupyterhub.
let me know if this helps you

@kriyanshishah

  1. How to install your specific version?
  2. Is it in sync with original mercury code updates?
    Thanks