Skip to content
Snippets Groups Projects
Select Git revision
  • 08356a32addf987bf05aa78960749304df510d18
  • main default protected
  • sprint-1/75-issue
  • feat/histograms
  • feat/exareme2-viz-integrations
  • docs
  • fix/datashield-token-issue
  • feat/logistic-reg-cv
  • feat/datashield-integration
  • feat/datashield-algorithms
  • feat/remove-matomo-config
  • feat/auth-refresh-token
  • feat/integration-logistic-regression
  • feat/exareme2-integration
  • feat/exareme2-t-test-paired-integration
  • feat/linear-regression-cv
  • fix/cache-reset-logout
  • feat/datashield-connector
  • feat/connector-cache
  • feat/datashield-cohorts-filter
  • feat/logger-levels
  • 1.4.1
  • 1.4.0
  • 1.4.0-rc.7
  • 1.4.0-rc.6
  • 1.4.0-beta.10
  • 1.4.0-beta.9
  • 1.4.0-beta.8
  • 1.4.0-rc.5
  • 1.4.0-rc.4
  • 1.4.0-beta.7
  • 1.4.0-beta.6
  • 1.4.0-rc.3
  • 1.4.0-rc.2
  • 1.4.0-rc.1
  • 1.4.0-beta.5
  • 1.4.0-beta.4
  • 1.4.0-beta.3
  • 1.4.0-beta.2
  • 1.4.0-beta.1
  • 1.3.1
41 results

app.module.ts

Blame
  • create_JupyterLab_kernel.sh 2.68 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 $RELEASE_NAME $LAB_KERNEL_PATH
    #==============================================================================
    
    INSTALLATION_ROOT=$1
    SPACKIFIED_ENV=$2
    RELEASE_NAME=$3
    LAB_KERNEL_PATH=$4
    
    # capture the empty env
    cd ~
    env >> /tmp/before.txt
    
    # load spack, spack repos and spack env
    export SPACK_USER_CACHE_PATH=/srv/$INSTALLATION_ROOT/spack/.spack
    export SPACK_USER_CONFIG_PATH=/srv/$INSTALLATION_ROOT/spack/.spack
    source /srv/$INSTALLATION_ROOT/spack/share/spack/setup-env.sh
    # this shouldn't be needed:
    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
    
    source /usr/share/modules/init/sh
    module use /srv/$INSTALLATION_ROOT/spack/share/spack/modules/linux-ubuntu20.04-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
    # export also python modules installed in the base docker Collab image
    export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.8/dist-packages
    
    # capture the env after spack activation
    cd ~
    env >> /tmp/after.txt
    
    # kernel name is lowercase release name
    LAB_KERNEL_NAME=$(echo "$RELEASE_NAME" | tr '[:upper:]' '[:lower:]')
    # kernel dir is a directory inside LAB_KERNEL_PATH named after the kernel
    LAB_KERNEL_DIR=$LAB_KERNEL_PATH/$LAB_KERNEL_NAME
    
    # prepare the env file required for the JupyterLab kernel
    mkdir -p $LAB_KERNEL_DIR/bin
    
    # start of env creation
    cat <<EOF > $LAB_KERNEL_DIR/bin/env.sh
    #!/usr/bin/env bash
    set -euxo pipefail
    EOF
    
    # append the necessary env variables for spack env and tools
    diff /tmp/before.txt /tmp/after.txt|grep ">"|cut -c 3- |awk '$0="export "$0' >> $LAB_KERNEL_DIR/bin/env.sh
    
    # end of env creation
    cat <<EOF >>$LAB_KERNEL_DIR/bin/env.sh
    python -m ipykernel_launcher -f \$@
    EOF
    chmod +x $LAB_KERNEL_DIR/bin/env.sh
    
    # create the new kernel's configuration file
    mkdir -p $LAB_KERNEL_DIR/$LAB_KERNEL_NAME
    cat <<EOF >$LAB_KERNEL_DIR/$LAB_KERNEL_NAME/kernel.json
    {
     "argv": ["$LAB_KERNEL_DIR/bin/env.sh", "{connection_file}", "--profile=default"],
     "display_name": "RELEASE_NAME",
     "name": "$LAB_KERNEL_NAME",
     "language": "python",
     "env": { "LAB_KERNEL_NAME": "$RELEASE_NAME", "LAB_KERNEL_RELEASE_DATE": "$(date +"%Y-%m-%d")" }
    }
    EOF