Skip to content
Snippets Groups Projects
Select Git revision
  • 0a712e0be4bccbb4c0c5b9cf1347169c80c285e3
  • master default protected
  • noelp-master-patch-87404
  • disable-view
  • experimental_rel
  • test_quiggeldy_service
  • update-arbor-0.10.0
  • image_build
  • spack_v0.22.1
  • ebrains-24-04
  • update-readme
  • create-module-file
  • add-nestml-tests
  • feat_add_py-norse
  • update-libneuroml
  • update-bluebrain-packages
  • feat_arbor_install_all_binaries
  • ebrains-23.09-jsc-site-config
  • spack-v0.20.0
  • ebrains-23-09-spack-v0.19.2
  • ebrains-23-09
21 results

package.py

Blame
  • create_JupyterLab_kernel.sh 2.44 KiB
    #!/bin/bash
    #title           :create_JupyterLab_kernel.sh
    #description     :Script to create a spackified JupyterLab kernel conf and place it to NFS where it can be loaded by all users.   
    #usage           :./create_JupyterLab_kernel.sh $INSTALLATION_ROOT $ENV $LAB_KERNEL_PATH
    #==============================================================================
    
    INSTALLATION_ROOT=$1
    SPACKIFIED_ENV=$2
    LAB_KERNEL_PATH=$3
    
    # capture the empty env
    cd /opt/app-root/src
    env >> before.txt
    
    # load spack, spack repos and spack env
    cp -r /srv/$INSTALLATION_ROOT/spack/.spack ~
    source /srv/$INSTALLATION_ROOT/spack/share/spack/setup-env.sh
    spack repo add /srv/$INSTALLATION_ROOT/ebrains-spack-builds
    # no need to activate as the env is already activated in the context it is used
    #spack env activate $SPACKIFIED_ENV
    
    module use /srv/$INSTALLATION_ROOT/spack/share/spack/modules/linux-centos7-broadwell/
    module use /srv/$INSTALLATION_ROOT/spack/share/spack/modules/linux-centos7-x86_64/
    source /srv/$INSTALLATION_ROOT/spack/var/spack/environments/$SPACKIFIED_ENV/loads
    # add also user's .local python3.8 packages to allow package installation at runtime
    # by the user using pip
    export PYTHONPATH=$PYTHONPATH:/opt/app-root/src/.local/lib/python3.8/site-packages
    export PATH=$PATH:/opt/app-root/src/.local/bin
    
    # capture the env after spack activation
    cd /opt/app-root/src
    env >> after.txt
    
    # prepare the env file required for the JupyterLab kernel
    mkdir $LAB_KERNEL_PATH/bin
    cat <<EOF > $LAB_KERNEL_PATH/bin/env.sh
    #!/usr/bin/env bash
    set -euxo pipefail
    EOF
    
    # load here all tools
    #spack load --sh -r python@3.8.11 py-ipykernel py-pip py-numpy@1.21.0 py-scipy py-pandas py-seaborn py-matplotlib arbor nest@3.0 neuron py-pynn tvb-data tvb-library meta-brainscales %gcc@10.3.0 >> $LAB_KERNEL_PATH/bin/env.sh
    
    # append the necessary env variables for spack env and tools
    cd /opt/app-root/src
    diff before.txt after.txt|grep ">"|cut -c 3- |awk '$0="export "$0' >> $LAB_KERNEL_PATH/bin/env.sh
    
    # end of env creation
    cat <<EOF >>$LAB_KERNEL_PATH/bin/env.sh
    python -m ipykernel_launcher -f \$@
    EOF
    chmod +x $LAB_KERNEL_PATH/bin/env.sh
    # create the new kernel's configuration file
    mkdir $LAB_KERNEL_PATH/spack_python_kernel_release_202112
    cat <<EOF >$LAB_KERNEL_PATH/spack_python_kernel_release_202112/kernel.json
    {
     "argv": ["$LAB_KERNEL_PATH/bin/env.sh", "{connection_file}", "--profile=default"],
     "display_name": "EBRAINS_release_v0.2_202112",
     "name": "spack_python_kernel_release_202112",
     "language": "python"
    }
    EOF