MLOps Studio notebook test: Conda environment and package persistence
Purpose
Verify how Python dependencies behave after stopping and starting an MLOps Studio notebook server.
The test confirms that:
A new Conda environment stored under
/home/jovyan/.conda/envspersists after the notebook restart.A package installed inside that environment remains available after the restart.
A package installed directly into the default
baseenvironment under/opt/condadoes not persist after the restart.
Test configuration
Create a new MLOps Studio notebook with the following configuration:
Notebook type: standard MLOps Studio notebook
Image:
ghcr.io/kubeflow/kubeflow/notebook-servers/jupyter-scipy:v1.10.0CPU: 4 CPU
Memory: 8 GiB
GPU: not required
Workspace volume: at least 5 GiB
Workspace mount path:
/home/jovyanJEG: not required
KServe access: not required
Pipelines access: not required
Resource note
The test was successfully completed with 4 CPU and 8 GiB RAM.
A smaller configuration, such as 2 CPU and 4 GiB RAM, may also be sufficient, but it was not validated in this test. A notebook with approximately 1.2 GiB RAM was repeatedly terminated with OOMKilled while running conda create.
For a reliable test, use 4 CPU and 8 GiB RAM.
Preconditions
The notebook must have a persistent workspace mounted at:
/home/jovyan
The following environment variables should be configured:
CONDA_ENVS_PATH=/home/jovyan/.conda/envs
CONDA_PKGS_DIRS=/home/jovyan/.conda/pkgs
Do not delete the notebook resource or its PVC during the test. Use only Stop and Start in the MLOps Studio UI.
Test procedure
Step 1 — Verify the Conda configuration
Open a terminal in the notebook and run:
echo "$CONDA_ENVS_PATH"
Expected result:
/home/jovyan/.conda/envs
Run:
echo "$CONDA_PKGS_DIRS"
Expected result:
/home/jovyan/.conda/pkgs
Run:
conda info --base
Expected result:
/opt/conda
Expected interpretation
New Conda environments should be stored on the persistent workspace.
The default
baseenvironment remains under the ephemeral container filesystem.
Step 2 — Create a separate Conda environment
Run:
conda create -y -n persistence-test python=3.11 pip
Wait until the command finishes and the terminal prompt appears again.
Expected output should include:
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
The environment location should be:
/home/jovyan/.conda/envs/persistence-test
Step 3 — Verify the environment location
Run:
conda info --envs
Expected result:
persistence-test /home/jovyan/.conda/envs/persistence-test
base * /opt/conda
Failure condition
The test configuration is incorrect if persistence-test is created under:
/opt/conda/envs/persistence-test
That location is not persistent.
Step 4 — Install a package in the separate Conda environment
Run:
conda run -n persistence-test python -m pip install pyfiglet==1.0.2
Expected result:
Successfully installed pyfiglet-1.0.2
Step 5 — Verify the package before the restart
Run:
conda run -n persistence-test python -c "import pyfiglet; print('PYFIGLET_OK'); print(pyfiglet.__file__)"
Expected result:
PYFIGLET_OK
/home/jovyan/.conda/envs/persistence-test/lib/python3.11/site-packages/pyfiglet/__init__.py
The exact Python patch version in the path may differ.
Step 6 — Stop and start the notebook
In the MLOps Studio UI:
Click Stop for the notebook.
Wait until the notebook is fully stopped.
Click Start.
Wait until the notebook is running and ready.
Open a new terminal.
Do not delete or recreate the notebook. Do not delete its PVC.
Step 7 — Verify persistence of the separate Conda environment
Run:
conda info --envs
Expected result:
persistence-test /home/jovyan/.conda/envs/persistence-test
base * /opt/conda
Run:
conda run -n persistence-test python -c "import pyfiglet; print('PYFIGLET_OK'); print(pyfiglet.__file__)"
Expected result:
PYFIGLET_OK
/home/jovyan/.conda/envs/persistence-test/lib/python3.11/site-packages/pyfiglet/__init__.py
Result
This part is PASS when:
persistence-teststill exists after Stop and Start.pyfigletcan still be imported.The environment and package paths are under
/home/jovyan/.conda/envs.
Default base environment test
Step 8 — Install the package directly into base
Confirm that the terminal prompt starts with (base).
Run:
python -m pip install pyfiglet==1.0.2
Expected result:
Successfully installed pyfiglet-1.0.2
Step 9 — Verify the package location in base
Run:
python -c "import pyfiglet; print(pyfiglet.__file__)"
Expected result:
/opt/conda/lib/python3.11/site-packages/pyfiglet/__init__.py
The exact Python patch version in the path may differ.
This confirms that the package was installed into the ephemeral /opt/conda filesystem.
Step 10 — Stop and start the notebook again
In the MLOps Studio UI:
Click Stop.
Wait until the notebook is fully stopped.
Click Start.
Wait until the notebook is running and ready.
Open a new terminal.
Step 11 — Verify the package in base after the restart
Run:
python -c "import pyfiglet; print(pyfiglet.__file__)"
Expected result:
ModuleNotFoundError: No module named 'pyfiglet'
Result
This part confirms the documented limitation:
Packages installed directly into the default
baseenvironment do not persist.The
baseenvironment is located under/opt/conda./opt/condabelongs to the notebook container filesystem and is recreated when the notebook is restarted.
Expected final result
Area |
Expected result |
|---|---|
|
|
|
|
New Conda environment |
Stored under |
Package in the new environment |
Persists after Stop and Start |
Package installed directly into |
Disappears after Stop and Start |
Default |
|
Pass criteria
The complete test is PASS when:
The new environment is created under
/home/jovyan/.conda/envs.The environment remains available after stopping and starting the notebook.
The package installed in that environment remains importable.
The package installed directly into
basedisappears after stopping and starting the notebook.The behavior matches the expected persistence model.
Troubleshooting
Jupyter connection is lost during conda create
Check whether the notebook container was terminated because of insufficient memory:
kubectl get pod "<POD_NAME>" -n "<NAMESPACE>" -o jsonpath='{range .status.containerStatuses[*]}{.name}{" | restarts="}{.restartCount}{" | lastReason="}{.lastState.terminated.reason}{" | exitCode="}{.lastState.terminated.exitCode}{"\n"}{end}'
An example memory-related failure is:
lastReason=OOMKilled
exitCode=137
In that case, increase the notebook memory and repeat the test.
Recommended tested configuration:
CPU: 4
Memory: 8 GiB
The separate environment disappears after restart
Verify:
echo "$CONDA_ENVS_PATH"
It should return:
/home/jovyan/.conda/envs
Also verify that the notebook workspace is mounted at /home/jovyan and backed by a PVC.
A custom workspace mount path is used
The tested configuration assumes that the persistent workspace is mounted at:
/home/jovyan
If the user changes the PVC mount path, the configured Conda paths may no longer point to persistent storage. This limitation should be documented.