-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe your context
Please provide us your environment, so we can easily reproduce the issue.
- replace the result of
pip list | grep dashbelow
dash 2.16.1
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table 5.0.0
jupyter-dash 0.4.2
-
if frontend related, tell us your Browser, Version and OS
- OS: MacOS 14.4
- Browser: Chrome
- Version: 122.0.6261.129
Describe the bug
This use case might be a little niche, but I'm trying to use Dash inside a notebook hosted through a web service called Terra. The notebook is hosted via a proxy, and in the past a hack (discovered by a colleague) was able to get it to work using JupyterDash. However, it looks like the integrated solution in Dash doesn't work here due to a timeout. In particular, running:
import dash
dash.jupyter_dash.infer_jupyter_proxy_config()
produces the error:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[9], line 1
----> 1 dash.jupyter_dash.infer_jupyter_proxy_config()
File ~/.local/lib/python3.10/site-packages/dash/_jupyter.py:205, in JupyterDash.infer_jupyter_proxy_config(self)
203 return
204 # Assume classic notebook or JupyterLab
--> 205 _request_jupyter_config()
File ~/.local/lib/python3.10/site-packages/dash/_jupyter.py:137, in _request_jupyter_config(timeout)
134 while True:
135 if (time.time() - t0) > timeout:
136 # give up
--> 137 raise EnvironmentError(
138 "Unable to communicate with the jupyter_dash notebook or JupyterLab \n"
139 "extension required to infer Jupyter configuration."
140 )
141 if _jupyter_comm_response_received():
142 break
OSError: Unable to communicate with the jupyter_dash notebook or JupyterLab
extension required to infer Jupyter configuration.
I tried cloning the repo and editing the hard-coded timeout (at 2 seconds), but couldn't get the package to install with pip install .. (If anyone could provide some instructions on getting this to work I could try testing this out.)
Further Details
Previously, the "hack" to get this to work in the past went as follows:
## Run these two then comment and restart the kernel
# ! pip install dash
# ! pip install jupyter_dash
import os
from jupyter_dash.comms import _jupyter_config
port = 8050
gcs_project = os.environ["GOOGLE_PROJECT"]
runtime_name = os.environ["RUNTIME_NAME"]
base_subpath = f'/notebooks/{gcs_project}/{runtime_name}/'
server_url = f'[https://notebooks.firecloud.org/proxy/{gcs_project}/{runtime_name}/jupyter/proxy/{port}/](https://notebooks.firecloud.org/proxy/%7Bgcs_project%7D/%7Bruntime_name%7D/jupyter/proxy/%7Bport%7D/)'
_jupyter_config.update({
'type': 'base_url_response',
'server_url': server_url,
'base_subpath': base_subpath,
'frontend': 'notebook'
})
import jupyter_dash
from dash import html
app = jupyter_dash.JupyterDash(__name__)
app.layout = html.Div([
html.P("Hello World!"),
html.P("Hello Terra!")
])
app.run_server(mode="external", port=8050)
The proxy URL would get configured manually using some config object from JupyterDash. It would be great if the magic method could also infer this sort of info (in case the Terra API changes), but exposing some of these options in the new integrated Dash would be second best.
Expected behavior
The method would hopefully handle setting up the proxy config stuff behind the scenes and work like it did with the hack for JupyterDash.