From 7ce8bc77c51c1b33deb0d3e580efeb6fcaa18482 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 693324c0..e4fab984 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -283,6 +283,9 @@ sync-gitlab-spack-instance:
     - spack env activate $SPACK_NFS_ENV
     - spack install -y -j2 --fresh --test root
     - spack reindex
+    # 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 spack_logs
     - |
diff --git a/create_JupyterLab_kernel.sh b/create_JupyterLab_kernel.sh
index 4961eaa4..1b50b11b 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