CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
heppy_batch Namespace Reference

Classes

class  MyBatchManager
 

Functions

def batchScriptCERN
 
def batchScriptIC
 
def batchScriptLocal
 
def batchScriptPADOVA
 
def batchScriptPISA
 
def batchScriptPSI
 

Variables

tuple batchManager = MyBatchManager()
 
list cfgFileName = args[0]
 
tuple cfo = imp.load_source("pycfg", cfgFileName, handle)
 
tuple components = split( [comp for comp in config.components if len(comp.files)>0] )
 
 config = cfo.config
 
tuple handle = open(cfgFileName, 'r')
 
list listOfNames = [comp.name for comp in components]
 
tuple listOfValues = range(0, len(components))
 
float waitingTime = 0.1
 

Function Documentation

def heppy_batch.batchScriptCERN (   jobDir,
  remoteDir = '' 
)
prepare the LSF version of the batch script, to run on LSF

Definition at line 75 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

75 
76 def batchScriptCERN( jobDir, remoteDir=''):
77  '''prepare the LSF version of the batch script, to run on LSF'''
78 
79  dirCopy = """echo 'sending the logs back' # will send also root files if copy failed
80 cp -r Loop/* $LS_SUBCWD
81 if [ $? -ne 0 ]; then
82  echo 'ERROR: problem copying job directory back'
83 else
84  echo 'job directory copy succeeded'
85 fi"""
86  if remoteDir=='':
87  cpCmd=dirCopy
88  elif remoteDir.startswith("/pnfs/psi.ch"):
89  cpCmd="""echo 'sending root files to remote dir'
90 export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH # Fabio's workaround to fix gfal-tools with CMSSW
91 for f in Loop/mt2*.root
92 do
93  ff=`basename $f | cut -d . -f 1`
94  #d=`echo $f | cut -d / -f 2`
95  gfal-mkdir {srm}
96  echo "gfal-copy file://`pwd`/Loop/$ff.root {srm}/${{ff}}_{idx}.root"
97  gfal-copy file://`pwd`/Loop/$ff.root {srm}/${{ff}}_{idx}.root
98  if [ $? -ne 0 ]; then
99  echo "ERROR: remote copy failed for file $ff"
100  else
101  echo "remote copy succeeded"
102  rm Loop/$ff.root
103  fi
104 done
105 #fi
106 """.format(idx=jobDir[jobDir.find("_Chunk")+6:].strip("/"), srm='srm://t3se01.psi.ch'+remoteDir+jobDir[jobDir.rfind("/"):jobDir.find("_Chunk")]) + dirCopy
107  else:
108  print "chosen location not supported yet: ", remoteDir
109  print 'path must start with "/pnfs/psi.ch"'
110  sys.exit(1)
111 
112  script = """#!/bin/bash
113 #BSUB -q 8nm
114 echo 'environment:'
115 echo
116 env | sort
117 # ulimit -v 3000000 # NO
118 echo 'copying job dir to worker'
119 cd $CMSSW_BASE/src
120 eval `scramv1 ru -sh`
121 # cd $LS_SUBCWD
122 # eval `scramv1 ru -sh`
123 cd -
124 cp -rf $LS_SUBCWD .
125 ls
126 cd `find . -type d | grep /`
127 echo 'running'
128 python $CMSSW_BASE/src/PhysicsTools/HeppyCore/python/framework/looper.py pycfg.py config.pck
129 echo
130 {copy}
131 """.format(copy=cpCmd)
132 
133  return script
134 
def batchScriptCERN
Definition: heppy_batch.py:75
def heppy_batch.batchScriptIC (   jobDir)
prepare a IC version of the batch script

Definition at line 226 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

227 def batchScriptIC(jobDir):
228  '''prepare a IC version of the batch script'''
229 
230 
231  cmssw_release = os.environ['CMSSW_BASE']
232  script = """#!/bin/bash
233 export X509_USER_PROXY=/home/hep/$USER/myproxy
234 source /vols/cms/grid/setup.sh
235 cd {jobdir}
236 cd {cmssw}/src
237 eval `scramv1 ru -sh`
238 cd -
239 echo 'running'
240 python {cmssw}/src/PhysicsTools/HeppyCore/python/framework/looper.py pycfg.py config.pck
241 echo
242 echo 'sending the job directory back'
243 mv Loop/* ./ && rm -r Loop
244 """.format(jobdir = jobDir,cmssw = cmssw_release)
245  return script
def batchScriptIC
Definition: heppy_batch.py:226
def heppy_batch.batchScriptLocal (   remoteDir,
  index 
)
prepare a local version of the batch script, to run using nohup

