14 from __future__
import print_function
15 import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass
as mpslib
20 lib = mpslib.jobdatabase()
24 command = [
"ls",
"-l", os.path.join(lib.mssDir,
"binaries")]
26 eoslsoutput = subprocess.check_output(command, stderr=subprocess.STDOUT).
split(
'\n')
27 except subprocess.CalledProcessError:
31 for i
in xrange(len(lib.JOBID)):
66 if 'DISABLED' in lib.JOBSTATUS[i]:
69 if 'FETCH' in lib.JOBSTATUS[i]:
72 stdOut =
'jobData/'+lib.JOBDIR[i]+
'/STDOUT' 74 if os.access(stdOut+
'.gz', os.R_OK):
75 os.system(
'gunzip '+stdOut+
'.gz')
78 with open(stdOut,
"r") as STDFILE: 84 if re.search(re.compile(
'Unable to access quota space',re.M|re.I), line):
86 if re.search(re.compile(
'Unable to get quota space',re.M|re.I), line):
88 if re.search(re.compile(
'Disk quota exceeded',re.M|re.I), line):
90 if re.search(re.compile(
'CERN report: Job Killed',re.M), line):
92 if re.search(re.compile(
'Job finished',re.M), line):
94 if re.search(re.compile(
'connection timed out',re.M), line):
96 if re.search(re.compile(
'ConfigFileReadError',re.M), line):
98 if re.search(re.compile(
'0 bytes transferred',re.M), line):
100 if re.search(re.compile(
'command not found',re.M), line):
103 if re.search(re.compile(
'stage_put: Insufficient user privileges',re.M), line):
109 match = re.search(re.compile(
'This process used .+?(\d+) KSI2K seconds',re.M|re.I), line)
112 cputime =
int(round(
int(match.group(1))/cpuFactor))
115 print(
'gzip -f '+stdOut)
116 os.system(
'gzip -f '+stdOut)
118 if e.args == (2,
"No such file or directory"):
119 print(
"mps_check.py cannot find", stdOut,
"to test")
125 log_file = os.path.join(
"jobData", lib.JOBDIR[i],
"HTCJOB")
126 condor_log = subprocess.check_output([
"condor_q", lib.JOBID[i],
127 "-userlog", log_file,
132 stderr = subprocess.STDOUT)
133 condor_log = condor_log.split()
135 cputime =
int(round(
float(condor_log[0])))
137 if condor_log[1] ==
"3":
139 kill_reason =
" ".
join(condor_log[2:])
141 except subprocess.CalledProcessError
as e:
146 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/cmsRun.out' 147 if os.access(eazeLog, os.R_OK):
149 with open(eazeLog,
"r") as INFILE: 153 if re.search(re.compile(
'<StorageStatistics>',re.M), line):
155 if re.search(re.compile(
'Time limit reached\.',re.M), line):
157 if re.search(re.compile(
'gives I\/O problem',re.M), line):
159 if re.search(re.compile(
'FrameworkError ExitStatus=[\'\"]8001[\'\"]',re.M), line):
161 if re.search(re.compile(
'too many tracks',re.M), line):
163 if re.search(re.compile(
'segmentation violation',re.M), line):
165 if re.search(re.compile(
'failed RFIO error',re.M), line):
167 if re.search(re.compile(
'Request exceeds quota',re.M), line):
171 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/alignment.log' 174 if os.access(eazeLog+
'.gz', os.R_OK):
175 os.system(
'gunzip '+eazeLog+
'.gz')
178 if os.access(eazeLog, os.R_OK):
180 with open(eazeLog,
'r') as INFILE: 184 if re.search(re.compile(
'<StorageStatistics>',re.M), line):
186 if re.search(re.compile(
'EAZE\. Time limit reached\.',re.M), line):
188 if re.search(re.compile(
'GAF gives I\/O problem',re.M), line):
190 if re.search(re.compile(
'FrameworkError ExitStatus=[\'\"]8001[\'\"]',re.M), line):
192 if re.search(re.compile(
'too many tracks',re.M), line):
194 if re.search(re.compile(
'segmentation violation',re.M), line):
196 if re.search(re.compile(
'failed RFIO error',re.M), line):
198 if re.search(re.compile(
'Request exceeds quota',re.M), line):
201 if re.search(re.compile(
'Fatal Exception',re.M), line):
203 if re.search(re.compile(
'Exception caught in cmsRun',re.M), line):
206 if re.search(re.compile(
'AlignmentProducerAsAnalyzer::endJob\(\)',re.M), line):
208 if re.search(re.compile(
'FwkReport -i main_input:sourc',re.M), line):
210 nEvent =
int(array[5])
211 if nEvent==0
and re.search(re.compile(
'FwkReport -i PostSource',re.M), line):
213 nEvent =
int(array[5])
215 if nEvent==0
and re.search(re.compile(
'FwkReport -i AfterSource',re.M), line):
217 nEvent =
int(array[5])
219 if logZipped ==
'true':
220 os.system(
'gzip '+eazeLog)
223 print(
'mps_check.py cannot find',eazeLog,
'to test')
229 milleOut =
'milleBinary%03d.dat' % (i+1)
235 for line
in eoslsoutput:
237 columns = line.split()
238 mOutSize = columns[4]
245 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/pede.dump' 246 if os.access(eazeLog+
'.gz', os.R_OK):
248 os.system(
'rm -f /tmp/pede.dump')
249 os.system(
'gunzip -c '+eazeLog+
'.gz > /tmp/pede.dump')
250 eazeLog =
'/tmp/pede.dump' 251 if os.access(eazeLog, os.R_OK):
252 with open(eazeLog,
"r") as INFILE: # open pede.dump 258 if re.search(re.compile(
'Millepede II.* ending',re.M), line):
261 match = re.search(re.compile(
'Peak dynamic memory allocation: (.+) GB',re.I), line)
264 mem = re.sub(
'\s',
'', mem)
266 if re.search(re.compile(
'^\d+\.\d+$',re.M), mem):
267 usedPedeMem =
float(mem)
269 print(
'mps_check.py: Found Pede peak memory allocation but extracted number is not a float:',mem)
273 if lib.pedeMem > 0
and usedPedeMem > 0.:
274 memoryratio = usedPedeMem /(lib.pedeMem/1024.)
277 if lib.pedeMem > 4000
and memoryratio < 0.75 :
278 msg = (
"Warning: {0:.2f} GB of memory for Pede " 279 "requested, but only {1:.1f}% of it has been " 280 "used! Consider to request less memory in order " 281 "to save resources.")
282 print(msg.format(lib.pedeMem/1024.0, memoryratio*100))
283 elif memoryratio > 1 :
284 msg = (
"Warning: {0:.2f} GB of memory for Pede " 285 "requested, but {1:.1f}% of this has been " 286 "used! Consider to request more memory to avoid " 287 "premature removal of the job by the admin.")
288 print(msg.format(lib.pedeMem/1024.0, memoryratio*100))
290 msg = (
"Info: Used {0:.1f}% of {1:.2f} GB of memory " 291 "which has been requested for Pede.")
292 print(msg.format(memoryratio*100, lib.pedeMem/1024.0))
296 if eazeLog ==
'/tmp/pede.dump':
297 os.system(
'rm /tmp/pede.dump')
301 print(
'mps_check.py cannot find',eazeLog,
'to test')
304 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/millepede.log' 306 if os.access(eazeLog+
'.gz', os.R_OK):
307 os.system(
'gunzip '+eazeLog+
'.gz')
310 if os.access(eazeLog, os.R_OK):
312 with open(eazeLog,
"r") as INFILE: 316 if re.search(re.compile(
'step no descending',re.M), line):
318 pedeLogErrStr += line
319 if re.search(re.compile(
'Constraint equation discrepancies:',re.M), line):
321 pedeLogErrStr += line
323 if re.search(re.compile(
'insufficient constraint equations',re.M), line):
325 pedeLogWrnStr += line
327 if logZipped ==
'true':
328 os.system(
'gzip '+eazeLog)
330 print(
'mps_check.py cannot find',eazeLog,
'to test')
334 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/millepede.end' 336 if os.access(eazeLog+
'.gz', os.R_OK):
337 os.system(
'gunzip'+eazeLog+
'.gz')
340 if os.access(eazeLog, os.R_OK):
342 with open(eazeLog,
"r") as INFILE: 347 match = re.search(re.compile(
'([-+]?\d+)',re.M), line)
349 if int(match.group(1)) == 1:
351 pedeLogWrnStr += line
352 elif int(match.group(1)) != 0:
354 pedeLogErrStr += line
355 if logZipped ==
'true':
356 os.system(
'gzip '+eazeLog)
358 print(
'mps_check.py cannot find',eazeLog,
'to test')
366 print(lib.JOBDIR[i],lib.JOBID[i],
'did not reach end of file')
369 print(lib.JOBDIR[i],lib.JOBID[i],
'had quota space problem')
371 remark =
'eos quota space problem' 373 print(lib.JOBDIR[i],lib.JOBID[i],
'had I/O problem')
376 print(lib.JOBDIR[i],lib.JOBID[i],
'had Framework error 8001 problem')
377 remark =
'fwk error 8001' 380 print(lib.JOBDIR[i],lib.JOBID[i],
'had connection timed out problem')
381 remark =
'connection timed out' 383 print(lib.JOBDIR[i],lib.JOBID[i],
'had config file error')
384 remark =
'cfg file error' 387 guess =
" (probably time exceeded)" if kill_reason
is None else ":" 388 print(lib.JOBDIR[i], lib.JOBID[i],
"Job killed" + guess)
389 if kill_reason
is not None:
print(kill_reason)
393 print(lib.JOBDIR[i],lib.JOBID[i],
'ran into time limit')
395 if tooManyTracks == 1:
396 print(lib.JOBDIR[i],lib.JOBID[i],
'too many tracks')
398 print(lib.JOBDIR[i],lib.JOBID[i],
'SEGVIOL encountered')
402 print(lib.JOBDIR[i],lib.JOBID[i],
'RFIO error encountered')
403 remark =
'rfio error' 406 print(lib.JOBDIR[i],lib.JOBID[i],
'Request exceeds quota')
407 if exceptionCaught == 1:
408 print(lib.JOBDIR[i],lib.JOBID[i],
'Exception caught in cmsrun')
409 remark =
'Exception caught' 412 print(
'milleBinary???.dat file not found or empty')
413 remark =
'empty milleBinary' 414 if emptyDatOnFarm > 0:
415 print(
'...but already empty on farm so OK (or check job',i+1,
'yourself...)')
419 print(lib.JOBDIR[i],lib.JOBID[i],
'Command not found')
420 remark =
'cmd not found' 423 print(lib.JOBDIR[i],lib.JOBID[i],
'Insufficient privileges to rfcp files')
424 remark =
'Could not rfcp files' 427 print(lib.JOBDIR[i],lib.JOBID[i],
'Pede did not end normally')
428 remark =
'pede failed' 431 print(lib.JOBDIR[i],lib.JOBID[i],
'Problems in running Pede:')
433 remark =
'pede error' 437 print(lib.JOBDIR[i],lib.JOBID[i],
'Warnings in running Pede:')
439 remark =
'pede warnings' 442 print(lib.JOBDIR[i],lib.JOBID[i],
'Job not ended')
443 remark =
'job not ended' 448 print(lib.JOBDIR[i],lib.JOBID[i],
' -------- ',okStatus)
451 lib.JOBNEVT[i] = nEvent
453 lib.JOBSTATUS[i] = disabled+okStatus
455 lib.JOBRUNTIME[i] = cputime
457 lib.JOBREMARK[i] = remark
S & print(S &os, JobReport::InputFile const &f)
static std::string join(char **cmd)