You can build a custom image to use R and Python packages. Custom images are based on the
SPSS Modeler runtime image available in
Watson Studio.
Before you begin
Cluster administrator A cluster administrator must
perform this task.
Note: If you use custom images, it is your responsibility to update your custom images with
all the latest updates that are made to the available runtime images in Watson Studio. You are responsible for
installing new fix packs, security updates, or any other updates. When new versions of
Cloud Pak for Data are released,
rebuilding all of your custom images is the best way to keep them updated.
About this task
You can use a custom image to optimize the standard configuration of an SPSS Modeler runtime. You can also use custom
images in air-gapped environments that cannot expose any operations to the internet.
Procedure
- Prepare to build a new image.
- Get the registry URL to use for Docker commands and in scripts.
The SPSS Modeler runtime images
are stored in a Docker image registry. Use a private registry. You can use the URL
to the registry that was used during the installation of Cloud Pak for Data. You can use a
different registry, but then you need to configure Red Hat OpenShift so it can pull
images from that registry. The registry that you use can be outside of the Red Hat
OpenShift cluster.
Use the same URL for all commands and in all the scripts that you run.
- Download the configuration file for the SPSS Modeler runtime image that you want to
customize. For more information, see Downloading the runtime
configuration.
- Download the image in the configuration. For more information, see Downloading the runtime image.
- Download the build-image-for-python-r-packages.zip that
contains the Dockerfile and scripts for installing R and Python
packages.
The archive contains the following files:
- Create the custom runtime image with the files that you downloaded, and add your R
or Python packages.
- Add customizations and build a new image. See Creating a
custom image.
- In Dockerfile from the archive, update
<spss-modeler-base-image> with the tag of the actual
spss-modeler base image that you pulled from the IBM Entitled registry or a private
Container Registry.
Example of the
Dockerfile:
FROM <spss-modeler-base-image> as custom-runtime-for-python-r-packages
USER modeler-user:modeler-user
COPY --chown=modeler-user install-packages.R /tmp/install/
COPY --chown=modeler-user install-Python-packages.sh /tmp/install/
RUN umask 002 \
&& /opt/r/lib/R/bin/Rscript /tmp/install/install-packages.R \
&& bash /tmp/install/install-Python-packages.sh \
&& rm -rf /tmp/install
- If you are installing R packages, add all your package names to the list in
install-packages.R. Every package name must be in double
quotation marks.
install.packages(c(
"pkg-name1",
"pkg-name2",
...),
repos='http://cran.rstudio.com')
- If you are installing Python packages, add all your package names after the
pip install command in
install-Python-packages.sh.
set -e -o pipefail
MODELER_HOME=/opt/IBM/SPSS/ModelerServer/Cloud/
LD_LIBRARY_PATH=$MODELER_HOME/python/lib $MODELER_HOME/python_venv/bin/pip install \
pkg-name1 \
pkg-name2 \
...
- If you want to install only R packages or only Python packages, comment out
the line in Dockerfile for the installation that you want to
skip.
By default,
Dockerfile invokes both
install-packages.R and
install-Python-packages.sh to install the R and Python packages together.
- To install only R packages, comment out
&& bash
/tmp/install/install-Python-packages.sh \.
- To install only Python packages, comment out
&&
/opt/r/lib/R/bin/Rscript /tmp/install/install-packages.R \.
- Push the image to the container server to register it.
- Change and upload the configuration file to use the new custom image.