Definition at line 246 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

247 def batchScriptLocal( remoteDir, index ):
248  '''prepare a local version of the batch script, to run using nohup'''
249 
250  script = """#!/bin/bash
251 echo 'running'
252 python $CMSSW_BASE/src/PhysicsTools/HeppyCore/python/framework/looper.py pycfg.py config.pck echo
253 echo 'sending the job directory back'
254 mv Loop/* ./
255 """
256  return script
257 
def batchScriptLocal
Definition: heppy_batch.py:246
def heppy_batch.batchScriptPADOVA (   index,
  jobDir = './' 
)
prepare the LSF version of the batch script, to run on LSF

Definition at line 14 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

14 
15 def batchScriptPADOVA( index, jobDir='./'):
16  '''prepare the LSF version of the batch script, to run on LSF'''
17  script = """#!/bin/bash
18 #BSUB -q local
19 #BSUB -J test
20 #BSUB -o test.log
21 cd {jdir}
22 echo 'PWD:'
23 pwd
24 export VO_CMS_SW_DIR=/cvmfs/cms.cern.ch
25 source $VO_CMS_SW_DIR/cmsset_default.sh
26 echo 'environment:'
27 echo
28 env > local.env
29 env
30 # ulimit -v 3000000 # NO
31 echo 'copying job dir to worker'
32 eval `scram runtime -sh`
33 ls
34 echo 'running'
35 python $CMSSW_BASE/src/PhysicsTools/HeppyCore/python/framework/looper.py pycfg.py config.pck >& local.output
36 exit $?
37 #echo
38 #echo 'sending the job directory back'
39 #echo cp -r Loop/* $LS_SUBCWD
40 """.format(jdir=jobDir)
41 
42  return script
def batchScriptPADOVA
Definition: heppy_batch.py:14
def heppy_batch.batchScriptPISA (   index,
  remoteDir = '' 
)
prepare the LSF version of the batch script, to run on LSF

Definition at line 43 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

43 
44 def batchScriptPISA( index, remoteDir=''):
45  '''prepare the LSF version of the batch script, to run on LSF'''
46  script = """#!/bin/bash
47 #BSUB -q cms
48 echo 'PWD:'
49 pwd
50 export VO_CMS_SW_DIR=/cvmfs/cms.cern.ch
51 source $VO_CMS_SW_DIR/cmsset_default.sh
52 echo 'environment:'
53 echo
54 env > local.env
55 env
56 # ulimit -v 3000000 # NO
57 echo 'copying job dir to worker'
58 ###cd $CMSSW_BASE/src
59 eval `scramv1 runtime -sh`
60 #eval `scramv1 ru -sh`
61 # cd $LS_SUBCWD
62 # eval `scramv1 ru -sh`
63 ##cd -
64 ##cp -rf $LS_SUBCWD .
65 ls
66 echo `find . -type d | grep /`
67 echo 'running'
68 python $CMSSW_BASE/src/PhysicsTools/HeppyCore/python/framework/looper.py pycfg.py config.pck >& local.output
69 exit $?
70 #echo
71 #echo 'sending the job directory back'
72 #echo cp -r Loop/* $LS_SUBCWD
73 """
74  return script
def batchScriptPISA
Definition: heppy_batch.py:43
def heppy_batch.batchScriptPSI (   index,
  jobDir,
  remoteDir = '' 
)
prepare the SGE version of the batch script, to run on the PSI tier3 batch system

Definition at line 135 of file heppy_batch.py.

