From f43c3537248fb04da62dd6fc820a71536abd34c5 Mon Sep 17 00:00:00 2001
From: Eleni Mathioulaki <emathioulaki@athenarc.gr>
Date: Tue, 17 Oct 2023 12:50:52 +0300
Subject: [PATCH] create jupyter kernel for each env

---
 .gitlab-ci.yml              | 3 +++
 create_JupyterLab_kernel.sh | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ffd59f6a..d3e6509d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -207,6 +207,9 @@ sync-gitlab-spack-instance:
     - rm -rf $SPACK_REPO_PATH && cp -r $CI_PROJECT_DIR $SPACK_REPO_PATH
     # run installation script
     - . install_spack_env.sh $SPACK_PATH_GITLAB $SPACK_VERSION $SPACK_REPO_PATH $SPACK_NFS_ENV
+    # create kernel spec, so that the environment can be used in gitlab CI jobs
+    - RELEASE_NAME=$(case $CI_COMMIT_BRANCH in experimental_rel) echo ebrains-experimental;; ebrains*) echo ${CI_COMMIT_BRANCH:0:10}.${CI_COMMIT_BRANCH:11};; *) echo $CI_COMMIT_BRANCH;; esac);
+    - . create_JupyterLab_kernel.sh $SPACK_PATH_GITLAB $SPACK_NFS_ENV $RELEASE_NAME /mnt/ebrains_env
   after_script:
     - mkdir -p $CI_PROJECT_DIR/spack_logs/installed $CI_PROJECT_DIR/spack_logs/not_installed
       # for succesfully installed packages: keep the spack logs for any package modified during this CI job
diff --git a/create_JupyterLab_kernel.sh b/create_JupyterLab_kernel.sh
index a503ff0d..0843a8ac 100644
--- a/create_JupyterLab_kernel.sh
+++ b/create_JupyterLab_kernel.sh
@@ -28,6 +28,8 @@ EOF
 
 # (2) append the necessary env variables for spack env and tools
 cat $INSTALLATION_ROOT/spack/var/spack/environments/$EBRAINS_SPACK_ENV/load_env.sh >> $KERNEL_PATH/bin/env.sh
+# also copy the script so that it can be used independently:
+cp $INSTALLATION_ROOT/spack/var/spack/environments/$EBRAINS_SPACK_ENV/load_env.sh $KERNEL_PATH/bin/
 
 # (3) also add the user's .local locations to allow package installation at runtime,
 # and the location of python modules installed in the base docker Collab image
-- 
GitLab