Closed swelborn closed 7 months ago
The issue is related that on a remote setup not all the port might be open (as opposed to locally) so you need to either use trame-jupyter-extension or the server proxy of jupyter.
When the extension is available, it will be automatically detected and use the existing JupyterComm instead of its own WebSocket endpoint.
But if you are using JupyterHub and you have the server-proxy installed you can let trame know to use it instead of relying on its own direct server URL.
So the idea will be to do the following
app = Cone()
await app.ui.ready
app.ui.iframe_builder = "jupyter-hub" # Available options: serverproxy, jupyter-extension, jupyter-hub
app.ui
If that does not work, you have other controls to fine-tune the iframe URL, but that will depend on your setup and it might not be easy to explain what you should do without seeing the runtime environment.
I am not having any luck using any of the available options in your list, and I cannot add a labextension to the shared jupyterhub at nersc.
When I do "jupyter-hub", I get a 404 that takes me back to our entrypoint to the hub if I click control panel:
I can make recursive jupyterlab logins but that is not very helpful.
"serverproxy" yields nothing:
This is the URL I am connected to when I log into jupyterhub, maybe this helps?
https://jupyter.nersc.gov/user/swelborn/perlmutter-login-node-base/lab/tree/global/homes/s/swelborn/gits/trame-test-py312/examples/jupyter/show.ipynb
I did get this to work on vscode remote by asking what the port was and adding it to my list of forwarded ports. I'm assuming you could pass in a trame_server.Server instance into the MyTrameApp constructor to set up preconfigured ports, etc.
So it seems that jupyter-server-proxy is not available. Unless I know more about what's available and how trame can leverage the existing infrastructure, I won't be of much help.
ok! i will ask someone who knows the answer and get back to you.
We have jupyter server proxy installed/enabled, but we have named servers. Thus we have a prefix to make my server run at: https://jupyter.nersc.gov/user/swelborn/perlmutter-login-node-base
For our dask dashboard, we have to do something like this "{JUPYTERHUB_SERVICE_PREFIX}proxy/{host}:{port}/status"
Does this help?
Yes it does, thank you. We'll try to get back to you with the proper way to configure trame so it can work at NERSC.
FYI @alesgenova
Do you know how you can get {host}
?
You might be able to do something like
def nersc_iframe(layout):
host = os.environ['HOSTNAME']
server = layout.server
template_name = layout._template_name
src = f"{os.environ['JUPYTERHUB_SERVICE_PREFIX']}proxy/{host}:{server.port}/index.html?ui={template_name[16:]}&reconnect=auto"
elem_id = f"{server.name}_{template_name}"
return {
"id": elem_id,
"src": src,
"style": layout.iframe_style,
**layout.iframe_attrs,
}
app.ui.iframe_builder = nersc_iframe
app.ui
You can find the current jupyter-hub
implementation
We finally got a chance to test it on NERSC and the issue was with our "jupyter-hub" implementation, we were generating 2 slash in a row. The latest version of "trame-client>=2.17.1" is now fixing it.
On top of that, it should automatically detect the jupyter-hub environment so you should not need to set the __iframe_builder__ at all.
And in case I've also added a jupyter-hub-host option.
Describe the bug
The example from https://kitware.github.io/trame/guide/deployment/jupyter.html does work in jupyter on my local machine (mac), both in jupyter and vscode.
I am trying to test this out on NERSC through both NERSC's jupyterhub and vscode. It doesn't render in either.
It is understandable that NERSC's jupyterhub -- I have had issues rendering widgets from third parties (e.g., bqplot widgets are not registered with the jupyterlab instance they are running on the hub, and so they can't render there). Ideally it would work there, though.
However, I'm unsure why it wouldn't work through vscode. I have tried two routes:
Select python from conda env binary as kernel:
Select existing jupyterlab instance after registering test-trame-py312 in available kernels:
Connect to this jupyterlab server:
Select "Existing jupyter server"
When I connect to the server through vscode, I see that it is starting the kernel
[I 2024-03-03 09:30:49.879 ServerApp] Kernel started:
and I can import trame, etc. When I run the example (cone) I don't get a render. You can see that it shows the first output line ('new resolution 6'), but no cone:
even though
--log-level=DEBUG
on the jupyterlab instance shows that display_data is executing in the UI output cell.I also tried this with python=3.10 to no avail.
Unsure how to further debug. Let me know if you can reproduce, would be good to know if it is something with NERSC environment that is causing this.
Install commands
Expected behavior
To be able to run on a remote host through vscode's jupyter support.
Platform:
OS: