Chapter 4. Using basic workbenches
Red Hat OpenShift AI provides access to Start basic workbench as an enabled application for situations where, for example, you do not want users to have their own data science projects or you want to open a Jupyter notebook that was developed outside of OpenShift AI and has no dependencies on other environments.
Note that the preferred way to access workbenches on OpenShift AI is through a data science project, as described in Creating a workbench and selecting an IDE. The advantages to using an OpenShift AI data science project and creating a workbench that includes Jupyter, is that your project organizes your data science work in one place and adds functionality such as connections so that you can access data and save your models and pipelines for automating your ML workflow.
4.1. Starting a basic workbench Copy linkLink copied to clipboard!
Using the basic workbench is based on a server-client architecture. The basic workbench runs in a container on the Red Hat OpenShift cluster. The client is the IDE interface that opens in your web browser on your local computer. However, all of the commands that you enter in the IDE are executed by the workbench. This architecture allows you to interact through your local computer in a browser environment, while all processing occurs on the cluster. The cluster provides the benefits of larger available resources and security because the data being processed never leaves the cluster.
From the Start basic workbench tile, you can start a basic workbench. If you require extra power for use with large datasets, you can assign accelerators to your workbench to optimize performance.
Prerequisites
- You are logged in to Red Hat OpenShift AI.
- You are starting the workbench for the first time or you stopped your workbench.
-
You know the names and values you want to use for any environment variables in your workbench environment, for example,
AWS_SECRET_ACCESS_KEY
. - If you want to work with a large data set, work with your administrator to proactively increase the storage capacity of your workbench. If applicable, also consider assigning accelerators to your workbench.
Procedure
-
In the left navigation pane, click Applications
Enabled. - On the Enabled page, locate the Start basic workbench tile.
Click Open application.
If you see an Access permission needed message, you are not in the default user group or the default administrator group for OpenShift AI. Ask your administrator to add you to the correct group by using Adding users to OpenShift AI user groups.
If your credentials are accepted, the Workbench control panel opens displaying the Start a basic workbench page.
Start a basic workbench.
In the Workbench image section, select the workbench image to use for your workbench.
Different workbench images have different packages installed by default. Click the help icon (?) next to a workbench image name to view a list of its included packages.
If the workbench image contains multiple versions, select the version of the workbench image from the Versions section.
NoteWhen a new version of a workbench image is released, the previous version remains available and supported on the cluster. This gives you time to migrate your work to the latest version of the workbench image.
- From the Container size list, select a suitable container size for your workbench.
- Optional: From the Accelerator list, select an accelerator.
If you selected an accelerator in the preceding step, specify the number of accelerators to use.
ImportantUsing accelerators is only supported with specific workbench images. For GPUs, only the AMD ROCm, PyTorch, TensorFlow, and CUDA workbench images are supported. In addition, you can only specify the number of accelerators required for your workbench if accelerators are enabled on your cluster. To learn how to enable accelerator support, see Working with accelerators.
Optional: Select and specify values for any new Environment variables.
The interface stores these variables so that you only need to enter them once. Example variable names for common environment variables are automatically provided for frequently integrated environments and frameworks, such as Amazon Web Services (AWS).
ImportantSelect the Secret checkbox for variables with sensitive values that must remain private, such as passwords.
- Optional: Check Start workbench in current tab.
Click Start workbench.
The Workbench status progress indicator is displayed. Click the Events log tab to view additional information about the workbench creation process. Depending on the deployment size and resources you requested, starting the workbench can take up to several minutes. Only click Cancel if you want to cancel the workbench creation.
After the server starts, you see one of the following behaviors:
- If you selected Start workbench in current tab in the preceding step, the IDE interface opens in the current tab of your web browser.
- If you did not select Start workbench in current tab in the preceding step, the Workbench status dialog box prompts you to open the server in a new browser tab or in the current browser tab.
Verification
- The IDE interface opens.
Troubleshooting
- If you see the "Unable to load workbench configuration options" error message, contact your administrator so that they can review the logs associated with your workbench pod and determine further details about the problem.
4.2. Creating and importing Jupyter notebooks Copy linkLink copied to clipboard!
You can create a blank Jupyter notebook or import a Jupyter notebook in JupyterLab from several different sources.
4.2.1. Creating a Jupyter notebook Copy linkLink copied to clipboard!
You can create a Jupyter notebook from an existing notebook container image to access its resources and properties. The Workbench control panel contains a list of available container images that you can run as a single-user workbench.
Prerequisites
- Ensure that you have logged in to Red Hat OpenShift AI.
- Ensure that you have launched your workbench and logged in to JupyterLab.
- The workbench image exists in a registry, image stream, and is accessible.
Procedure
-
Click File
New Notebook. If prompted, select a kernel for your Jupyter notebook from the list.
If you want to use a kernel, click Select. If you do not want to use a kernel, click No Kernel.
Verification
- Check that the notebook file is visible in the JupyterLab interface.
4.2.2. Uploading an existing notebook file to JupyterLab from local storage Copy linkLink copied to clipboard!
You can load an existing notebook file from local storage into JupyterLab to continue work, or adapt a project for a new use case.
Prerequisites
- Credentials for logging in to JupyterLab.
- You have a launched and running workbench based on a JupyterLab image.
- A notebook file exists in your local storage.
Procedure
-
In the File Browser in the left sidebar of the JupyterLab interface, click Upload Files (
).
Locate and select the notebook file and then click Open.
The file is displayed in the File Browser.
Verification
- The notebook file is displayed in the File Browser in the left sidebar of the JupyterLab interface.
- You can open the notebook file in JupyterLab.
4.3. Collaborating on Jupyter notebooks by using Git Copy linkLink copied to clipboard!
If your files are stored in Git version control, you can clone a Git repository to work with them in JupyterLab. When you are ready, you can push your changes back to the Git repository so that others can review or use your models.
4.3.1. Uploading an existing notebook file from a Git repository by using JupyterLab Copy linkLink copied to clipboard!
You can use the JupyterLab user interface to clone a Git repository into your workspace to continue your work or integrate files from an external project.
Prerequisites
- You have a launched and running workbench based on a JupyterLab image.
- Read access for the Git repository you want to clone.
Procedure
Copy the HTTPS URL for the Git repository.
-
In GitHub, click ⤓ Code
HTTPS and then click the Copy URL to clipboard icon. - In GitLab, click Code and then click the Copy URL icon under Clone with HTTPS.
-
In GitHub, click ⤓ Code
In the JupyterLab interface, click the Git Clone button (
).
You can also click Git
Clone a repository in the menu, or click the Git icon ( ) and click the Clone a repository button.
The Clone a repo dialog opens.
- Enter the HTTPS URL of the repository that contains your notebook file.
- Click CLONE.
- If prompted, enter your username and password for the Git repository.
Verification
-
Check that the contents of the repository are visible in the file browser in JupyterLab, or run the
ls
command in the terminal to verify that the repository shows as a directory.
4.3.2. Uploading an existing notebook file to JupyterLab from a Git repository by using the CLI Copy linkLink copied to clipboard!
You can use the command line interface to clone a Git repository into your workspace to continue your work or integrate files from an external project.
Prerequisites
- You have a launched and running workbench based on a JupyterLab image.
Procedure
Copy the HTTPS URL for the Git repository.
-
In GitHub, click ⤓ Code
HTTPS and then click the Copy URL to clipboard icon. - In GitLab, click Code and then click the Copy URL icon under Clone with HTTPS.
-
In GitHub, click ⤓ Code
-
In JupyterLab, click File
New Terminal to open a terminal window. Enter the
git clone
command:git clone <git-clone-URL>
git clone <git-clone-URL>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
git-clone-URL>
with the HTTPS URL, for example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
-
Check that the contents of the repository are visible in the file browser in JupyterLab, or run the
ls
command in the terminal to verify that the repository shows as a directory.
4.3.3. Updating your project with changes from a remote Git repository Copy linkLink copied to clipboard!
You can pull changes made by other users into your data science project from a remote Git repository.
Prerequisites
- You have a launched and running workbench based on a JupyterLab image.
- You have credentials for logging in to Jupyter.
- You have configured the remote Git repository.
- You have permissions to pull files from the remote Git repository to your local repository.
- You have imported the Git repository into JupyterLab, and the contents of the repository are visible in the file browser in JupyterLab.
Procedure
-
In the JupyterLab interface, click the Git button (
).
-
Click the Pull latest changes button (
).
Verification
- You can view the changes pulled from the remote repository on the History tab in the Git pane.
4.3.4. Pushing project changes to a Git repository Copy linkLink copied to clipboard!
To build and deploy your application in a production environment, upload your work to a remote Git repository.
Prerequisites
- You have opened a Jupyter notebook in the JupyterLab interface.
- You have added the relevant Git repository to your workbench.
- You have permission to push changes to the relevant Git repository.
- You have installed the Git version control extension.
Procedure
-
Click File
Save All to save any unsaved changes. -
Click the Git icon (
) to open the Git pane in the JupyterLab interface.
Confirm that your changed files appear under Changed.
If your changed files appear under Untracked, click Git
Simple Staging to enable a simplified Git process. Commit your changes.
- Ensure that all files under Changed have a blue checkmark beside them.
- In the Summary field, enter a brief description of the changes you made.
- Click Commit.
-
Click Git
Push to Remote to push your changes to the remote repository. - When prompted, enter your Git credentials and click OK.
Verification
- Your most recently pushed changes are visible in the remote Git repository.
4.4. Managing Python packages Copy linkLink copied to clipboard!
In JupyterLab, you can view the Python packages that are installed on your workbench image and install additional packages.
4.4.1. Viewing Python packages installed on your workbench Copy linkLink copied to clipboard!
You can check which Python packages are installed on your workbench and which version of the package you have by running the pip
tool in a notebook cell.
Prerequisites
- Log in to JupyterLab and open a Jupyter notebook.
Procedure
Enter the following in a new cell in your Jupyter notebook:
!pip list
!pip list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the cell.
Verification
The output shows an alphabetical list of all installed Python packages and their versions. For example, if you use the
pip list
command immediately after creating a workbench that uses the Minimal image, the first packages shown are similar to the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4.2. Installing Python packages on your workbench Copy linkLink copied to clipboard!
You can install Python packages that are not part of the default workbench by adding the package and the version to a requirements.txt
file and then running the pip install
command in a notebook cell.
Although you can install packages directly, it is recommended that you use a requirements.txt
file so that the packages stated in the file can be easily re-used across different workbenches.
Prerequisites
- Log in to JupyterLab and open a Jupyter notebook.
Procedure
Create a new text file using one of the following methods:
- Click + to open a new launcher and then click Text file.
-
Click File
New Text File.
Rename the text file to
requirements.txt
.- Right-click the name of the file and then click Rename Text. The Rename File dialog opens.
-
Enter
requirements.txt
in the New Name field and then click Rename.
Add the packages to install to the
requirements.txt
file.altair
altair
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can specify the exact version to install by using the
==
(equal to) operator, for example:altair==4.1.0
altair==4.1.0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteRed Hat recommends specifying exact package versions to enhance the stability of your workbench over time. New package versions can introduce undesirable or unexpected changes in your environment’s behavior.
To install multiple packages at the same time, place each package on a separate line.
Install the packages in
requirements.txt
to your server by using a notebook cell.Create a new notebook cell and enter the following command:
!pip install -r requirements.txt
!pip install -r requirements.txt
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the cell by pressing Shift and Enter.
ImportantThe
pip install
command installs the package on your workbench. However, you must run theimport
statement in a code cell to use the package in your code.import altair
import altair
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
-
Confirm that the packages in the
requirements.txt
file appear in the list of packages installed on the workbench. See Viewing Python packages installed on your workbench for details.
4.5. Updating workbench settings by restarting your workbench Copy linkLink copied to clipboard!
You can update the settings on your workbench by stopping and relaunching the workbench. For example, if your server runs out of memory, you can restart the server to make the container size larger.
Prerequisites
- A running workbench.
- Log in to JupyterLab.
Procedure
Click File
Hub Control Panel. The Workbench control panel opens.
Click the Stop workbench button.
The Stop server dialog opens.
Click Stop server to confirm your decision.
The Start a basic workbench page opens.
- Update the relevant workbench settings and click Start workbench.
Verification
- The workbench starts and contains your updated settings.