I want to deploy a Dash/Plotly application on Renkulab using jupyter-server-proxy similar to the streamlit example described here: How to deploy Streamlit in renku
from jupyter_dash import JupyterDash
JupyterDash.infer_jupyter_proxy_config()
app = JupyterDash(__name__)
(details are defined here...)
if __name__ == "__main__":
app.run_server(mode="jupyterlab", debug=False, port=5000, host='0.0.0.0')
If I call the python script locally it works. However, in Renkulab I receive the following error when starting the session:
Any ideas what could be missing? I also tried a version using gunicorn instead of calling the python script directly (this is for example required when deploying the app on Heroku) with the same result.
Hey @manuelknott can you share a link to the project? If the one where this has been tried contains information you don’t want to share, you can make another one just for testing this.
thanks for pointing out the mismatching ports. I fixed it in the current commit of the minimal example.
However, the “Loading…” issue still remains, and I dug deeper into it:
The main issue is that jupyter_dash works like a charm when being called from a jupyter notebook environment, as this is the library’s main purpose. It does not work when being called from a python file since it is dependent on the jupyter_dash frontend extension.
I tried a couple of things:
Calling a notebook with papermill or nbconvert does not work as the jupyter extensions are not used.
Calling the python script with “jupyter run …” does not work (same issue)
I also tried to not use the above mentioned dependencies but to serve the plain flask app (see the “no_jupyterdash” branch in the example’s repo) → no success so far
There is also a related github issue here.
I tried adding requests_pathname_prefix='/proxy/8050/' to the JupyterDash constructor.
The logs show that the app is running at {host}:8888/proxy/8050, but it is still stuck in the “loading…” phase.
When opening the “lab” environment with my image, I receive a popup that the lab extension “jupyterlab-dash” is missing. Not sure if that would solve anything. Would maybe be worth a try to add it to the Renku Image.
Hi Manuel. Did you manage to solve it? After many hours of trial and error I also got stuck in the same place and I am also running out of ideas. I did not get the popup of lab extension “jupyterlab-dash” missing, but I arrived to the “loading…” phase. Any new suggestions would be highly appreciated. Many thanks in advance!
If you simply click the Build button everything should work just fine @champost.
Did you have any issues with it? I tested on my end and the dashboard works just fine and does not show that message. And from what I can tell the jupyterlab environment is also functional.
I will take a look if I can get that message to go away.
Do I have to commit these changes, push to Gitlab, wait for the CI/CD build and then restart a session with the new image (in this order) to preview my update ?
Yes currently that is the only “proper” way to get your changes.
What you suggested with looking up the PID, killing that process and then waiting for the new version to start is really smart and it is great that it works. Thanks for sharing that.
Just wanted to mention the following if somebody else runs into a related problem (independent though of Renku).
When using the same port to display/update by running/re-running some Dash app code, there appears an Address already in use... error due to werkzeug==2.2.2 and downgrading werkzeug to 2.2.1solves the problem as of now.
The Dash app MWE (proposed by @tolevski further ) doesn’t start automatically on renkulab.io with the latest Renku minimal Python template as it should even though it has been specified in /home/jovyan/work/<project-name>/jupyter_notebook_config.py with the following server process configuration :