136 def batchScriptPSI( index, jobDir, remoteDir=''):
137  '''prepare the SGE version of the batch script, to run on the PSI tier3 batch system'''
138 
139  cmssw_release = os.environ['CMSSW_BASE']
140  VO_CMS_SW_DIR = "/swshare/cms" # $VO_CMS_SW_DIR doesn't seem to work in the new SL6 t3wn
141 
142  if remoteDir=='':
143  cpCmd="""echo 'sending the job directory back'
144 cp -r Loop/* $SUBMISIONDIR"""
145  elif remoteDir.startswith("/pnfs/psi.ch"):
146  cpCmd="""echo 'sending root files to remote dir'
147 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/dcap/ # Fabio's workaround to fix gfal-tools
148 for f in Loop/treeProducerSusyFullHad/*.root
149 do
150 echo $f
151 ff=`basename $f | cut -d . -f 1`
152 echo $ff
153 gfal-mkdir {srm}
154 echo "gfal-copy file:///`pwd`/Loop/treeProducerSusyFullHad/$file.root {srm}/${{ff}}_{idx}.root"
155 gfal-copy file:///`pwd`/Loop/treeProducerSusyFullHad/$ff.root {srm}/${{ff}}_{idx}.root
156 done
157 rm Loop/treeProducerSusyFullHad/*.root
158 echo 'sending the logs back'
159 cp -r Loop/* $SUBMISIONDIR""".format(idx=index, srm='srm://t3se01.psi.ch'+remoteDir+jobDir[jobDir.rfind("/"):jobDir.find("_Chunk")])
160  else:
161  print "remote directory not supported yet: ", remoteDir
162  print 'path must start with "/pnfs/psi.ch"'
163  sys.exit(1)
164 
165 
166  script = """#!/bin/bash
167 shopt expand_aliases
168 ##### MONITORING/DEBUG INFORMATION ###############################
169 DATE_START=`date +%s`
170 echo "Job started at " `date`
171 cat <<EOF
172 ################################################################
173 ## QUEUEING SYSTEM SETTINGS:
174 HOME=$HOME
175 USER=$USER
176 JOB_ID=$JOB_ID
177 JOB_NAME=$JOB_NAME
178 HOSTNAME=$HOSTNAME
179 TASK_ID=$TASK_ID
180 QUEUE=$QUEUE
181 
182 EOF
183 echo "######## Environment Variables ##########"
184 env
185 echo "################################################################"
186 TOPWORKDIR=/scratch/`whoami`
187 JOBDIR=sgejob-$JOB_ID
188 WORKDIR=$TOPWORKDIR/$JOBDIR
189 SUBMISIONDIR={jdir}
190 if test -e "$WORKDIR"; then
191  echo "ERROR: WORKDIR ($WORKDIR) already exists! Aborting..." >&2
192  exit 1
193 fi
194 mkdir -p $WORKDIR
195 if test ! -d "$WORKDIR"; then
196  echo "ERROR: Failed to create workdir ($WORKDIR)! Aborting..." >&2
197  exit 1
198 fi
199 
200 #source $VO_CMS_SW_DIR/cmsset_default.sh
201 source {vo}/cmsset_default.sh
202 export SCRAM_ARCH=slc6_amd64_gcc481
203 #cd $CMSSW_BASE/src
204 cd {cmssw}/src
205 shopt -s expand_aliases
206 cmsenv
207 cd $WORKDIR
208 cp -rf $SUBMISIONDIR .
209 ls
210 cd `find . -type d | grep /`
211 echo 'running'
212 #python $CMSSW_BASE/src/CMGTools/RootTools/python/fwlite/looper.py config.pck
213 python {cmssw}/src/CMGTools/RootTools/python/fwlite/looper.py pycfg.py config.pck
214 echo
215 {copy}
216 ###########################################################################
217 DATE_END=`date +%s`
218 RUNTIME=$((DATE_END-DATE_START))
219 echo "################################################################"
220 echo "Job finished at " `date`
221 echo "Wallclock running time: $RUNTIME s"
222 exit 0
223 """.format(jdir=jobDir, vo=VO_CMS_SW_DIR,cmssw=cmssw_release, copy=cpCmd)
224 
225  return script
def batchScriptPSI
Definition: heppy_batch.py:135

Variable Documentation

tuple heppy_batch.batchManager = MyBatchManager()

Definition at line 296 of file heppy_batch.py.

list heppy_batch.cfgFileName = args[0]

Definition at line 306 of file heppy_batch.py.

tuple heppy_batch.cfo = imp.load_source("pycfg", cfgFileName, handle)

Definition at line 309 of file heppy_batch.py.

tuple heppy_batch.components = split( [comp for comp in config.components if len(comp.files)>0] )

Definition at line 313 of file heppy_batch.py.

heppy_batch.config = cfo.config

Definition at line 310 of file heppy_batch.py.

tuple heppy_batch.handle = open(cfgFileName, 'r')

Definition at line 308 of file heppy_batch.py.

list heppy_batch.listOfNames = [comp.name for comp in components]

Definition at line 315 of file heppy_batch.py.

tuple heppy_batch.listOfValues = range(0, len(components))

Definition at line 314 of file heppy_batch.py.

float heppy_batch.waitingTime = 0.1

Definition at line 318 of file heppy_batch.py.