Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:16

0001 #!/bin/sh
0002 
0003 #    Script will be able to do next things: 
0004 # -- run MILLE, PEDE or MILLEPEDE jobs 
0005 # -- check out for FAILs and resubmit it
0006 # -- send an email when MILLE, PEDE or MILLEPEDE jobs are ready
0007 # you can setup time delay in FAILs checking (-t)
0008 # plese setup mail adress to get INFO about jobs status
0009 
0010 help(){
0011 echo "*************************************************************************************"
0012                         echo " "
0013                         echo " Options:"
0014                         echo "-h, --help                show brief help"
0015                         echo "-n,                       specify N mille jobs, default is Njobs = 429"
0016                         echo "-m,                       run MILLE jobs only"
0017                         echo "-p,                       run PEDE  jobs only"
0018                         echo "-mp,                      run MILLEPEDE jobs"
0019                         echo "-email,                   specify you e-mail adress, or manually change it in the script"
0020                         echo "-t,                       specify time of script sleeping, Example : -t 10m, -t 20s"
0021                         echo ""
0022                         echo "  Run example: sh nextMPS.sh -n 429 -m -email uname@gmail.com -t 5m"
0023                         echo " "
0024 echo "*************************************************************************************"
0025                         exit 0
0026 }
0027 
0028 if [ "$#" == "0" ]; then
0029         echo "This script needs arguments. Please use in this way:"
0030         help
0031         exit 1
0032 fi
0033 
0034 Njobs=429
0035 echo "*************************************************************************************"
0036 
0037 while (("$#")); do
0038         case "$1" in
0039                 -h|--help)
0040                         help
0041                         exit 0
0042                         ;;
0043                 -n)
0044                         shift
0045                         if (("$#")); then
0046                                 Njobs=$1
0047                                 echo "You specified Njobs = $Njobs"
0048                         else
0049                                 echo "Number of jobs is not specified. Please use -h, --help"
0050                                 exit 1
0051                         fi
0052                         shift
0053                         ;;
0054                 -m)
0055                         if (("$#")); then
0056                                 echo "You will run MILLE jobs only"
0057                                 runstatus="m"
0058                                 #echo "Runstatus = $runstatus"
0059                         fi
0060                         shift
0061                         ;;
0062                 -p)
0063                         if (("$#")); then
0064                                 echo "You will run PEDE jobs only"
0065                                 runstatus="p"
0066                                 #echo "Runstatus = $runstatus"
0067                         fi
0068                         shift
0069                         ;;
0070                 -mp)
0071                         if (("$#")); then
0072                                 echo "You will run MILLEPEDE jobs"
0073                                 runstatus="mp"
0074                                 #echo "Runstatus = $runstatus"
0075                         fi
0076                         shift
0077                         ;;
0078                 -email)
0079                         shift
0080                         if (("$#")); then
0081                                 echo "Job status will be send to the email adress: $1"
0082                                 email="$1"
0083                                # echo "Email = $email"
0084                                 else 
0085                                 email="0"
0086                                 echo "You did not specified e-mail adress"
0087                         fi
0088                         shift
0089                         ;;
0090 
0091                 -t)
0092                         shift
0093                         if (("$#")); then
0094                                 TimeSleep=$1
0095                                 time_flag="spec"
0096                                 echo "You specified time script sleeping = $1"
0097                         else
0098                                 echo "TimeSleep is not specified. Please use -h, --help"
0099                                 exit 1
0100                         fi
0101                         shift
0102                         ;;
0103                                         
0104                 *)
0105                         break
0106                         ;;
0107         esac
0108 done
0109 
0110 echo "*************************************************************************************"
0111 if [ "$runstatus" = "m" ] || [ "$runstatus" = "mp" ]; then
0112         if [ ! -f nextMPS.log  ]; then
0113         echo "nextMPS.log will be created"
0114         else
0115         rm nextMPS.log  
0116         echo "Old nextMPS.log file removed"
0117         fi
0118 fi
0119 
0120 TESTJOBS(){
0121 # testing your Jobs for FAIL status and resubmitting
0122 
0123 while [ "$(mps_stat.py | grep OK | wc -l)" != "$Njobs" ]
0124 do      
0125         if [ "$time_flag" = "spec" ]; then
0126                 sleep $TimeSleep
0127                 else 
0128                 sleep 10m
0129         fi
0130 
0131         echo "Fetch DONE jobs"
0132         mps_fetch.py
0133 
0134         if [ $(mps_stat.py | grep FAIL | wc -l) -ne 0 ];
0135         then
0136                 Njfails=$(echo "$(mps_stat.py | grep FAIL | wc -l)")
0137                 echo "Njob fails = $Njfails"
0138                 echo "Retry failed jobs"
0139                 mps_retry.pl FAIL
0140                 mps_fire.py $Njfails
0141         else
0142                 NjOK=$(mps_stat.py | grep OK | wc -l)
0143                 echo " Checking jobs . Njobs OK = $NjOK"
0144 
0145         fi
0146 done
0147 }
0148 
0149 
0150 MILLERUN(){
0151 # Setup your folder for MILLEPEDE run. Job status after: PEND
0152         ./setup_align.pl 
0153 
0154 # Send your jobs for running. Job status after: RUN
0155         mps_fire.py $Njobs
0156 
0157 # testing your MILLE jobs for FAIL status and resubmitting
0158         TESTJOBS
0159 
0160 if [ "$email" != "0" ]; then
0161 (echo "Subject: MILLE jobs ready"; echo "Your MILLE jobs are ready. Njobs mille OK = $NjOK";) | sendmail $email
0162 else echo "You did not setup e-mail"
0163 fi
0164 
0165         }
0166 
0167 PEDERUN(){
0168         mps_fire.py -m
0169         Njobs=$[Njobs+1]
0170         TESTJOBS
0171 
0172 if [ "$email" != "0" ]; then
0173 (echo "Subject: PEDE jobs ready"; echo "Your PEDE jobs are ready. Njobs pede OK = 1";) | sendmail $email
0174 else echo "You did not setup e-mail"
0175 fi
0176 
0177         }
0178 
0179 MILLEPEDERUN()  {
0180         MILLERUN
0181         PEDERUN
0182                 }
0183 
0184 # Run part:
0185                 if [ "$runstatus" = "m" ]; then
0186                 echo "MILLE jobs will be run"
0187                 MILLERUN >> nextMPS.log          
0188                 else
0189                         if [ "$runstatus" = "p" ]; then
0190                         echo "PEDE jobs will be run"
0191                         PEDERUN >> nextMPS.log
0192                         else 
0193                                 if [ "$runstatus" = "mp" ]; then
0194                                 echo "MILLEPEDE jobs will be run"
0195                                 MILLEPEDERUN >> nextMPS.log
0196                                 fi
0197                         fi
0198 
0199                 fi      
0200 # END SCRIPT
0201 echo "THE END"
0202