-
Notifications
You must be signed in to change notification settings - Fork 15
/
submit-digireplay-jobs.sh
executable file
·87 lines (77 loc) · 2.89 KB
/
submit-digireplay-jobs.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# ------------------------------------------------------------------------- #
# This script submits jobs to replay digitized data to batch farm. #
# --------- #
# P. Datta <[email protected]> CREATED 11-09-2022 #
# ------------------------------------------------------------------------- #
# Setting necessary environments via setenv.sh
source setenv.sh
# List of arguments
inputfile=$1 # Digitized ROOT filebase w/o extention
indirpath=$2 # Directory containing ditized ROOT files
outdirpath=$indirpath #
sbsconfig=$3 # SBS configuration
nevents=$4
fjobid=$5 # first job id
njobs=$6 # total no. of jobs to submit
run_on_ifarm=$7
# workflow name
workflowname=
# Checking the environments
if [[ ! -d $SCRIPT_DIR ]]; then
echo -e '\nERROR!! Please set "SCRIPT_DIR" path properly in setenv.sh script!\n'; exit;
elif [[ (! -d $ANALYZER) && ($useJLABENV -eq 1) ]]; then
echo -e '\nERROR!! Please set "ANALYZER" path properly in setenv.sh script!\n'; exit;
elif [[ ! -d $SBSOFFLINE ]]; then
echo -e '\nERROR!! Please set "SBSOFFLINE" path properly in setenv.sh script!\n'; exit;
elif [[ ! -d $SBS_REPLAY ]]; then
echo -e '\nERROR!! Please set "SBS_REPLAY" path properly in setenv.sh script!\n'; exit;
fi
# Validating the number of arguments provided
if [[ "$#" -ne 7 ]]; then
echo -e "\n--!--\n Illegal number of arguments!!"
echo -e " This script expects 7 arguments: <g4sbsfilebase> <g4sbsfiledir> <sbsconfig> <nevents> <fjobid> <njobs> <run_on_ifarm>\n"
exit;
else
if [[ $run_on_ifarm -ne 1 ]]; then
echo -e '\n------'
echo -e ' Check the following variable(s):'
echo -e ' "workflowname" : '$workflowname''
while true; do
read -p "Do they look good? [y/n] " yn
echo -e ""
case $yn in
[Yy]*)
break; ;;
[Nn]*)
read -p "Enter desired workflowname : " temp1
workflowname=$temp1
break; ;;
esac
done
fi
fi
# Creating the workflow
if [[ $run_on_ifarm -ne 1 ]]; then
swif2 create $workflowname
else
echo -e "\nRunning all jobs on ifarm!\n"
fi
# looping over jobs
for ((i=$fjobid; i<$((fjobid+njobs)); i++))
do
digireplayinfile=$inputfile'_job_'$i
digireplayjobname=$inputfile'_digi_replay_job_'$i
digireplayscript=$SCRIPT_DIR'/run-digi-replay.sh'' '$digireplayinfile' '$sbsconfig' '$nevents' '$outdirpath' '$run_on_ifarm' '$ANALYZER' '$SBSOFFLINE' '$SBS_REPLAY' '$ANAVER' '$useJLABENV' '$JLABENV
if [[ $run_on_ifarm -ne 1 ]]; then
swif2 add-job -workflow $workflowname -partition production -name $digireplayjobname -cores 1 -disk 5GB -ram 1500MB $digireplayscript
else
$digireplayscript
fi
done
# run the workflow and then print status
if [[ $run_on_ifarm -ne 1 ]]; then
swif2 run $workflowname
echo -e "\n Getting workflow status.. [may take a few minutes!] \n"
swif2 status $workflowname
fi