Skip to main content
Version: Python

How to use plug-ins

There are many ways to customize either the Deephaven build or packages to fit your use-cases. In this guide, we extend Deephaven to build a custom Docker image with JS plug-ins installed. For this guide, we will add the js-plugin-matplotlib. This makes the popular Matplotlib library available for use, providing more data visualization options within the Deephaven IDE, such as 3D plots and sophisticated scatter plots. As always, you'll be able to plot both your static and real-time data.

note

In some cases, you'll want to install packages rather than use plug-ins. Those instructions are covered in How to install packages.

To have complete control of the build process, you can can Build and launch Deephaven from source code.

Extend Deephaven

First, follow the Launch Deephaven from pre-built images steps from the Quickstart guide.

To open a Python session, run:

compose_file=https://raw.githubusercontent.com/deephaven/deephaven-core/main/containers/python-examples/base/docker-compose.yml
curl -O "${compose_file}"

Once you have the docker-compose.yml file pulled down, define your own web Docker image in web/Dockerfile that includes the plug-ins you would like to use.

  1. Create the ubdirectory web in the same folder as your docker-compose.yml: mkdir web

  2. Create the Dockerfile for web and open for editing: vi web/Dockerfile

  3. Paste the following into the web/Dockerfile and save:

    # Pull the web-plugin-packager image
    FROM ghcr.io/deephaven/web-plugin-packager:main as build

    # Specify the plugins you wish to use. You can specify multiple plugins separated by a space, and optionally include the version number, e.g.
    # RUN ./pack-plugins.sh <js-plugin-name>[@version] ...
    # For a list of published plugins, see https://www.npmjs.com/search?q=keywords%3Adeephaven-js-plugin

    # Here is how you would install the matplotlib and table-example plugins
    RUN ./pack-plugins.sh @deephaven/js-plugin-matplotlib @deephaven/js-plugin-table-example

    # Copy the packaged plugins over
    FROM ghcr.io/deephaven/web:${VERSION:-latest}
    COPY --from=build js-plugins/ /usr/share/nginx/html/js-plugins/

Many plug-ins will also require a server side component. To define the plug-ins used on the server, create a server/Dockerfile similar to above:

  1. Create subdirectory server in the same folder as your docker-compose.yml: mkdir server

  2. Create the Dockerfile for server and open for editing: vi server/Dockerfile

  3. Paste the following into the server/Dockerfile and save:

    FROM ghcr.io/deephaven/server:${VERSION:-latest}
    # pip install any of the plugins required on the server
    RUN pip install deephaven-plugin-matplotlib

After building, you need to update your docker-compose file to specify using that build. Modify the existing docker-compose.yml file and replace the web and server definitions with the following:

services:
server:
# Comment out the image name
# image: ghcr.io/deephaven/server:${VERSION:-latest}
# Build from your local Dockerfile you just created
build: ./server

...

web:
# Comment out the image name
# image: ghcr.io/deephaven/web:${VERSION:-latest}
# Build from your local Dockerfile you just created
build: ./web

When you're done, your directory structure should look like:

.
├── docker-compose.yml
├── server
│ └── Dockerfile
└── web
└── Dockerfile

Everything's ready to go! Now you just need to run docker-compose up as normal, and you will be using your custom image with your JS plugins installed.

Example

In this guide, we added the js-plugin-matplotlibplug-in so we can now use Matplotlib inside the IDE. Try the following query:

import matplotlib.pyplot as plt
x = [0, 2, 4, 6]
y = [1, 3, 4, 8]
plt.figure()
plt.plot(x, y)

plt.xlabel('x values')
plt.ylabel('y values')
plt.title('plotted x and y values')
plt.legend(['line 1'])
m_figure=plt.gcf()