From e7975e4d4e817ecd3d6aaac929cbc2c2ebd91187 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Thu, 4 May 2023 13:37:05 +0200
Subject: [PATCH] SCHWED-5908 Fixes for updated ProMod3 Singularity image

The following issues were observed:
- warning about non-writable directory which was set as IPYTHONDIR env var
  Not very surprising, it's a directory that lives in container space...
- stale kernels
  I didn't investigate that one properly. It had something to do with bending
  around all Jupyter/IPython relevant directories to custom set directories
  in the image. Reason for doing that is potential Python modules that reside
  in user home of the host that get imported in the container. I removed the
  bending around with the full knowledge that the described problem may occur.
- version updates
  Some changes related to different Python versions between old base image
  (Ubuntu 20.04) and the new one (Ubuntu 22.04).
---
 container/Singularity | 35 +++++++++++------------------------
 1 file changed, 11 insertions(+), 24 deletions(-)

diff --git a/container/Singularity b/container/Singularity
index 004c139e..7808b57c 100644
--- a/container/Singularity
+++ b/container/Singularity
@@ -13,27 +13,23 @@ ln -sf /bin/bash /bin/sh
 
 # INSTALL SYSTEM DEPS
 #####################
-apt-get update -y && apt-get install -y python3-pip
+apt-get update -y && apt-get install -y ipython3 jupyter python3-pip
 pip3 install ipywidgets==7.6.0
 pip3 install nglview \
-             ipython \
-             jupyter 
+             six
+
+# SET LOCALE
+############
+echo "LC_ALL=en_US.UTF-8" >> /etc/environment
+echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
+echo "LANG=en_US.UTF-8" > /etc/locale.conf
+locale-gen en_US.UTF-8
 
 # SETUP IPYTHON / JUPYTER
 #########################
-export IPYTHONDIR="/usr/local/share/ipython"
-export JUPYTER_CONFIG_DIR="/usr/local/etc/jupyter"
 export JUPYTER_PATH="/usr/local/share/jupyter"
-export JUPYTER_RUNTIME_DIR="/tmp/jupyter_runtime"
-mkdir -p /usr/local/share/ipython
 mkdir -p $JUPYTER_PATH
-mkdir -p $JUPYTER_RUNTIME_DIR
-mkdir -p $JUPYTER_CONFIG_DIR
 mkdir -p $JUPYTER_PATH/kernels/ost-kernel
-chmod a+rw -R /usr/local/share/ipython
-chmod a+rw -R $JUPYTER_PATH
-chmod a+rw -R $JUPYTER_CONFIG_DIR
-chmod a+rw -R $JUPYTER_RUNTIME_DIR
 cat > $JUPYTER_PATH/kernels/ost-kernel/kernel.json <<EOF
 {
   "display_name": "OST",
@@ -43,7 +39,7 @@ cat > $JUPYTER_PATH/kernels/ost-kernel/kernel.json <<EOF
     "-m", "ipykernel",
         "-f", "{connection_file}",
     "--InteractiveShellApp.exec_PYTHONSTARTUP=False",
-    "--InteractiveShellApp.exec_files=['/usr/local/lib64/python3.8/site-packages/ost/ost_startup.py']"
+    "--InteractiveShellApp.exec_files=/usr/local/lib64/python3.10/site-packages/ost/ost_startup.py"
   ],
   "env": {
   }
@@ -60,13 +56,7 @@ export TEMP="/tmp"
 export TEMPDIR="/tmp"
 export TMPDIR="/tmp"
 export TMP="/tmp"
-# As the Singularity mounts $HOME by default Jupyter and Ipython config files
-# are moved to separate directories. Proper environmental variables are also 
-# set
-export IPYTHONDIR="/usr/local/share/ipython"
-export JUPYTER_CONFIG_DIR="/usr/local/etc/jupyter"
 export JUPYTER_PATH="/usr/local/share/jupyter"
-export JUPYTER_RUNTIME_DIR="$TMPDIR/jupyter_runtime"
 
 
 %apprun ChemdictTool
@@ -201,7 +191,7 @@ and goes to CWD. Thus this sould work as expected out of the box.
 # NOTEBOOK ENV
 ##############################################################################
 export DNG_ROOT=$OST_ROOT
-export DNG_INITDIR=${DNG_ROOT}/lib64/python3.8/site-packages/ost
+export DNG_INITDIR=${DNG_ROOT}/lib64/python3.10/site-packages/ost
 
 
 %apprun IPython
@@ -261,9 +251,6 @@ load all necessary OST/ProMod3 components just like in the OST shell. We also en
 the nglview widget to interactively view molecular structures and trajectories.
 For more details on how to use nglview see http://nglviewer.org/nglview/latest/.
 
-As the Singularity mounts $HOME by default Jupyter and Ipython config files
-are moved to separate directories. Proper environmental variables are also set.
-
 To list of all available options:
 
     singularity run --app Notebook <IMAGE> --help
-- 
GitLab