Skip to content

Commit 999cc8a

Browse files
authored
Merge pull request #261 from laraPPr/Fix_copy_logs
Fix and move copy_build_log function
2 parents 64697e3 + ac2ee4d commit 999cc8a

2 files changed

Lines changed: 31 additions & 31 deletions

File tree

EESSI-install-software.sh

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,6 @@ display_help() {
1717
echo " --skip-cuda-install - disable installing a full CUDA SDK in the host_injections prefix (e.g. in CI)"
1818
}
1919

20-
function copy_build_log() {
21-
# copy specified build log to specified directory, with some context added
22-
build_log=${1}
23-
build_logs_dir=${2}
24-
25-
# also copy to build logs directory, if specified
26-
if [ ! -z "${build_logs_dir}" ]; then
27-
log_filename="$(basename ${build_log})"
28-
if [ ! -z "${SLURM_JOB_ID}" ]; then
29-
# use subdirectory for build log in context of a Slurm job
30-
build_log_path="${build_logs_dir}/jobs/${SLURM_JOB_ID}/${log_filename}"
31-
else
32-
build_log_path="${build_logs_dir}/non-jobs/${log_filename}"
33-
fi
34-
mkdir -p $(dirname ${build_log_path})
35-
cp -a ${build_log} ${build_log_path}
36-
chmod 0644 ${build_log_path}
37-
38-
# add context to end of copied log file
39-
echo >> ${build_log_path}
40-
echo "Context from which build log was copied:" >> ${build_log_path}
41-
echo "- original path of build log: ${build_log}" >> ${build_log_path}
42-
echo "- working directory: ${PWD}" >> ${build_log_path}
43-
echo "- Slurm job ID: ${SLURM_OUT}" >> ${build_log_path}
44-
echo "- EasyBuild version: ${eb_version}" >> ${build_log_path}
45-
echo "- easystack file: ${easystack_file}" >> ${build_log_path}
46-
47-
echo "EasyBuild log file ${build_log} copied to ${build_log_path} (with context appended)"
48-
fi
49-
}
50-
5120
function safe_module_use {
5221
# add a given non-empty directory to $MODULEPATH if and only if it is not yet in
5322
directory=${1}

scripts/utils.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,34 @@ function nvidia_gpu_has_compute_capability {
197197
fi
198198
fi
199199
}
200+
201+
function copy_build_log() {
202+
# copy specified build log to specified directory, with some context added
203+
build_log=${1}
204+
build_logs_dir=${2}
205+
206+
# also copy to build logs directory, if specified
207+
if [ ! -z "${build_logs_dir}" ]; then
208+
log_filename="$(basename ${build_log})"
209+
if [ ! -z "${SLURM_JOB_ID}" ]; then
210+
# use subdirectory for build log in context of a Slurm job
211+
build_log_path="${build_logs_dir}/jobs/${SLURM_JOB_ID}/${log_filename}"
212+
else
213+
build_log_path="${build_logs_dir}/non-jobs/${log_filename}"
214+
fi
215+
mkdir -p $(dirname ${build_log_path})
216+
cp -a ${build_log} ${build_log_path}
217+
chmod 0644 ${build_log_path}
218+
219+
# add context to end of copied log file
220+
echo >> ${build_log_path}
221+
echo "Context from which build log was copied:" >> ${build_log_path}
222+
echo "- original path of build log: ${build_log}" >> ${build_log_path}
223+
echo "- working directory: ${PWD}" >> ${build_log_path}
224+
echo "- Slurm job ID: ${SLURM_JOB_ID}" >> ${build_log_path}
225+
echo "- EasyBuild version: ${eb_version}" >> ${build_log_path}
226+
echo "- easystack file: ${easystack_file}" >> ${build_log_path}
227+
228+
echo "EasyBuild log file ${build_log} copied to ${build_log_path} (with context appended)"
229+
fi
230+
}

0 commit comments

Comments
 (0)