Commit b6181c60 authored by Valentin Pelloin's avatar Valentin Pelloin
Browse files

commit avant refont slurm_add_command & cie

parent 59a96642
#!/usr/bin/env python3
import os
import re
if not 'SLURM_NODELIST' in os.environ:
raise EnvironmentError('Probably not in a SLURM job')
......@@ -10,7 +10,8 @@ base = os.environ['SLURM_NODELIST']
if '[' in base:
types, nums = base.split('[')
nums = nums.strip(']').split('-')
nums = re.split(',|-', nums.strip(']'))
# nums = nums.strip(']').split('-')
print(" ".join([types + n for n in nums]))
else:
print(base)
#!/usr/bin/env bash
if [ "$#" -ne "1" ]; then
echo "Usage: $0 <server name>"
exit 1
fi
server=$1
sinfo -o '%P %n' | grep $server | head -n1 | awk '{print $1;}' | sed -r "s/\*//"
#!/bin/sh
sh $SLURM_SUBMIT_DIR/.slurm_batch_script_job_$SLURM_ARRAY_TASK_ID.sh
bash $SLURM_SUBMIT_DIR/.slurm_batch_script_job_$SLURM_ARRAY_TASK_ID.sh
......@@ -12,6 +12,7 @@ job_name=
time="01-00"
max_parallel=10
ranks=""
repeat_worker=1
. /lium/buster1/vpelloin/.local/bin/parse_options.sh
......@@ -54,6 +55,16 @@ if [ "$#" -gt 1 ]; then
jobid=$(sbatch "${params[@]}" slurm_array_job_start)
echo " Done!"
elif [ "$repeat_worker" -gt 1 ]; then
params+=(--wait)
params+=(--parsable)
params+=(--array "1-$repeat_worker%$max_parallel")
echo "Starting $repeat_worker times the same worker on SLURM..."
jobid=$(sbatch "${params[@]}" .slurm_batch_script_job_1.sh)
echo " Done!"
elif [ "$#" == 1 ]; then
stdout=.stdout$1
params+=(--output $stdout)
......@@ -81,7 +92,7 @@ elif [ "$#" == 1 ]; then
tail --pid $(jobs -p) -f $stdout
else
echo "Not enough jobs given"
exit 1
exit 0
fi
if $cancel; then
......@@ -91,18 +102,19 @@ fi
i=1
for script in $@; do
rm .slurm_batch_script_job_$i.sh
rm -f .slurm_batch_script_job_$i.sh
if [ "$#" -gt 1 ]; then
echo -e "====\n$i\n===="
echo -e "====\n Job n°$i:"
output=slurm-${jobid}_${i}.out
if [ -f $output ]; then
cat $output
rm $output
fi
echo -e "\n"
else
rm $stdout
if ! [ -z $stdout ]; then
rm $stdout
fi
fi
i=$((i + 1))
done
......
#!/usr/bin/env bash
i=$(echo $(($(find . -name '.slurm_batch_script_job_*' | wc -l) + 1)))
output=".slurm_batch_script_job_$i.sh"
(
# Wait for lock on /var/lock/.slurm_prepare.exclusivelock (fd 200) for 30 seconds
flock -x -w 30 200 || exit 1
if [ -f "$output" ]; then
rm $output
fi
i=$(echo $(($(find . -name '.slurm_batch_script_job_*' | wc -l) + 1)))
output=".slurm_batch_script_job_$i.sh"
cat <(echo -e "#!/bin/bash \nset -e") > .slurm_batch_script_job_$i.sh
if [ -f "$output" ]; then
rm $output
fi
echo $output
cat <(echo -e "#!/bin/bash \nset -e") > .slurm_batch_script_job_$i.sh
for bash_import in $@; do
echo ". $bash_import" >> .slurm_batch_script_job_$i.sh
done
echo $output
) 200>/var/lock/.slurm_prepare.exclusivelock
Supports Markdown
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