Skip to content
Snippets Groups Projects
Select Git revision
  • 700f932d76cb806e01c75a9a36819674cad666e8
  • master default protected
  • cineca_ebrains/libvips_magick
  • cineca/wget_openssl_external
  • create-module-file
  • ebrains-24-04
  • add-nestml-tests
  • experimental_rel
  • 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
  • nestml-source-distribution
  • ebrains-23-06
  • ebrains-23-02
  • ebrains-22-10
  • ebrains-22-07
21 results

create_JupyterLab_kernel.sh

Blame
  • create_JupyterLab_kernel.sh 2.09 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/
    source /srv/$INSTALLATION_ROOT/spack/var/spack/environments/$SPACKIFIED_ENV/loads
    
    # 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- >> $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_20210930
    cat <<EOF >$LAB_KERNEL_PATH/spack_python_kernel_release_20210930/kernel.json
    {
     "argv": ["$LAB_KERNEL_PATH/bin/env.sh", "{connection_file}"],
     "display_name": "EBRAINS_release_20210930",
     "name": "spack_python_kernel_release_20210930",
     "language": "python"
    }
    EOF