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 76 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

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

Definition at line 232 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

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

Definition at line 252 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

253 def batchScriptLocal( remoteDir, index ):
254  '''prepare a local version of the batch script, to run using nohup'''
255 
256  script = """#!/bin/bash
257 echo 'running'
258 python $CMSSW_BASE/src/PhysicsTools/HeppyCore/python/framework/looper.py pycfg.py config.pck --options=options.json
259 echo
260 echo 'sending the job directory back'
261 mv Loop/* ./
262 """
263  return script
264 
def batchScriptLocal
Definition: heppy_batch.py:252
def heppy_batch.batchScriptPADOVA (   index,
  jobDir = './' 
)
prepare the LSF version of the batch script, to run on LSF

Definition at line 15 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

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

Definition at line 44 of file heppy_batch.py.

Referenced by heppy_batch.MyBatchManager.PrepareJobUser().

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

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

Variable Documentation

tuple heppy_batch.batchManager = MyBatchManager()

Definition at line 306 of file heppy_batch.py.

list heppy_batch.cfgFileName = args[0]

Definition at line 325 of file heppy_batch.py.

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

Definition at line 329 of file heppy_batch.py.

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

Definition at line 333 of file heppy_batch.py.

heppy_batch.config = cfo.config

Definition at line 330 of file heppy_batch.py.

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

Definition at line 327 of file heppy_batch.py.

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

Definition at line 335 of file heppy_batch.py.

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

Definition at line 334 of file heppy_batch.py.

float heppy_batch.waitingTime = 0.1

Definition at line 338 of file heppy_batch.py.