Commit a404edab authored by Pape, David (FWCC) - 139658's avatar Pape, David (FWCC) - 139658
Browse files

Add concurrency, use for loop to write settings to sript

parent 1eea22ca
#!/usr/bin/env bash
CUSTOM_ENV_PATH="$CUSTOM_ENV_CI_RUNNER_ID-$CUSTOM_ENV_CI_PROJECT_ID-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID-$CUSTOM_ENV_CI_JOB_ID"
cat << EOS
{
"builds_dir": "/home/pape58/runner-wd/builds/$CUSTOM_ENV_PATH",
"cache_dir": "/home/pape58/runner-wd/cache/$CUSTOM_ENV_PATH",
"builds_dir_is_shared": true
}
EOS
#!/usr/bin/env bash
set -e
set -eo pipefail
module load git
SLURM_OPTIONS=(cpus-per-task nodes ntasks ntasks-per-node)
function getSlurmVar {
local option
option=$(echo "${2^^}" | tr - _)
{
sed -e 's/\\n/\n/g' "$1" | grep "export CI_SLURM_$option=" | cut -d "=" -f 2
} || {
# TODO: return sensible default values?
#case "$option" in
# "CPUS_PER_TASK") echo "4";;
# "NODES") echo "1";;
# "NTASKS") echo "4");;
# "NTASKS-PER-NODE") echo "";;
# *) echo ""
#esac
echo ""
}
}
#
# ./this_script [my_args...] script stage_name
......@@ -10,14 +30,16 @@ module load git
# This has to be run!
#
script=${@: -2:1}
runStage=${@: -1:1}
# this is needed since the runner's working directory is /tmp which is not shared between nodes
module load git
script=${*: -2:1}
runStage=${*: -1:1}
# This is needed since the runner's working directory is /tmp which is not shared between nodes.
workDir="/home/pape58/runner-wd"
module load git
1>&2 echo "Run stage: $runStage"
#1>&2 echo "Run stage: $runStage"
if [[ "$runStage" == "build_script" ]]; then
# This will be the name of the batch script that is constructed from the script passed to this
......@@ -27,16 +49,24 @@ if [[ "$runStage" == "build_script" ]]; then
{
# write shebang and SBATCH options to new script
echo "#!/usr/bin/env bash";
echo "#SBATCH -o $workDir/slurm-%j.out";
echo "#SBATCH -e $workDir/slurm-%j.err";
echo "#SBATCH -n 4";
echo "";
echo "#SBATCH --output=$workDir/slurm-%j.out";
echo "#SBATCH --error=$workDir/slurm-%j.err";
# iterate over SLURM options and get the desired setting
# only write to new script if variable not empty
for option in "${SLURM_OPTIONS[@]}"; do
slurmVar=$(getSlurmVar "$script" "$option")
if [[ -n "$slurmVar" ]]; then
echo "#SBATCH --$option=$slurmVar"
fi
unset -v slurmVar
done
# write settings to new script
# TODO: Better read out these settings than assume they'll always stay like this
echo "set -eo pipefail";
echo "set +o noclobber";
echo "";
echo "set -eo pipefail"
echo "set +o noclobber"
echo ""
# add the rest of the old script
tail -n +5 "$script";
......@@ -50,8 +80,7 @@ if [[ "$runStage" == "build_script" ]]; then
jobID=$(sbatch "$script" | awk '{ print $4 }')
# wait for job to finish
# don't use -o pipefail or this might crash
until [[ $(squeue -j "$jobID" | wc -l) -le "1" ]]; do sleep 5; done
until [[ $(squeue -j "$jobID" | wc -l) -le "1" ]]; do sleep 2; done
outFile="$workDir/slurm-$jobID.out"
errFile="$workDir/slurm-$jobID.err"
......@@ -73,3 +102,4 @@ else
fi
exit 0
concurrent = 1
concurrent = 10
check_interval = 0
[session_server]
session_timeout = 1800
session_timeout = 1800
[[runners]]
name = "Test runner for cluster integration"
url = "https://gitlab.hzdr.de/"
token = "eQT7ugr9aK-g6TTJGxdB"
executor = "custom"
builds_dir = "/home/pape58/builds"
cache_dir = "/home/pape58/cache"
shell = "bash"
[runners.custom]
run_exec = "run.sh"
graceful_kill_timeout = 200
force_kill_timeout = 200
name = "Test runner for cluster integration"
url = "https://gitlab.hzdr.de/"
token = "eQT7ugr9aK-g6TTJGxdB"
executor = "custom"
builds_dir = "/home/pape58/runner-wd/builds"
cache_dir = "/home/pape58/runner-wd/cache"
builds_dir_is_shared = "true"
shell = "bash"
[runners.custom]
config_exec = "config.sh"
run_exec = "run.sh"
run_args = [ "$TEST" ]
graceful_kill_timeout = 200
force_kill_timeout = 200
......@@ -13,5 +13,6 @@ ln -s "$REPO_DIR/runner-config.toml" "config.toml"
mkdir -p "$LOCAL_BIN_DIR"
cd "$LOCAL_BIN_DIR"
ln -s "$REPO_DIR/run.sh" "run.sh"
ln -s "$REPO_DIR/config.sh" "config.sh"
exit 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment