Customize your Kubernetes installation

Add Python packages to your Docker images

Deephaven uses a default set of requirements that provide a working environment when building container images for Kubernetes. To add additional packages to the default virtual environment, a customer_requirements.txt file can be added to the deephaven_python (for Legacy workers) and db_query_worker_dnd (for Community workers) subdirectories of the Docker build. After installing the default packages into the worker's virtual environment, Deephaven will use pip to automatically install the packages listed in customer_requirements.txt.

For example, if we want to make the Python package pybaseball available in the Community Python worker, we create, or edit the existing, docker/db_query_worker_dnd/customer_requirements.txt to specify the package and version:

# customer_requirements.txt allows you to add additional packages to your Deephaven Community workers.
# This file is not updated or included in the Deephaven Helm installation package.
pybaseball==2.2.7

Build and push your images as specified in the installation documentation. When you create a Community Python worker, the package will be available to use:

from pybaseball import statcast

print(statcast(start_dt="2019-06-24", end_dt="2019-06-25"))

img

In order to install a Python package only in the context of the current worker, Community Python workers have a deephaven_enterprise.venv module, which can be used to query the current path to the virtual environment and to install packages into the virtual environment with pip. For example:

from deephaven_enterprise import venv

venv.install(["bs4", "lxml"])

On Kubernetes, dbquery and dbmerge are permitted to write to the default virtual environment of /usr/illumon/coreplus/venv/latest. This has no persistent effects on the system.