14 from __future__
import print_function
15 from builtins
import range
16 import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass
as mpslib
21 lib = mpslib.jobdatabase()
25 command = [
"ls",
"-l", os.path.join(lib.mssDir,
"binaries")]
27 eoslsoutput = subprocess.check_output(command, stderr=subprocess.STDOUT).
split(
'\n')
28 except subprocess.CalledProcessError:
32 for i
in range(len(lib.JOBID)):
69 if 'DISABLED' in lib.JOBSTATUS[i]:
72 if 'FETCH' in lib.JOBSTATUS[i]:
75 stdOut =
'jobData/'+lib.JOBDIR[i]+
'/STDOUT'
77 if os.access(stdOut+
'.gz', os.R_OK):
78 os.system(
'gunzip '+stdOut+
'.gz')
81 with open(stdOut,
"r")
as STDFILE:
87 if re.search(re.compile(
'Unable to access quota space',re.M|re.I), line):
89 if re.search(re.compile(
'Unable to get quota space',re.M|re.I), line):
91 if re.search(re.compile(
'Disk quota exceeded',re.M|re.I), line):
93 if re.search(re.compile(
'CERN report: Job Killed',re.M), line):
95 if re.search(re.compile(
'Job finished',re.M), line):
97 if re.search(re.compile(
'connection timed out',re.M), line):
99 if re.search(re.compile(
'ConfigFileReadError',re.M), line):
101 if re.search(re.compile(
'0 bytes transferred',re.M), line):
103 if re.search(re.compile(
'command not found',re.M), line):
106 if re.search(re.compile(
'stage_put: Insufficient user privileges',re.M), line):
108 if re.search(re.compile(
'Give up doing',re.M), line):
110 if re.search(re.compile(
'Directory content before',re.M),line):
116 match = re.search(re.compile(
'This process used .+?(\d+) KSI2K seconds',re.M|re.I), line)
119 cputime =
int(round(
int(match.group(1))/cpuFactor))
122 print(
'gzip -f '+stdOut)
123 os.system(
'gzip -f '+stdOut)
125 if e.args == (2,
"No such file or directory"):
126 print(
"mps_check.py cannot find", stdOut,
"to test")
132 log_file = os.path.join(
"jobData", lib.JOBDIR[i],
"HTCJOB")
133 condor_log = subprocess.check_output([
"condor_q", lib.JOBID[i],
134 "-userlog", log_file,
139 stderr = subprocess.STDOUT)
140 condor_log = condor_log.split()
142 cputime =
int(round(
float(condor_log[0])))
144 if condor_log[1] ==
"3":
146 kill_reason =
" ".
join(condor_log[2:])
148 except subprocess.CalledProcessError
as e:
153 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/cmsRun.out'
154 if os.access(eazeLog, os.R_OK):
156 with open(eazeLog,
"r")
as INFILE:
160 if re.search(re.compile(
'<StorageStatistics>',re.M), line):
162 if re.search(re.compile(
'Time limit reached\.',re.M), line):
164 if re.search(re.compile(
'gives I\/O problem',re.M), line):
166 if re.search(re.compile(
'FrameworkError ExitStatus=[\'\"]8001[\'\"]',re.M), line):
168 if re.search(re.compile(
'too many tracks',re.M), line):
170 if re.search(re.compile(
'segmentation violation',re.M), line):
172 if re.search(re.compile(
'failed RFIO error',re.M), line):
174 if re.search(re.compile(
'Request exceeds quota',re.M), line):
178 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/alignment.log'
181 if os.access(eazeLog+
'.gz', os.R_OK):
182 os.system(
'gunzip '+eazeLog+
'.gz')
185 if os.access(eazeLog, os.R_OK):
187 with open(eazeLog,
'r')
as INFILE:
191 if re.search(re.compile(
'<StorageStatistics>',re.M), line):
193 if re.search(re.compile(
'EAZE\. Time limit reached\.',re.M), line):
195 if re.search(re.compile(
'GAF gives I\/O problem',re.M), line):
197 if re.search(re.compile(
'FrameworkError ExitStatus=[\'\"]8001[\'\"]',re.M), line):
199 if re.search(re.compile(
'too many tracks',re.M), line):
201 if re.search(re.compile(
'segmentation violation',re.M), line):
203 if re.search(re.compile(
'failed RFIO error',re.M), line):
205 if re.search(re.compile(
'Request exceeds quota',re.M), line):
208 if re.search(re.compile(
'Fatal Exception',re.M), line):
210 if re.search(re.compile(
'Exception caught in cmsRun',re.M), line):
213 if re.search(re.compile(
'AlignmentProducerAsAnalyzer::endJob\(\)',re.M), line):
215 if re.search(re.compile(
'FwkReport -i main_input:sourc',re.M), line):
217 nEvent =
int(array[5])
218 if nEvent==0
and re.search(re.compile(
'FwkReport -i PostSource',re.M), line):
220 nEvent =
int(array[5])
222 if nEvent==0
and re.search(re.compile(
'FwkReport -i AfterSource',re.M), line):
224 nEvent =
int(array[5])
226 if logZipped ==
'true':
227 os.system(
'gzip -f '+eazeLog)
230 print(
'mps_check.py cannot find',eazeLog,
'to test')
236 milleOut =
'milleBinary%03d.dat' % (i+1)
242 for line
in eoslsoutput:
244 columns = line.split()
245 mOutSize = columns[4]
252 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/pede.dump'
253 if os.access(eazeLog+
'.gz', os.R_OK):
255 os.system(
'rm -f /tmp/pede.dump')
256 os.system(
'gunzip -c '+eazeLog+
'.gz > /tmp/pede.dump')
257 eazeLog =
'/tmp/pede.dump'
258 if os.access(eazeLog, os.R_OK):
259 with open(eazeLog,
"r")
as INFILE:
265 if re.search(re.compile(
'Millepede II.* ending',re.M), line):
268 match = re.search(re.compile(
'Peak dynamic memory allocation: (.+) GB',re.I), line)
271 mem = re.sub(
'\s',
'', mem)
273 if re.search(re.compile(
'^\d+\.\d+$',re.M), mem):
274 usedPedeMem =
float(mem)
276 print(
'mps_check.py: Found Pede peak memory allocation but extracted number is not a float:',mem)
280 if lib.pedeMem > 0
and usedPedeMem > 0.:
281 memoryratio = usedPedeMem /(lib.pedeMem/1024.)
284 if lib.pedeMem > 4000
and memoryratio < 0.75 :
285 msg = (
"Warning: {0:.2f} GB of memory for Pede "
286 "requested, but only {1:.1f}% of it has been "
287 "used! Consider to request less memory in order "
288 "to save resources.")
289 print(msg.format(lib.pedeMem/1024.0, memoryratio*100))
290 elif memoryratio > 1 :
291 msg = (
"Warning: {0:.2f} GB of memory for Pede "
292 "requested, but {1:.1f}% of this has been "
293 "used! Consider to request more memory to avoid "
294 "premature removal of the job by the admin.")
295 print(msg.format(lib.pedeMem/1024.0, memoryratio*100))
297 msg = (
"Info: Used {0:.1f}% of {1:.2f} GB of memory "
298 "which has been requested for Pede.")
299 print(msg.format(memoryratio*100, lib.pedeMem/1024.0))
303 if eazeLog ==
'/tmp/pede.dump':
304 os.system(
'rm /tmp/pede.dump')
308 print(
'mps_check.py cannot find',eazeLog,
'to test')
311 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/millepede.log'
313 if os.access(eazeLog+
'.gz', os.R_OK):
314 os.system(
'gunzip '+eazeLog+
'.gz')
317 if os.access(eazeLog, os.R_OK):
319 with open(eazeLog,
"r")
as INFILE:
323 if re.search(re.compile(
'step no descending',re.M), line):
325 pedeLogErrStr += line
326 if re.search(re.compile(
'Constraint equation discrepancies:',re.M), line):
328 pedeLogErrStr += line
330 if re.search(re.compile(
'insufficient constraint equations',re.M), line):
332 pedeLogWrnStr += line
334 if logZipped ==
'true':
335 os.system(
'gzip -f '+eazeLog)
337 print(
'mps_check.py cannot find',eazeLog,
'to test')
341 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/millepede.end'
343 if os.access(eazeLog+
'.gz', os.R_OK):
344 os.system(
'gunzip'+eazeLog+
'.gz')
347 if os.access(eazeLog, os.R_OK):
349 with open(eazeLog,
"r")
as INFILE:
354 match = re.search(re.compile(
'([-+]?\d+)',re.M), line)
356 if int(match.group(1)) == 1:
358 pedeLogWrnStr += line
359 elif int(match.group(1)) != 0:
361 pedeLogErrStr += line
362 if logZipped ==
'true':
363 os.system(
'gzip -f '+eazeLog)
365 print(
'mps_check.py cannot find',eazeLog,
'to test')
373 print(lib.JOBDIR[i],lib.JOBID[i],
'did not reach end of file')
376 print(lib.JOBDIR[i],lib.JOBID[i],
'had quota space problem')
378 remark =
'eos quota space problem'
380 print(lib.JOBDIR[i],lib.JOBID[i],
'had I/O problem')
383 print(lib.JOBDIR[i],lib.JOBID[i],
'had Framework error 8001 problem')
384 remark =
'fwk error 8001'
387 print(lib.JOBDIR[i],lib.JOBID[i],
'had connection timed out problem')
388 remark =
'connection timed out'
390 print(lib.JOBDIR[i],lib.JOBID[i],
'had config file error')
391 remark =
'cfg file error'
394 guess =
" (probably time exceeded)" if kill_reason
is None else ":"
395 print(lib.JOBDIR[i], lib.JOBID[i],
"Job killed" + guess)
396 if kill_reason
is not None:
print(kill_reason)
400 print(lib.JOBDIR[i],lib.JOBID[i],
'ran into time limit')
402 if tooManyTracks == 1:
403 print(lib.JOBDIR[i],lib.JOBID[i],
'too many tracks')
405 print(lib.JOBDIR[i],lib.JOBID[i],
'SEGVIOL encountered')
409 print(lib.JOBDIR[i],lib.JOBID[i],
'RFIO error encountered')
410 remark =
'rfio error'
413 print(lib.JOBDIR[i],lib.JOBID[i],
'Request exceeds quota')
414 if exceptionCaught == 1:
415 print(lib.JOBDIR[i],lib.JOBID[i],
'Exception caught in cmsrun')
416 remark =
'Exception caught'
419 print(
'milleBinary???.dat file not found or empty')
420 remark =
'empty milleBinary'
421 if emptyDatOnFarm > 0:
422 print(
'...but already empty on farm so OK (or check job',i+1,
'yourself...)')
426 print(lib.JOBDIR[i],lib.JOBID[i],
'Command not found')
427 remark =
'cmd not found'
430 print(lib.JOBDIR[i],lib.JOBID[i],
'Insufficient privileges to rfcp files')
431 remark =
'Could not rfcp files'
434 print(lib.JOBDIR[i],lib.JOBID[i],
'Pede did not end normally')
435 remark =
'pede failed'
438 print(lib.JOBDIR[i],lib.JOBID[i],
'Problems in running Pede:')
440 remark =
'pede error'
444 print(lib.JOBDIR[i],lib.JOBID[i],
'Warnings in running Pede:')
446 remark =
'pede warnings'
449 print(lib.JOBDIR[i],lib.JOBID[i],
'Job not ended')
450 remark =
'job not ended'
452 if copyerr == 1
and ispede!=1:
454 print(lib.JOBDIR[i],lib.JOBID[i],
'Copy to eos failed')
455 remark =
'copy to eos failed'
461 print(lib.JOBDIR[i],lib.JOBID[i],
' -------- ',okStatus)
464 lib.JOBNEVT[i] = nEvent
466 lib.JOBSTATUS[i] = disabled+okStatus
468 lib.JOBRUNTIME[i] = cputime
470 lib.JOBREMARK[i] = remark