From ffe4ca13e6521cdd810785a0e2135f01d4c265ff Mon Sep 17 00:00:00 2001 From: Felix Tomski <tomski@itc.rwth-aachen.de> Date: Thu, 26 Jan 2023 12:14:50 +0100 Subject: [PATCH] Fix direct write to service account directories --- core/modes/__init__.py | 15 +++++++++++++-- core/scripts/batch.env | 1 + core/scripts/chmodPath.sh | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 core/scripts/batch.env diff --git a/core/modes/__init__.py b/core/modes/__init__.py index 062d7c0..5e1c160 100644 --- a/core/modes/__init__.py +++ b/core/modes/__init__.py @@ -404,14 +404,25 @@ class Batch(Slurm): class Singularity_Batch(Default): container = '' + @staticmethod + def escape(s): + return s.replace('/', '\/') + def custom_run_setup(self, **kwargs): Sbatch.custom_run_setup(self, **kwargs) if kwargs["script_execution"] and kwargs["do_inbetween_processing"]: logging.debug('Creating param file') # write env_file - with open(f'{self.slurm_output_dir}/env{self.job.jobid}', 'w') as file: + with open(f'{self.job.tmp_dir}/env{self.job.jobid}', 'w') as file: file.write(f"CONTAINER={self.container}\0EXEC_WRAPPER={srun_path}\0PARAMS={self.job.get_parameters()}\0OUTPUT_FILE=--output={self.slurm_output_file}") + + self.job.execute(f'/usr/bin/cp /dev/stdin ' + f'{self.slurm_output_dir}/batchEnv{self.job.jobid}', + f"{self.job.tmp_dir}/env{self.job.jobid}", + f"{self.job.driver_path}/core/scripts/pipeHelper.sh", + skip_env=True, srun_wrap=True) + def get_combiner_script(self): self._combiner_script = f"{self.job.driver_path}/core/scripts/pipeHelper.sh" return self._combiner_script @@ -445,7 +456,7 @@ class Singularity_Batch(Default): skip_env=True, srun_wrap=True) # add singularity specific parameter to the properties property_split = self._run_properties.split(" ") - property_split.insert(1, f'--export-file={self.slurm_output_dir}/env{self.job.jobid}') + property_split.insert(1, f'--export-file={self.slurm_output_dir}/batchEnv{self.job.jobid}') self._run_properties = " ".join(property_split) return self._run_properties diff --git a/core/scripts/batch.env b/core/scripts/batch.env new file mode 100644 index 0000000..33cedb8 --- /dev/null +++ b/core/scripts/batch.env @@ -0,0 +1 @@ +CONTAINER=_CONTAINER\0EXEC_WRAPPER=_EXEC_WRAPPER\0PARAMS=_PARAMS\0OUTPUT_FILE=_OUTPUT_FILE diff --git a/core/scripts/chmodPath.sh b/core/scripts/chmodPath.sh index 18893a4..cb98165 100755 --- a/core/scripts/chmodPath.sh +++ b/core/scripts/chmodPath.sh @@ -2,7 +2,7 @@ _path=$1 set -e while test "$_path" != "/work"; do - chmod o+wx "$_path" + chmod o+x "$_path" _path=$(dirname "$_path") done -- GitLab