-
Notifications
You must be signed in to change notification settings - Fork 0
/
job_template_common.txt
executable file
·61 lines (55 loc) · 2.73 KB
/
job_template_common.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#SBATCH --mail-user=${job_email}
#SBATCH --mail-type=${job_email_options}
#SBATCH --nodes=1
#SBATCH --ntasks=${job_ppn}
#SBATCH --time=${job_walltime}
#SBATCH --mem=${job_memory}mb
#SBATCH -o ${job_output_file}
smemwatch -k 90 -d 50 $$$$ &
# List info
uname -a
# Make sure tmp directory is made
mkdir -p $TMPDIR
XNATHOST=${XNAT_HOST}
XNATUSER=${XNAT_USER}
SESSLIMIT=40
SLEEPMAX=300
SLEEPSHORT=120
# Check number of open sessions on host before we download
echo "Checking that we can download"
SLEEPSECS=$[ ( $RANDOM % $SLEEPSHORT ) ]s && echo "$SLEEPSECS" && sleep $SLEEPSECS
while true;do
SESSID=`curl -s -n "$XNATHOST/data/JSESSION"`
#echo "JSESSIONID=$SESSID"
SESSCOUNT=`curl -s -b "JSESSIONID=$SESSID" "$XNATHOST/data/user/$XNATUSER/sessions" | cut -s -f2 -d ":" | cut -f1 -d "}"`
echo "$SESSCOUNT"
echo "$SESSLIMIT"
if (( "$SESSCOUNT" > "$SESSLIMIT" )); then
echo -n "Cannot download yet, too many open sessions, sleeping "
curl -s -b "JSESSIONID=$SESSID" -X DELETE "$XNATHOST/data/JSESSION"
SLEEPSECS=$[ ( $RANDOM % $SLEEPMAX ) ]s && echo "$SLEEPSECS" && sleep $SLEEPSECS
else
echo "Looks good, ready to download"
curl -s -b "JSESSIONID=$SESSID" -X DELETE "$XNATHOST/data/JSESSION"
break
fi
done
#echo "DONE! JSESSIONID=$SESSID"
# Run mega docker
singularity exec --cleanenv --contain --bind /home/$USER/.dax_settings.ini:/home/$USER/.dax_settings.ini --bind /home/$USER/.daxnetrc:/home/$USER/.daxnetrc --bind /nobackup/$USER:/nobackup/$USER --bind /tmp:/tmp --bind /data/mcr/centos7/dax_local/ldax_credentials:/data/mcr/centos7/dax_local/ldax_credentials --bind /data/mcr/centos7/dax_local/bashrc_ldax_megadocker:${HOME}/.bashrc /data/mcr/singularity/mega_docker/vuiiscci_mega_docker_4.2.0-2020-07-13.img scl enable python27 'bash -c "
source ${HOME}/.bashrc && \
export PYTHONNOUSERSITE=TRUE && \
export OPENBLAS_NUM_THREADS=1 && \
export [email protected] && \
export PYTHONPATH=/data/mcr/masimatlab/trunk/xnatspiders/python/:/data/mcr/masimatlab/trunk/xnatspiders/SpiderUtils/ && \
export PATH=\"$PATH\":/usr/local/matlab/2013a/bin:/data/mcr/fsl5/bin/:/data/mcr/camino/bin/:/data/mcr/masimatlab/trunk/xnatspiders/python/justinlib_v1_1_0/xnatlib:/data/mcr/masimatlab/trunk/xnatspiders/python/justinlib_v1_1_0/pythonlib && \
export FSLDIR=/data/mcr/fsl5 && \
source /data/mcr/fsl5/etc/fslconf/fsl.sh && \
export CAMINO_HEAP_SIZE=30000 && \
export FREESURFER_HOME=/data/mcr/freesurfer && \
export FREESURFER_PBS_TEMPLATE=/data/mcr/masimatlab/trunk/xnatspiders/pbs_templates/FreesurferReconAllWithQC_PBS_template.txt && \
source /data/mcr/freesurfer/SetUpFreeSurfer.sh && \
xvfb-run -a --server-num=$((65536+$$$$)) --server-args=\"-screen 0 1920x1280x24 -ac\" \
${job_cmds}\
"'