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)):
67 if 'DISABLED' in lib.JOBSTATUS[i]:
70 if 'FETCH' in lib.JOBSTATUS[i]:
73 stdOut =
'jobData/'+lib.JOBDIR[i]+
'/STDOUT' 75 if os.access(stdOut+
'.gz', os.R_OK):
76 os.system(
'gunzip '+stdOut+
'.gz')
79 with open(stdOut,
"r") as STDFILE: 85 if re.search(re.compile(
'Unable to access quota space',re.M|re.I), line):
87 if re.search(re.compile(
'Unable to get quota space',re.M|re.I), line):
89 if re.search(re.compile(
'Disk quota exceeded',re.M|re.I), line):
91 if re.search(re.compile(
'CERN report: Job Killed',re.M), line):
93 if re.search(re.compile(
'Job finished',re.M), line):
95 if re.search(re.compile(
'connection timed out',re.M), line):
97 if re.search(re.compile(
'ConfigFileReadError',re.M), line):
99 if re.search(re.compile(
'0 bytes transferred',re.M), line):
101 if re.search(re.compile(
'command not found',re.M), line):
104 if re.search(re.compile(
'stage_put: Insufficient user privileges',re.M), line):
110 match = re.search(re.compile(
'This process used .+?(\d+) KSI2K seconds',re.M|re.I), line)
113 cputime =
int(round(
int(match.group(1))/cpuFactor))
116 print(
'gzip -f '+stdOut)
117 os.system(
'gzip -f '+stdOut)
119 if e.args == (2,
"No such file or directory"):
120 print(
"mps_check.py cannot find", stdOut,
"to test")
126 log_file = os.path.join(
"jobData", lib.JOBDIR[i],
"HTCJOB")
127 condor_log = subprocess.check_output([
"condor_q", lib.JOBID[i],
128 "-userlog", log_file,
133 stderr = subprocess.STDOUT)
134 condor_log = condor_log.split()
136 cputime =
int(round(
float(condor_log[0])))
138 if condor_log[1] ==
"3":
140 kill_reason =
" ".
join(condor_log[2:])
142 except subprocess.CalledProcessError
as e:
147 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/cmsRun.out' 148 if os.access(eazeLog, os.R_OK):
150 with open(eazeLog,
"r") as INFILE: 154 if re.search(re.compile(
'<StorageStatistics>',re.M), line):
156 if re.search(re.compile(
'Time limit reached\.',re.M), line):
158 if re.search(re.compile(
'gives I\/O problem',re.M), line):
160 if re.search(re.compile(
'FrameworkError ExitStatus=[\'\"]8001[\'\"]',re.M), line):
162 if re.search(re.compile(
'too many tracks',re.M), line):
164 if re.search(re.compile(
'segmentation violation',re.M), line):
166 if re.search(re.compile(
'failed RFIO error',re.M), line):
168 if re.search(re.compile(
'Request exceeds quota',re.M), line):
172 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/alignment.log' 175 if os.access(eazeLog+
'.gz', os.R_OK):
176 os.system(
'gunzip '+eazeLog+
'.gz')
179 if os.access(eazeLog, os.R_OK):
181 with open(eazeLog,
'r') as INFILE: 185 if re.search(re.compile(
'<StorageStatistics>',re.M), line):
187 if re.search(re.compile(
'EAZE\. Time limit reached\.',re.M), line):
189 if re.search(re.compile(
'GAF gives I\/O problem',re.M), line):
191 if re.search(re.compile(
'FrameworkError ExitStatus=[\'\"]8001[\'\"]',re.M), line):
193 if re.search(re.compile(
'too many tracks',re.M), line):
195 if re.search(re.compile(
'segmentation violation',re.M), line):
197 if re.search(re.compile(
'failed RFIO error',re.M), line):
199 if re.search(re.compile(
'Request exceeds quota',re.M), line):
202 if re.search(re.compile(
'Fatal Exception',re.M), line):
204 if re.search(re.compile(
'Exception caught in cmsRun',re.M), line):
207 if re.search(re.compile(
'AlignmentProducerAsAnalyzer::endJob\(\)',re.M), line):
209 if re.search(re.compile(
'FwkReport -i main_input:sourc',re.M), line):
211 nEvent =
int(array[5])
212 if nEvent==0
and re.search(re.compile(
'FwkReport -i PostSource',re.M), line):
214 nEvent =
int(array[5])
216 if nEvent==0
and re.search(re.compile(
'FwkReport -i AfterSource',re.M), line):
218 nEvent =
int(array[5])
220 if logZipped ==
'true':
221 os.system(
'gzip '+eazeLog)
224 print(
'mps_check.py cannot find',eazeLog,
'to test')
230 milleOut =
'milleBinary%03d.dat' % (i+1)
236 for line
in eoslsoutput:
238 columns = line.split()
239 mOutSize = columns[4]
246 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/pede.dump' 247 if os.access(eazeLog+
'.gz', os.R_OK):
249 os.system(
'rm -f /tmp/pede.dump')
250 os.system(
'gunzip -c '+eazeLog+
'.gz > /tmp/pede.dump')
251 eazeLog =
'/tmp/pede.dump' 252 if os.access(eazeLog, os.R_OK):
253 with open(eazeLog,
"r") as INFILE: # open pede.dump 259 if re.search(re.compile(
'Millepede II.* ending',re.M), line):
262 match = re.search(re.compile(
'Peak dynamic memory allocation: (.+) GB',re.I), line)
265 mem = re.sub(
'\s',
'', mem)
267 if re.search(re.compile(
'^\d+\.\d+$',re.M), mem):
268 usedPedeMem =
float(mem)
270 print(
'mps_check.py: Found Pede peak memory allocation but extracted number is not a float:',mem)
274 if lib.pedeMem > 0
and usedPedeMem > 0.:
275 memoryratio = usedPedeMem /(lib.pedeMem/1024.)
278 if lib.pedeMem > 4000
and memoryratio < 0.75 :
279 msg = (
"Warning: {0:.2f} GB of memory for Pede " 280 "requested, but only {1:.1f}% of it has been " 281 "used! Consider to request less memory in order " 282 "to save resources.")
283 print(msg.format(lib.pedeMem/1024.0, memoryratio*100))
284 elif memoryratio > 1 :
285 msg = (
"Warning: {0:.2f} GB of memory for Pede " 286 "requested, but {1:.1f}% of this has been " 287 "used! Consider to request more memory to avoid " 288 "premature removal of the job by the admin.")
289 print(msg.format(lib.pedeMem/1024.0, memoryratio*100))
291 msg = (
"Info: Used {0:.1f}% of {1:.2f} GB of memory " 292 "which has been requested for Pede.")
293 print(msg.format(memoryratio*100, lib.pedeMem/1024.0))
297 if eazeLog ==
'/tmp/pede.dump':
298 os.system(
'rm /tmp/pede.dump')
302 print(
'mps_check.py cannot find',eazeLog,
'to test')
305 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/millepede.log' 307 if os.access(eazeLog+
'.gz', os.R_OK):
308 os.system(
'gunzip '+eazeLog+
'.gz')
311 if os.access(eazeLog, os.R_OK):
313 with open(eazeLog,
"r") as INFILE: 317 if re.search(re.compile(
'step no descending',re.M), line):
319 pedeLogErrStr += line
320 if re.search(re.compile(
'Constraint equation discrepancies:',re.M), line):
322 pedeLogErrStr += line
324 if re.search(re.compile(
'insufficient constraint equations',re.M), line):
326 pedeLogWrnStr += line
328 if logZipped ==
'true':
329 os.system(
'gzip '+eazeLog)
331 print(
'mps_check.py cannot find',eazeLog,
'to test')
335 eazeLog =
'jobData/'+lib.JOBDIR[i]+
'/millepede.end' 337 if os.access(eazeLog+
'.gz', os.R_OK):
338 os.system(
'gunzip'+eazeLog+
'.gz')
341 if os.access(eazeLog, os.R_OK):
343 with open(eazeLog,
"r") as INFILE: 348 match = re.search(re.compile(
'([-+]?\d+)',re.M), line)
350 if int(match.group(1)) == 1:
352 pedeLogWrnStr += line
353 elif int(match.group(1)) != 0:
355 pedeLogErrStr += line
356 if logZipped ==
'true':
357 os.system(
'gzip '+eazeLog)
359 print(
'mps_check.py cannot find',eazeLog,
'to test')
367 print(lib.JOBDIR[i],lib.JOBID[i],
'did not reach end of file')
370 print(lib.JOBDIR[i],lib.JOBID[i],
'had quota space problem')
372 remark =
'eos quota space problem' 374 print(lib.JOBDIR[i],lib.JOBID[i],
'had I/O problem')
377 print(lib.JOBDIR[i],lib.JOBID[i],
'had Framework error 8001 problem')
378 remark =
'fwk error 8001' 381 print(lib.JOBDIR[i],lib.JOBID[i],
'had connection timed out problem')
382 remark =
'connection timed out' 384 print(lib.JOBDIR[i],lib.JOBID[i],
'had config file error')
385 remark =
'cfg file error' 388 guess =
" (probably time exceeded)" if kill_reason
is None else ":" 389 print(lib.JOBDIR[i], lib.JOBID[i],
"Job killed" + guess)
390 if kill_reason
is not None:
print(kill_reason)
394 print(lib.JOBDIR[i],lib.JOBID[i],
'ran into time limit')
396 if tooManyTracks == 1:
397 print(lib.JOBDIR[i],lib.JOBID[i],
'too many tracks')
399 print(lib.JOBDIR[i],lib.JOBID[i],
'SEGVIOL encountered')
403 print(lib.JOBDIR[i],lib.JOBID[i],
'RFIO error encountered')
404 remark =
'rfio error' 407 print(lib.JOBDIR[i],lib.JOBID[i],
'Request exceeds quota')
408 if exceptionCaught == 1:
409 print(lib.JOBDIR[i],lib.JOBID[i],
'Exception caught in cmsrun')
410 remark =
'Exception caught' 413 print(
'milleBinary???.dat file not found or empty')
414 remark =
'empty milleBinary' 415 if emptyDatOnFarm > 0:
416 print(
'...but already empty on farm so OK (or check job',i+1,
'yourself...)')
420 print(lib.JOBDIR[i],lib.JOBID[i],
'Command not found')
421 remark =
'cmd not found' 424 print(lib.JOBDIR[i],lib.JOBID[i],
'Insufficient privileges to rfcp files')
425 remark =
'Could not rfcp files' 428 print(lib.JOBDIR[i],lib.JOBID[i],
'Pede did not end normally')
429 remark =
'pede failed' 432 print(lib.JOBDIR[i],lib.JOBID[i],
'Problems in running Pede:')
434 remark =
'pede error' 438 print(lib.JOBDIR[i],lib.JOBID[i],
'Warnings in running Pede:')
440 remark =
'pede warnings' 443 print(lib.JOBDIR[i],lib.JOBID[i],
'Job not ended')
444 remark =
'job not ended' 449 print(lib.JOBDIR[i],lib.JOBID[i],
' -------- ',okStatus)
452 lib.JOBNEVT[i] = nEvent
454 lib.JOBSTATUS[i] = disabled+okStatus
456 lib.JOBRUNTIME[i] = cputime
458 lib.JOBREMARK[i] = remark
S & print(S &os, JobReport::InputFile const &f)
static std::string join(char **cmd)