Skip to content
Snippets Groups Projects
Singularity 3.71 KiB
BootStrap: docker
Registry: http://localhost:5000
Namespace:
From: promod:latest

%post
##############################################################################
# POST
##############################################################################

# CHANGE DASH TO BASH
rm /bin/sh
ln -sf /bin/bash /bin/sh

# INSTALL NGL AND JUPYTER WITH PIP
######################################
pip install --no-cache-dir nglview==1.1.6 \
                           jupyter==1.0.0

# SETUP JUPYTER
###############
mkdir -p /usr/local/share/ipython
mkdir -p /usr/local/share/jupyter
mkdir -p /usr/local/etc/jupyter
mkdir -p /usr/local/share/jupyter/runtime
mkdir -p /usr/local/share/jupyter/kernels/ost-kernel
chmod a+rw -R /usr/local/share/ipython
chmod a+rw -R /usr/local/share/jupyter
chmod a+rw -R /usr/local/etc/jupyter
chmod a+rw -R /usr/local/share/jupyter/runtime
cat > /usr/local/share/jupyter/kernels/ost-kernel/kernel.json <<EOF
{
	"display_name": "OST",
	"language": "python",
	"argv": [
		"python",
		"-m", "ipykernel",
        "-f", "{connection_file}",
		"--InteractiveShellApp.exec_PYTHONSTARTUP=False",
		"--InteractiveShellApp.exec_files=['/usr/local/lib64/python2.7/site-packages/ost/ost_startup.py']"
	],
	"env": {
	}
}
EOF

jupyter nbextension enable nglview --py --sys-prefix

%environment
##############################################################################
# ENVIRONMENT
##############################################################################
export QT_X11_NO_MITSHM=1
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=$JUPYTER_PATH/runtime

%apprun Notebook
##############################################################################
# NOTEBOOK APP
##############################################################################
jupyter notebook --NotebookApp.iopub_data_rate_limit=10000000 --no-browser "$@"

%apphelp Notebook
A Jupyter notebook playground with OST ProMod3 and nglview.

Usage:

    singularity run --app Notebook <IMAGE> [options]

The Jupyter notebook is run by default with `--NotebookApp.iopub_data_rate_limit=10000000`
and `--no-browser` options.

Useful options when running on remote server:
    --ip=<Unicode> (NotebookApp.ip)
        Default: 'localhost'
        The IP address the notebook server will listen on.
    --port=<Integer> (NotebookApp.port)
        Default: 8888
        The port the notebook server will listen on.

Copy the URL to the browser and launch the notebook with OST kernel. This will
load all necessary OST components just like in the OST shell.
ProMod3 modules can be imported as needed. We also enabled
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

%runscript
##############################################################################
# RUNSCRIPT
##############################################################################
cat << EOF
Singularity container for OST $OPENSTRUCTURE_VERSION and ProMod3 $PROMOD_VERSION

This container can run the ost, pm or chemdict_tool executables. 
For convenience, a jupyter notebook playground with OST, ProMod3 and nglview is 
available.

To run ost, pm or chemdict_tool executables, use the exec command.
E.g. to run scripts with pm:

singularity exec <IMAGE> pm my_script.py [options]

To get more information on how to run the Notebook run:

singularity help --app Notebook <IMAGE NAME>
EOF