From 4cecda39f36a8aae8a77bcb0e1fd9afc59364187 Mon Sep 17 00:00:00 2001
From: Adrian Schmitz <adrian.schmitz@rwth-aachen.de>
Date: Thu, 5 Oct 2023 09:26:23 +0200
Subject: [PATCH] Bug fixes

---
 .gitlab-ci.yml                          | 2 +-
 core/job.py                             | 7 +++----
 core/modes/slurm/batch.py               | 6 ++++--
 core/modes/slurm/singularity.py         | 2 +-
 core/utility/defines.py                 | 2 +-
 core/utility/executor.py                | 2 +-
 utility/runtime/scripts/batchWrapper.sh | 4 +++-
 utility/runtime/scripts/chmodPath.sh    | 2 +-
 8 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2df517d..223bbf4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -26,7 +26,7 @@ variables:
 
 .local-template:
   variables:
-    RUNNER_TAG: "ja664344-dev"
+    RUNNER_TAG: "custom2"
 
 .run-template:
   stage: run
diff --git a/core/job.py b/core/job.py
index 9f784bf..4f9aa0a 100644
--- a/core/job.py
+++ b/core/job.py
@@ -90,11 +90,11 @@ class Job:
         self.rt_utility_path = rep(settings["Runtime Utility Path"])
         self.scripts_path = f'{self.rt_utility_path}/scripts'
         if self.down_scoping:
-            try:
+            if (get_cenv('HPC_CI_TOKEN') != None):
                 uid, pid = jwt.get_UID_PID_ID_TOKEN(get_cenv('HPC_CI_TOKEN'),
                                       f"{get_cenv('CI_SERVER_URL')}/-/jwks")
-            except:
-                logging.warn("id token HPC_CI_TOKEN, with aud: aixCIlence not defined.")
+            else:
+                print("WARNING:id token HPC_CI_TOKEN, with aud: aixCIlence not defined.", file=sys.stderr)
                 try:
                     uid, pid = jwt.get_UID_PID_CI_JOB_JWT(get_cenv('CI_JOB_JWT'),
                                        f"{get_cenv('CI_SERVER_URL')}/-/jwks")
@@ -112,7 +112,6 @@ class Job:
         else:
             self.user_path = rep(settings['User Path'])
 
-
     def __setup(self):
         self.__get_config()
         if not self.down_scoping:
diff --git a/core/modes/slurm/batch.py b/core/modes/slurm/batch.py
index df3d64a..2c21dae 100644
--- a/core/modes/slurm/batch.py
+++ b/core/modes/slurm/batch.py
@@ -74,7 +74,8 @@ class Sbatch(Slurm, ABC):
         tmp = os.getenv("TMP")
         with open(f'{self.job.scripts_path}/batchWrapper.sh', 'r') as file:
             filedata = file.read()
-        filedata = filedata.replace('replaceme', f'{self.job.clone_path}/{get_cenv("BATCH_SCRIPT")}')
+        filedata = filedata.replace('replacesource', f'{self.job.shell_config}')
+        filedata = filedata.replace('replacescript', f'{self.job.clone_path}/{get_cenv("BATCH_SCRIPT")}')
         with open(f'{tmp}/wrapper{self.job.jobid}', 'w') as file:
             file.write(filedata)
         return f'{tmp}/wrapper{self.job.jobid}'
@@ -126,7 +127,8 @@ class Default(Sbatch, ABC):
         tmp = os.getenv("TMP")
         with open(f'{self.job.scripts_path}/batchWrapper.sh', 'r') as file:
             filedata = file.read()
-        filedata = filedata.replace('replaceme', f'{self.job.clone_path}/script.')
+        filedata = filedata.replace('replacescript', f'{self.job.clone_path}/script.')
+        filedata = filedata.replace('replacesource', f'{self.job.shell_config}')
         with open(f'{tmp}/wrapper{self.job.jobid}', 'w') as file:
             file.write(filedata)
         return f'{tmp}/wrapper{self.job.jobid}'
diff --git a/core/modes/slurm/singularity.py b/core/modes/slurm/singularity.py
index 5d20c20..cba750e 100644
--- a/core/modes/slurm/singularity.py
+++ b/core/modes/slurm/singularity.py
@@ -81,7 +81,7 @@ class Singularity_Batch(Default, ABC):
         tmp = os.getenv("TMP")
         with open(f'{self.job.runner_path}/utility/runtime/scripts/batchWrapper.sh', 'r') as file:
             filedata = file.read()
-        filedata = filedata.replace('replaceme',
+        filedata = filedata.replace('replacescript',
                                     f'{self.job.clone_path}/singularity{self.job.jobid}.sh < '
                                     f'{self.job.clone_path}/script{self.job.jobid}.sh')
         with open(f'{tmp}/wrapper{self.job.jobid}', 'w') as file:
diff --git a/core/utility/defines.py b/core/utility/defines.py
index f916efe..2a17164 100644
--- a/core/utility/defines.py
+++ b/core/utility/defines.py
@@ -1,6 +1,6 @@
 import logging
 name = 'AixCIlenz CI Driver'
-version = '0.5.2'
+version = '0.5.3'
 
 debug = False
 stdout_logging = False
diff --git a/core/utility/executor.py b/core/utility/executor.py
index 370ec84..3657950 100644
--- a/core/utility/executor.py
+++ b/core/utility/executor.py
@@ -163,7 +163,7 @@ class Slurm_Executor(Executor, ABC):
                                       allocator=self.get_srun_cmd(),
                                       params=f'--jobid={self.simple_job_id} {self.get_default_params()} {params}',
                                       wrapper_add=wrapper_add,
-                                      pre_exec_scripts=[self.job.shell_config],
+                                      #pre_exec_scripts=[self.job.shell_config],
                                       target_script=script, install_env=install_env,
                                       text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout
         logging.debug(management_out)
diff --git a/utility/runtime/scripts/batchWrapper.sh b/utility/runtime/scripts/batchWrapper.sh
index 735e714..e00fb88 100644
--- a/utility/runtime/scripts/batchWrapper.sh
+++ b/utility/runtime/scripts/batchWrapper.sh
@@ -1,3 +1,5 @@
 #!/usr/bin/zsh
 
-zsh -l replaceme
\ No newline at end of file
+source replacesource
+
+zsh -l replacescript
diff --git a/utility/runtime/scripts/chmodPath.sh b/utility/runtime/scripts/chmodPath.sh
index cb98165..d59bcac 100755
--- a/utility/runtime/scripts/chmodPath.sh
+++ b/utility/runtime/scripts/chmodPath.sh
@@ -2,7 +2,7 @@
 _path=$1
 set -e
 while test "$_path" != "/work"; do
-    chmod o+x "$_path"
+    chmod o+rx "$_path"
     _path=$(dirname "$_path")
 done
 
-- 
GitLab