Getting started with Bokeh in Domino

akshay.ambekar
akshay.ambekar Moderator, Domino Posts: 25 mod

Here's how you can do cool things with Bokeh in Domino:

1. Installation: You can simply  pip install bokeh along with these dependencies in a compute environment that you are working from in Domino. If you are starting afresh, you can simply use the Domino Analytics Distribution (DAD) compute environment which should have the bokeh package and its related dependencies already installed for you, so you can skip this step and move to step 2!


2. Building a bokeh app: To demonstrate this, I created a simple app file called sliders.py in my test project by using the code at https://github.com/bokeh/bokeh/blob/master/examples/app/sliders.py 


3. Live testing the bokeh app: You can leverage jupyter server proxy to host your code as an app from within a jupyter workspace. To do so, ensure that jupyterlab and jupyter server proxy are installed in the compute environment before you launch a jupyterlab workspace. If you are using a DAD environment, this should be already installed for you.

Considering that the bokeh app file sliders.py is ready for development/testing in my /mnt directory in my project files, launch a new terminal in jupyterlab and serve your bokeh app using the following commands:

bokeh serve --show sliders.py --allow-websocket-origin='*'

This will start the bokeh server and you will be able to access your app in a new browser tab by building a URL with the run-id of your workspace:

https://<your-domino-url>/<your-username>/<your-project-name>/notebookSession/<run-id>/proxy/<bokeh-port>/<app-name>

In my case, I grabbed the run-id for my workspace from the URL and built a new URL for live testing the bokeh app as follows:

https://akshay.cs.domino.tech/domino-aksambe/test/notebookSession/5ff60031b135e411d2782112/proxy/5006/sliders


4. Publishing the app (once development is done): You can publish this app in Domino with just a bunch of clicks once the app development is complete. To do so, create an app.sh file in your project and add the following contents inside:

bokeh serve --show sliders.py --allow-websocket-origin='*' --address=0.0.0.0 --port=8888

The app.sh file tells Domino what to deploy. Observe that we've added address and port as parameters which we had skipped in the previous step while serving our app. The address and port as 0.0.0.0 and 8888 respectively, is required for hosting apps in Domino. After you save the app.sh file, you can navigate to Publish > App > Follow the form and Start the App.

Once the app is published, you can view your app by clicking the View App button. If the bokeh app does not show up, you can view your app at https://<your-domino-url>/u/<your-username>/<your-project-name>/app . I viewed the app by navigating to https://akshay.cs.domino.tech/u/domino-aksambe/test/app which in turn redirected the browser to https://akshay.cs.domino.tech/domino-aksambe/test/r/notebookSession/5ff600e0ee756c28e1d1ba24/sliders


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!