14 from __future__
import print_function
15 import tempfile
as tmp
16 import optparse
as opt
17 import cmsPerfRegress
as cpr
18 import re, os, sys, time, glob, socket, fnmatch
19 from shutil
import copy2, copystat
21 from cmsPerfCommons
import CandFname, Step, ProductionSteps, Candles
25 from functools
import reduce
27 PROG_NAME = os.path.basename(sys.argv[0])
28 DEF_RELVAL =
"/afs/cern.ch/cms/sdt/web/performance/RelVal" 29 DEF_SIMUL =
"/afs/cern.ch/cms/sdt/web/performance/simulation" 31 cpFileFilter = (
"*.root", )
34 TimeSizeNumOfEvents = -9999
35 IgProfNumOfEvents = -9999
36 CallgrindNumOfEvents = -9999
37 MemcheckNumOfEvents = -9999
55 Steps=set(Step+ProductionSteps+[
"GEN,FASTSIM",
"GEN,FASTSIM_PILEUP"])
64 "Relative directory could not be determined" 72 trail = re.compile(
"/$")
73 if os.path.isdir(adir)
and not trail.search(adir):
83 return subprocess.Popen(cmd,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().
strip()
90 return subprocess.Popen(command,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().
strip()
96 suffixes = [(
"B",2**10), (
"k",2**20), (
"M",2**30), (
"G",2**40), (
"T",2**50)]
97 for suf, lim
in suffixes:
102 return "-" + round(size/
float(lim/2**10),2).
__str__() + suf
116 self.table._newCol(colname)
131 out +=
"\n" + self.
rows 138 self.colNames.append(name)
144 if name
in self.rows.keys():
147 self.keys.append(name)
150 return self.
rows[name]
155 for key
in self.
keys:
161 rowobj = self.
rows[key]
162 rowdict = rowobj.getRowDict()
166 elif col
in rowdict
and not col == name:
168 total1 += rowdict[col]
170 (step_tot1, step_tot2) = rowdict[col]
174 rowobj.addEntry(name,total1)
176 rowobj.addEntry(name,(total1,total2))
181 if name
in self.rows.keys():
184 self.keys.append(name)
185 self.
rows[name] = row
189 for col
in self.colnames:
190 rowobj = transp.newRow(col)
191 for key
in self.
keys:
195 row_dict = self.
rows[key].getRowDict()
197 rowobj.addEntry(key,row_dict[col])
205 global TimeSizeNumOfEvents,IgProfNumOfEvents,CallgrindNumOfEvents,MemcheckNumOfEvents
208 def _copyReportsToStaging(repdir,LogFiles,cmsScimarkDir,stage):
209 """Use function syscp to copy LogFiles and cmsScimarkDir over to staging area""" 211 print(
"Copying the logfiles to %s/." % stage)
212 print(
"Copying the cmsScimark2 results to the %s/." % stage)
214 syscp(LogFiles , stage +
"/")
215 syscp(cmsScimarkDir, stage +
"/")
218 def _createLogFile(LogFile,date,LocalPath,ShowTagsResult):
219 """Creating a small logfile with basic publication script running information (never used really by other scripts in the suite).""" 221 LOG = open(LogFile,
"w")
223 print(
"Writing Production Host, Location, Release and Tags information in %s" % LogFile)
224 LOG.write(
"These performance tests were executed on host %s and published on %s" % (HOST,date))
225 LOG.write(
"They were run in %s" % LocalPath)
226 LOG.write(
"Results of showtags -r in the local release:\n%s" % ShowTagsResult)
228 except IOError
as detail:
229 print(
"WARNING: Can't create log file")
237 print(
"\n Getting Environment variables...")
244 print(
"\n Determining locations for input and staging...")
245 (drive,path,remote,stage,port,repdir,prevrev,igprof_remotedir) =
getStageRepDirs(options,args)
248 print(
"\n Getting the number of events for each test...")
250 cmsPerfSuiteLogfile=
"%s/cmsPerfSuite.log"%repdir
252 if os.path.exists(cmsPerfSuiteLogfile):
254 (TimeSizeNumOfEvents,IgProfNumOfEvents,CallgrindNumOfEvents,MemcheckNumOfEvents)=
getNumOfEventsFromLog(cmsPerfSuiteLogfile)
259 print(
"There was an issue in reading out the number of events for the various tests or the architecture/CMSSW version using the standard logfile %s"%cmsPerfSuiteLogFile)
260 print(
"Check that the format was not changed: this scripts relies on the initial perfsuite arguments to be dumped in the logfile one per line!")
261 print(
"For now taking the default values for all tests (0)!")
263 print(
"\n Scan report directory...")
265 (ExecutionDate,LogFiles,date,cmsScimarkResults,cmsScimarkDir) =
scanReportArea(repdir)
266 print(
"cmsScimarkResults are %s"%cmsScimarkResults)
267 print(
"\n Copy report files to staging directory...")
269 _copyReportsToStaging(repdir,LogFiles,cmsScimarkDir,stage)
271 print(
"\n Creating log file...")
273 _createLogFile(
"%s/ProductionLog.txt" % stage,date,repdir,ShowTagsResult)
276 for dirname
in os.listdir(repdir):
277 if "IgProf" in dirname:
278 print(
"\n Handling IgProf reports...")
282 print(
"\n Creating HTML files...")
284 createWebReports(stage,repdir,ExecutionDate,LogFiles,cmsScimarkResults,date,prevrev)
286 print(
"\n Copy profiling logs to staging directory...")
292 print(
"\n Uploading web report to remote location...")
294 print(
"\n Finished uploading! Now removing staging directory...")
297 print(
"\n Finished!!!")
304 global CMSSW_VERSION, CMSSW_RELEASE_BASE, CMSSW_BASE, HOST, USER, BASE_PERFORMANCE, CMSSW_WORK
305 global DEF_RELVAL, DEF_SIMUL
308 CMSSW_VERSION=os.environ[
'CMSSW_VERSION']
309 CMSSW_RELEASE_BASE=os.environ[
'CMSSW_RELEASE_BASE']
310 CMSSW_BASE=os.environ[
'CMSSW_BASE']
311 HOST=os.environ[
'HOST']
312 USER=os.environ[
'USER']
313 CMSSW_WORK = os.path.join(CMSSW_BASE,
"work/Results")
314 except KeyError
as detail:
315 fail(
"ERROR: Could not retrieve some necessary environment variables. Have you ran scramv1 runtime -csh yet?. Details: %s" % detail)
321 PerformancePkg=
"%s/src/Validation/Performance" % CMSSW_BASE
322 if (os.path.exists(PerformancePkg)):
323 BASE_PERFORMANCE=PerformancePkg
324 print(
"**Using LOCAL version of Validation/Performance instead of the RELEASE version**")
326 BASE_PERFORMANCE=
"%s/src/Validation/Performance" % CMSSW_RELEASE_BASE
328 return (LocalPath,ShowTagsResult)
334 global PROG_NAME, _debug, _dryrun, _verbose
336 parser = opt.OptionParser(usage=(
"""%s [HOST:]DEST_PATH [Options] 339 [HOST:]DEST_PATH - This is where the report should be published, you can specify a local path or a directory on a remote machine (HOST is optional) 342 Publish report to default local directory 344 Publish report to \"/some/local/dir\" 346 Publish report to \"/some/other/dir\" remote host \"hal.cern.ch\" 347 ./%s hal.cern.ch:/some/other/dir 348 Publish report to default relval location (this could be remote or local depending on the hardcoded default) 350 % ( PROG_NAME, PROG_NAME, PROG_NAME, PROG_NAME, PROG_NAME)))
352 devel = opt.OptionGroup(parser,
"Developer Options",
353 "Caution: use these options at your own risk." 354 "It is believed that some of them bite.\n")
359 help=
'Use the default RelVal location',
368 help=
'output more information',
376 help=
'Use the default simulation location',
384 help=
'The override the name of the previous release. Default is the string obtain from the identification file REGRESSION.<prevrel>.vs.<newrel>',
393 help=
'The location of the report files to be published',
402 help=
'Use a particular port number to rsync material to a remote server',
409 default=
'IgProfData',
411 help=
'Specify an AFS or host:mydir remote directory instead of default one',
412 metavar=
'<IGPROF REMOTE DIRECTORY>' 420 help=
'Show debug output',
428 help=
'Do not send files to remote server, but run everything else',
432 repdirdef = os.getcwd()
433 parser.set_defaults(debug=0,simulation=
False,relval=
False,port=873,pretend=
False,repdir=repdirdef,verbose=
False)
434 parser.add_option_group(devel)
436 (options, args) = parser.parse_args()
438 _debug = options.debug
439 _dryrun = options.dryrun
440 _verbose = options.verbose
442 numofargs = len(args)
444 if (options.simulation
and options.relval)
or ((options.simulation
or options.relval)
and numofargs >= 1):
445 parser.error(
"You can not specify simulation and relval together. Neither can you specify simulation or relval AND a path")
448 return (options, args)
453 '''A very fragile function to get the Number of events for each test by parsing the logfile of the Suite. This relies on the fact that nobody will turn off the print out of the options in the cmsPerfSuite.py output... ARGH!''' 454 log=open(logfile,
"r") 463 if 'TimeSizeEvents' in line
and not TimeSizeEvents:
464 lineitems=line.split()
465 TimeSizeEvents=lineitems[lineitems.index(
'TimeSizeEvents')+1]
466 if 'IgProfEvents' in line
and not IgProfEvents:
467 lineitems=line.split()
468 IgProfEvents=lineitems[lineitems.index(
'IgProfEvents')+1]
469 if 'CallgrindEvents' in line
and not CallgrindEvents:
470 lineitems=line.split()
471 CallgrindEvents=lineitems[lineitems.index(
'CallgrindEvents')+1]
472 if 'MemcheckEvents' in line
and not MemcheckEvents:
473 lineitems=line.split()
474 MemcheckEvents=lineitems[lineitems.index(
'MemcheckEvents')+1]
475 return (TimeSizeEvents,IgProfEvents,CallgrindEvents,MemcheckEvents)
478 '''Another very fragile function to get the architecture and the CMSSW version parsing the logfile...''' 479 log=open(logfile,
"r") 480 arch=re.compile("^Current Architecture is")
481 version=re.compile(
"^Current CMSSW version is")
482 CMSSW_arch=
"UNKNOWN_ARCH" 483 CMSSW_version=
"UNKNOWN_VERSION" 485 if arch.search(line):
486 CMSSW_arch=line.split()[3]
487 if version.search(line):
488 CMSSW_version=line.split()[4]
489 return(CMSSW_arch,CMSSW_version)
497 global TMP_DIR, IS_TMP, DEF_LOCAL, CMSSW_VERSION
498 DEF_LOCAL = CMSSW_WORK
499 numofargs = len(args)
501 repdir = os.path.abspath(options.repdir)
504 if not os.path.exists(repdir):
505 fail(
"ERROR: The specified report directory %s to retrieve report information from does not exist, exiting" % repdir)
507 previousrev = options.previousrev
508 if previousrev ==
"":
509 regressfiles = glob.glob(
"%s/REGRESSION.*.vs.*" % repdir)
510 if not len(regressfiles) == 0:
511 regressID = regressfiles[0]
512 base = os.path.basename(regressID)
513 split = base.split(
".")
514 previousrev = split[1]
515 currentrel = split[3]
516 print(
"Regression Identification file exists, renaming report title for regression report. Old ver: %s" % previousrev)
518 print(
"No regression ID file exists and previous release name was not specified. Producing normal report.")
520 print(
"Previous release name was specified, renaming report title for regression report. Old ver %s" % previousrev)
524 if options.simulation:
545 drive, path = uri.split(
":",1)
550 path = os.path.abspath(path)
551 remote =
not drive ==
"" 556 socket.getaddrinfo(drive,53)
558 except socket.gaierror:
564 socket.gethostbyaddr(drive)
566 except socket.gaierror:
569 print(
"ERROR: Can not determine your hostname or ipv{4,6} address %s" % drive)
570 if not (_dryrun
or _test):
573 if (
not remote)
and (
not options.port == 873) :
574 print(
"WARNING: Can not use a port if not performing a remote copy, ignoring")
583 localExists = os.path.exists(
"%s/%s" % (CMSSW_WORK,CMSSW_VERSION))
588 TMP_DIR=tmp.mkdtemp(prefix=
"/build/%s" % PROG_NAME)
589 StagingArea = TMP_DIR
591 elif defaultlocal
and localExists:
592 TMP_DIR=tmp.mkdtemp(prefix=
"%s/%s" % (CMSSW_WORK,CMSSW_VERSION))
593 StagingArea = TMP_DIR
594 print(
"WARNING: %s already exists, creating a temporary staging area %s" % (CMSSW_WORK,TMP_DIR))
597 StagingArea = CMSSW_WORK
599 os.mkdir(os.path.join(CMSSW_BASE,
"work"))
600 os.mkdir(os.path.join(CMSSW_BASE,
"work",
"Results"))
603 print(
"**User did not specify location of results, staging in default %s**" % StagingArea)
605 print(
"**User chose to publish results in a local directory**")
607 if not os.path.exists(path):
609 os.mkdir(
"%s" % path)
610 except OSError
as detail:
611 if detail.errno == 13:
612 fail(
"ERROR: Failed to create staging area %s because permission was denied " % StagingArea)
613 elif detail.errno == 17:
617 fail(
"ERROR: There was some problem (%s) when creating the staging directory" % detail)
619 IS_TMP =
not TMP_DIR ==
"" 625 StagingArea=
"%s/%s" % (StagingArea,CMSSW_VERSION)
627 os.mkdir(
"%s" % StagingArea)
628 except OSError
as detail:
629 if detail.errno == 13:
630 fail(
"ERROR: Failed to create staging area %s because permission was denied " % StagingArea)
631 elif detail.errno == 17:
635 fail(
"ERROR: There was some problem (%s) when creating the staging directory" % detail)
637 return (drive,path,remote,StagingArea,port,repdir,previousrev,options.ig_remotedir)
644 """Scans the working directory for cms*.logs (cmsPerfSuite.log and cmsScimark*.log, and cmsScimark results. 645 It returns Execution date (completion), current date, list of logfiles and cmsScimark results""" 647 LogFiles = glob.glob(repdir +
"cms*.log")
649 print(
"Found the following log files:")
652 cmsScimarkDir = glob.glob(repdir +
"cmsScimarkResults_*")
654 print(
"Found the following cmsScimark2 results directories:")
657 cmsScimarkResults = []
658 for adir
in cmsScimarkDir:
659 htmlfiles = glob.glob(adir +
"/*.html")
663 map(cmsScimarkResults.append,htmlfiles)
665 ExecutionDateLast =
"" 668 cmsreg = re.compile(
"^cmsPerfSuite")
669 for logf
in LogFiles:
670 if cmsreg.search(logf):
671 ExecutionDateLastSec = os.stat(logf)[ST_CTIME]
672 ExecutionDateLast = os.stat(logf)[ST_MTIME]
674 print(
"Execution (completion) date for %s was: %s" % (logf,ExecutionDateLast))
675 if (ExecutionDateLastSec > ExecutionDateSec):
676 ExecutionDateSec = ExecutionDateLastSec
677 ExecutionDate = ExecutionDateLast
679 if ExecutionDate ==
"":
680 ExecutionDate = ExecutionDateLast
682 return (ExecutionDate,LogFiles,date,cmsScimarkResults,cmsScimarkDir)
685 RegressTmplHTML=
"%s/doc/regress.html" % (BASE_PERFORMANCE)
686 candnreg = re.compile(
"CandleName")
687 candhreg = re.compile(
"CandlesHere")
689 REGR = open(reghtml,
"w")
690 for line
in open(RegressTmplHTML):
691 if candhreg.search(line):
695 abspath = os.path.join(repdir,outd)
696 if os.path.exists(abspath):
697 html +=
"<tr><td><a href=\"./%s/%s\"><img src=\"./%s/%s\" /></a></td></tr>\n" % (outd,x,outd,x)
699 html +=
"<tr><td> %s does not exist probably because the log file for the previous release was missing</td></tr>" % (abspath)
702 elif candnreg.search(line):
703 REGR.write(CurrentCandle)
706 except IOError
as detail:
707 print(
"ERROR: Could not write regression html %s because %s" % (os.path.basename(reghtml),detail))
710 logreg = re.compile(
"(.*)\.log$")
711 matches = logreg.search(reportName)
712 logdir = logreg.sub(matches.groups()[0],reportName)
713 outd = os.path.join(base,logdir)
714 nologext = matches.groups()[0]
715 return (nologext,outd)
720 x = os.path.basename(x)
721 y = os.path.basename(y)
722 stepreg = re.compile(
"%s_(..*)\.root" % fname)
723 if stepreg.search(x):
724 x = stepreg.search(x).groups()[0]
725 if stepreg.search(y):
726 y = stepreg.search(y).groups()[0]
732 x = os.path.basename(x)
733 y = os.path.basename(y)
734 stepreg = re.compile(
"%s_(..*)_%s" % (candle,prof))
735 if stepreg.search(x):
736 x = stepreg.search(x).groups()[0]
737 if stepreg.search(y):
738 y = stepreg.search(y).groups()[0]
744 x = os.path.basename(x)
745 y = os.path.basename(y)
746 stepreg = re.compile(
"%s_(..*)_%s_regression" % (candle,prof))
747 if stepreg.search(x):
748 x = stepreg.search(x).groups()[0]
749 if stepreg.search(y):
750 y = stepreg.search(y).groups()[0]
756 x = os.path.basename(x)
757 y = os.path.basename(y)
758 stepreg = re.compile(
"%s_(..*)_TimingReport.log" % fname)
759 if stepreg.search(x):
760 x = stepreg.search(x).groups()[0]
761 if stepreg.search(y):
762 y = stepreg.search(y).groups()[0]
768 x = os.path.basename(x)
769 y = os.path.basename(y)
770 stepreg = re.compile(
"%s_(..*)_TimingReport" % fname)
771 if stepreg.search(x):
772 x = stepreg.search(x).groups()[0]
773 if stepreg.search(y):
774 y = stepreg.search(y).groups()[0]
788 for i
in range(len(Step)):
789 stepreg = re.compile(
"^%s.*" % Step[i])
791 if Step[i]
in xstr
and sndbst_x == -1:
793 if Step[i]
in ystr
and sndbst_y == -1:
796 if xstr
in Step[i]
and bestx_idx == -1:
798 if ystr
in Step[i]
and besty_idx == -1:
801 if stepreg.search(xstr)
and x_idx == -1:
803 if stepreg.search(ystr)
and y_idx == -1:
806 if Step[i] == xstr
and x_idx == -1:
808 if Step[i] == ystr
and y_idx == -1:
810 if not ( x_idx == -1
or y_idx == -1):
831 if x_idx == -1
or y_idx == -1:
832 print(
"WARNING: No valid step names could be found in the logfiles or root filenames being sorted: x: %s y: %s." % (xstr,ystr))
833 print(
"x", x_idx,
"y", y_idx)
847 def createCandlHTML(tmplfile,candlHTML,CurrentCandle,WebArea,repdir,ExecutionDate,LogFiles,cmsScimarkResults,date,prevrev):
848 global TimeSizeNumOfEvents,IgProfNumOfEvents,CallgrindNumOfEvents,MemcheckNumOfEvents
849 def _stripbase(base, astr):
850 basereg = re.compile(
"^%s/?(.*)" % base)
852 found = basereg.search(astr)
854 out = found.groups()[0]
857 def _getProfileReportLink(repdir,CurrentCandle,CurDir,step,CurrentProfile,Profiler):
860 ProfileTemplate=os.path.join(repdir,
"%s_%s" % (CurrentCandle,CurDir),
"*_%s_%s*" % (step,CurrentProfile),Profiler)
863 ProfileTemplateLowCaps=os.path.join(repdir,
"%s_%s" % (CurrentCandle,CurDir),
"*_%s_%s*" % (step.lower(),CurrentProfile),Profiler)
864 ProfileReportLink = glob.glob(ProfileTemplate)
871 if len(ProfileReportLink) > 0:
873 if not reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentCandle
in x,ProfileReportLink)):
874 ProfileReportLink = glob.glob(ProfileTemplateLowCaps)
876 ProfileReportLink = glob.glob(ProfileTemplateLowCaps)
877 ProfileReportLink =
map(
lambda x: _stripbase(repdir,x),ProfileReportLink)
879 return ProfileReportLink
881 def _writeReportLink(INDEX,ProfileReportLink,CurrentProfile,step,NumOfEvents,Profiler=""):
883 INDEX.write(
"<li><a href=\"%s\">%s %s (%s events)</a></li>\n" % (ProfileReportLink,CurrentProfile,step,NumOfEvents))
886 if CurrentProfile ==
"memcheck_valgrind":
887 INDEX.write(
"<li><a href=\"%s\">%s %s %s (%s events)</a></li>\n" % (ProfileReportLink,CurrentProfile,Profiler,step,
"5"))
889 INDEX.write(
"<li><a href=\"%s\">%s %s %s (%s events)</a></li>\n" % (ProfileReportLink,CurrentProfile,Profiler,step,NumOfEvents))
890 def IgProfDumpsTable(INDEX,ProfileLinks,step):
892 EndOfJobProfileLink=
filter(
lambda x:
"IgProfMemTotal.res" in x
or "IgProfMemLive.res" in x, ProfileLinks)[0]
894 ProfileLinks.remove(EndOfJobProfileLink)
896 ProfileLinks.sort(key=
lambda x:
int(x.split(
".")[-2]))
898 IgProfMemLive_regexp=re.compile(
"IgProfMemLive")
899 if IgProfMemLive_regexp.search(EndOfJobProfileLink):
900 MemProfile=
"IgProf MEM LIVE" 902 MemProfile=
"IgProf MEM TOTAL" 904 INDEX.write(
"<li>%s"%MemProfile)
905 INDEX.write(
"<table><tr><td>Profile after event</td><td>Total Memory Size (bytes)</td><td>Total Calls (number)</td><td>Link to gzipped IgProf profile</td></tr>")
906 for link
in ProfileLinks:
908 gzProfile=os.path.join(link.split(
"/")[-3],link.split(
"/")[-1])[:-3]+
"gz" 909 if IgProfMemLive_regexp.search(gzProfile):
910 gzProfile=IgProfMemLive_regexp.sub(
r"IgProfMemTotal",gzProfile)
911 INDEX.write(
"<tr><td>%s</td><td>%s</td><td>%s</td><td><a href=%s>%s</a></td></tr>"%(link.split(
".")[-2],open(link,
"r").readlines()[6].split()[1],open(link,"r").readlines()[6].split()[2],gzProfile,os.path.basename(gzProfile))) 913 gzEndOfJobProfileLink=os.path.join(EndOfJobProfileLink.split(
"/")[-3],EndOfJobProfileLink.split(
"/")[-1])[:-3]+
"gz" 914 if IgProfMemLive_regexp.search(gzEndOfJobProfileLink):
915 gzEndOfJobProfileLink=IgProfMemLive_regexp.sub(
r"IgProfMemTotal",gzEndOfJobProfileLink)
916 INDEX.write(
"<tr><td>%s</td><td>%s</td><td>%s</td><td><a href=%s>%s</a></td></tr>"%(
"End of job",open(EndOfJobProfileLink,
"r").readlines()[6].split()[1],open(EndOfJobProfileLink,"r").readlines()[6].split()[2],gzEndOfJobProfileLink,os.path.basename(gzEndOfJobProfileLink))) 918 INDEX.write(
"</table>")
925 DirName[0] : TimeSizeNumOfEvents,
926 DirName[1] : IgProfNumOfEvents,
927 DirName[2] : IgProfNumOfEvents,
928 DirName[3] : IgProfNumOfEvents,
929 DirName[4] : CallgrindNumOfEvents,
930 DirName[5] : MemcheckNumOfEvents,
931 DirName[6] : TimeSizeNumOfEvents,
932 DirName[7] : IgProfNumOfEvents,
933 DirName[8] : IgProfNumOfEvents,
934 DirName[9] : IgProfNumOfEvents,
935 DirName[10] : CallgrindNumOfEvents,
936 DirName[11] : MemcheckNumOfEvents
952 IgProfMemAnalyseOut=(
953 "doBeginJob_output.html",
954 "doEvent_output.html",
958 memcheck_valgrindOut=(
964 Profile[0] :
"*TimingReport.html",
965 Profile[1] :
"TimeReport.html",
966 Profile[2] :
"*.html",
967 Profile[3] :
"objects_pp.html",
968 Profile[4] :
"overall.html",
969 Profile[5] :
"overall.html",
970 Profile[6] :
"overall.html",
971 Profile[7] :
"doBeginJob_output.html",
972 Profile[8] :
"overall.html",
973 Profile[9] :
"beginjob.html" 977 candnreg = re.compile(
"CandleName")
978 candhreg = re.compile(
"CandlesHere")
980 CAND = open(candlHTML,
"w")
981 for line
in open(tmplfile):
982 if candhreg.search(line):
983 CAND.write(
'<div id="content">')
985 CAND.write(CurrentCandle)
986 CAND.write(
"</h2>\n")
989 print(
"Producing candles html: ", CurrentCandle)
991 for CurDir
in DirName:
993 LocalPath = os.path.join(repdir,
"%s_%s" % (CurrentCandle,CurDir))
994 LocalDirname = os.path.basename(LocalPath)
996 if not prevrev ==
"":
1001 if CurDir == DirName[0]
or CurDir == DirName[6]:
1002 profs = Profile[0:4]
1003 elif CurDir == DirName[1]
or CurDir == DirName[7]:
1004 profs = Profile[4:8]
1005 elif CurDir == DirName[2]
or CurDir == DirName[8]:
1007 elif CurDir == DirName[3]
or CurDir == DirName[9]:
1009 elif CurDir == DirName[4]
or CurDir == DirName[10]:
1010 profs = [Profile[8]]
1011 elif CurDir == DirName[5]
or CurDir == DirName[11]:
1012 profs = [Profile[9]]
1017 print(
"Scanning for profile information for: ", prof)
1020 fullprof = (CurrentCandle,prof)
1023 if prof ==
"TimingReport":
1024 timeReports = glob.glob(os.path.join(LocalPath,
"%s_*_%s.log" % (CandFname[CurrentCandle],prof)))
1025 if len(timeReports) > 0:
1027 CAND.write(
"<p><strong>%s %s</strong></p>\n" % (prof,
"Regression Analysis"))
1029 for log
in timeReports:
1030 reportName = os.path.basename(log)
1032 CAND.write(
"<h4>%s</h4>\n" % reportName)
1033 htmNames = [
"changes.png"]
1034 otherNames = [
"graphs.png" ,
"histos.png"]
1035 regressHTML=
"%s-regress.html" % nologext
1036 pathsExist = reduce (
lambda x,y: x
or y,
map(os.path.exists,
map(
lambda x: os.path.join(repdir,outd,x),otherNames)))
1039 html =
"<p>Performance graphs and histograms superimposed for %s are <a href=\"%s\">here</a></p>\n" % (reportName,regressHTML)
1041 html =
"<p>No change in performance graph available</p>\n" 1042 regressHTML=
"%s/%s" % (WebArea,regressHTML)
1045 abspath = os.path.join(repdir,outd,x)
1046 if os.path.exists(abspath):
1047 html +=
"<p><a href=\"./%s/%s\"><img src=\"./%s/%s\" /></a></p>\n" % (outd,x,outd,x)
1049 html +=
"<p>%s does not exist probably because the log file for the previous release was missing</p>" % (abspath)
1053 CAND.write(
"\n</tr></table>")
1056 elif prof ==
"SimpleMemReport":
1057 simMemReports = glob.glob(os.path.join(LocalPath,
"%s_*_%s" % (CandFname[CurrentCandle],prof)))
1058 simMemReports =
map(
lambda x: (CandFname[CurrentCandle],prof,x), simMemReports )
1059 simMemReports.sort(cmp=dirname_cmp)
1060 simMemReports =
map(
lambda x: x[2], simMemReports )
1061 if len(simMemReports) > 0:
1063 CAND.write(
"<p><strong>%s %s</strong></p>\n" % (prof,
"Regression Analysis"))
1065 for adir
in simMemReports:
1066 reportName = os.path.basename(adir)
1067 CAND.write(
"<h4>%s</h4>\n" % reportName)
1068 htmNames = [
"vsize_change.png",
"rss_change.png"]
1069 otherNames = [
"vsize_graphs.png",
"rss_graphs.png"]
1070 nologext = reportName
1072 regressHTML=
"%s-regress.html" % nologext
1073 pathsExist = reduce (
lambda x,y: x
or y,
map(os.path.exists,
map(
lambda x: os.path.join(repdir,LocalDirname,outd,x),otherNames)))
1076 html =
"<p>Superimposed memory performance graphs for %s are <a href=\"%s\">here</a></p>\n" % (reportName,regressHTML)
1078 html =
"<p>No change in performance graph available</p>\n" 1079 regressHTML=
"%s/%s" % (WebArea,regressHTML)
1082 abspath = os.path.join(repdir,LocalDirname,outd,x)
1083 if os.path.exists(abspath):
1084 html +=
"<p><a href=\"./%s/%s/%s\"><img src=\"./%s/%s/%s\" /></a></p>\n" % (LocalDirname,outd,x,LocalDirname,outd,x)
1086 html +=
"<p>%s does not exist probably because the log file for the previous release was missing</p>" % (abspath)
1088 createRegressHTML(regressHTML,repdir,
"%s/%s" % (LocalDirname,outd),CurrentCandle,otherNames)
1090 CAND.write(
"\n</tr></table>")
1092 elif prof ==
"EdmSize" or prof ==
"IgProfMemTotal" or prof ==
"IgProfMemLive" or prof==
"IgProfperf" or prof ==
"Callgrind":
1093 regresPath = os.path.join(LocalPath,
"%s_*_%s_regression" % (CandFname[CurrentCandle],prof))
1094 regresses = glob.glob(regresPath)
1095 stepreg = re.compile(
"%s_([^_]*(_PILEUP)?)_%s_regression" % (CandFname[CurrentCandle],prof))
1096 if len(regresses) > 0:
1098 CAND.write(
"<p><strong>%s %s</strong></p>\n" % (prof,
"Regression Analysis"))
1100 regresses =
map(
lambda x: (CandFname[CurrentCandle],prof,x),regresses)
1101 regresses.sort(cmp=reg_dirname_cmp)
1102 regresses =
map(
lambda x: x[2],regresses)
1103 for rep
in regresses:
1104 base = os.path.basename(rep)
1105 found = stepreg.search(base)
1106 step =
"Unknown-step" 1108 step = found.groups()[0]
1110 if prof ==
"IgProfMemLive" or prof ==
"IgProfMemTotal" or prof==
"IgProfperf" or prof ==
"Callgrind":
1111 htmlpage =
"overall.html" 1113 htmlpage =
"objects_pp.html" 1114 CAND.write(
"<a href=\"%s/%s/%s\">%s %s regression report</a><br/>\n" % (LocalDirname,base,htmlpage,prof,step))
1117 if os.path.exists(LocalPath):
1118 thedir = os.listdir(LocalPath)
1119 CandleLogFiles = [x
for x
in map(
lambda x: os.path.abspath(os.path.join(LocalPath,x)),thedir)
if (x.endswith(
".log")
or x.endswith(
"EdmSize"))
and not os.path.isdir(x)
and os.path.exists(x)]
1121 if (len(CandleLogFiles)>0):
1123 syscp(CandleLogFiles,WebArea +
"/")
1124 base = os.path.basename(LocalPath)
1127 for cand
in CandleLogFiles:
1128 cand = os.path.basename(cand)
1130 print(
"Found %s in %s\n" % (cand,LocalPath))
1132 if not "EdmSize" in cand:
1133 lfileshtml +=
"<a href=\"./%s/%s\">%s </a><br/>" % (base,cand,cand)
1135 CAND.write(
"<p><strong>Logfiles for %s</strong></p>\n" % CurDir)
1136 CAND.write(lfileshtml)
1139 for CurrentProfile
in Profile:
1144 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1148 OutputHtml[CurrentProfile])
1151 isProfinLink =
False 1152 if len (ProfileReportLink) > 0:
1153 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1158 if (PrintedOnce==
False):
1162 CAND.write(
"<p><strong>%s</strong></p>\n" % CurDir)
1163 CAND.write(
"<ul>\n")
1168 if (CurrentProfile == Profile[5]
or CurrentProfile == Profile[6]):
1169 for prolink
in ProfileReportLink:
1170 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir])
1171 for igprofmem
in [
"*IgProfMemTotal*.res",
"*IgProfMemLive*.res"]:
1172 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1177 isProfinLink =
False 1178 if len (ProfileReportLink) > 0:
1179 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1182 IgProfDumpsTable(CAND,ProfileReportLink,step)
1185 elif (CurrentProfile == Profile[7]):
1186 for igprof
in IgProfMemAnalyseOut:
1187 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1192 isProfinLink =
False 1193 if len (ProfileReportLink) > 0:
1194 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1196 for prolink
in ProfileReportLink:
1197 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir],Profiler=igprof)
1200 elif (CurrentProfile == Profile[9]):
1202 for memprof
in memcheck_valgrindOut:
1204 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1210 isProfinLink =
False 1211 if len (ProfileReportLink) > 0:
1212 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1214 for prolink
in ProfileReportLink:
1215 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir],Profiler=memprof)
1218 for prolink
in ProfileReportLink:
1219 if "regression" not in prolink:
1220 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir])
1225 CAND.write(
"</ul>\n")
1228 CAND.write(
"<hr />")
1229 CAND.write(
"<br />\n")
1230 CAND.write(
"</div>\n")
1231 elif candnreg.search(line):
1232 CAND.write(CurrentCandle)
1237 except IOError
as detail:
1238 print(
"ERROR: Could not write candle html %s because %s" % (os.path.basename(candlHTML),detail))
1243 for cand
in Candles:
1244 fname = CandFname[cand]
1245 globpath = os.path.join(repdir,
"%s_TimeSize" % cand,
"%s_*_TimingReport" % fname)
1246 stepDirs = glob.glob(globpath)
1247 stepDirs =
map(
lambda x: (fname,x), stepDirs)
1248 stepDirs.sort(cmp=timerep_cmp)
1249 stepDirs =
map(
lambda x: x[1], stepDirs)
1250 stepreg = re.compile(
"%s_(.*)_TimingReport" % fname)
1255 for stepdir
in stepDirs:
1256 base = os.path.basename(stepdir)
1257 found = stepreg.search(base)
1258 step =
"Unknown-step" 1260 step = found.groups()[0]
1261 realstep =
"Unknown-step" 1262 if "PILEUP" in step:
1263 found = pureg.search(step)
1265 realstep = found.groups()[0]
1269 rootf = os.path.join(stepdir,rootfile)
1271 if os.path.exists(rootf):
1272 f = ROOT.TFile(rootf)
1274 cpu_time_tree = ROOT.TTree()
1275 f.GetObject(
"cpu_time_tuple;1",cpu_time_tree)
1277 if cpu_time_tree.InheritsFrom(
"TTree"):
1280 for t
in cpu_time_tree:
1285 createNewRow =
False 1286 curRow = table.newRow(cand)
1287 data_tuple = (data1,data2)
1289 if "PILEUP" in step:
1290 puRow.addEntry(realstep,data_tuple)
1293 createNewRow =
False 1294 curRow = table.newRow(cand)
1296 curRow.addEntry(step,data_tuple)
1301 table.addRow(puRow,
"%s PILEUP" %cand)
1306 cols = len(ordered_keys)
1307 totcols = (cols * 3) + 1
1309 colspan = totcols - 1
1312 labels = [
"fs1",
"fs2",
"Δ"]
1313 elif mode == 2
or mode == 3:
1317 labels = [
"t1" ,
"t2" ,
"Δ"]
1320 INDEX.write(
"<h3>%s</h3>\n" % header)
1321 INDEX.write(
"<table>\n")
1322 INDEX.write(
"<caption>%s</caption>\n" % caption)
1323 INDEX.write(
"<thead><tr><th></th><th colspan=\"%s\" scope=\"colgroup\">%s</th></tr></thead>" % (colspan,name))
1324 INDEX.write(
"<tbody>\n")
1325 for key
in ordered_keys:
1328 INDEX.write(
"<th></th>")
1330 INDEX.write(
"<td scope=\"row\">")
1332 INDEX.write(
"</td>")
1333 for col
in table_dict[
None]:
1335 INDEX.write(
"<th colspan=\"%s\" scope=\"col\">" % innercol)
1337 INDEX.write(
"</th>")
1339 rowdict = table_dict[key].getRowDict()
1344 INDEX.write(
"%s" % dat)
1345 INDEX.write(
"</td>")
1350 INDEX.write(
"%6.2f" % dat)
1351 INDEX.write(
"</td>")
1353 (data1, data2) = rowdict[col]
1354 diff = data2 - data1
1361 seq = [ data1, data2, diff ]
1363 INDEX.write(
"<td id=\"data\">")
1365 INDEX.write(
"%s" % dat)
1367 INDEX.write(
"%6.2f" % dat)
1369 INDEX.write(
"</td>")
1371 if mode == 2
or mode == 3:
1374 INDEX.write(
"</td>")
1379 INDEX.write(
"</td>")
1380 INDEX.write(
"</tr>\n")
1383 if not (mode == 2
or mode == 3 ):
1386 INDEX.write(
"<th>Candles</th>")
1387 for col
in table_dict[
None]:
1388 INDEX.write(
"<th>%s</th>" % labels[0])
1389 INDEX.write(
"<th>%s</th>" % labels[1])
1390 INDEX.write(
"<th>%s</th>" % labels[2])
1391 INDEX.write(
"</tr>\n")
1392 INDEX.write(
"</tbody></table>\n")
1394 INDEX.write(
"<br />")
1397 '''Publish all IgProf files into one remote directory (new naming convention). Can publish to AFS location or to a local directory on a remote (virtual) machine.''' 1400 if ":" in remotedir:
1401 (host,dir)=remotedir.split(
":")
1402 mkdir_cmd=
"ssh %s (mkdir %s;mkdir %s/%s)"%(host,dir,dir,arch)
1404 mkdir_cmd=
"mkdir %s;mkdir %s/%s"%(remotedir,remotedir,arch)
1409 os.system(mkdir_cmd)
1410 print(
"Successfully created publication directory")
1412 print(
"Issues with publication directory existence/creation!")
1417 if ":" in remotedir:
1418 tarpipe_cmd=
'tar cf - *_IgProf_*/*.sql3 | ssh %s "cd %s/%s; mkdir %s; cd %s; tar xf -; mv *_IgProf_*/*.sql3 .; rmdir *_IgProf_*"'%(host,dir,arch,version,version)
1420 tarpipe_cmd=
'tar cf - *_IgProf_*/*.sql3 | (cd %s/%s; mkdir %s; cd %s; tar xf -; mv *_IgProf_*/*.sql3 .; rmdir *_IgProf_*)'%(remotedir,arch,version,version)
1425 os.system(tarpipe_cmd)
1426 print(
"Successfully copied IgProf reports to %s"%remotedir)
1428 print(
"Issues with rsyncing to the remote directory %s!"%remotedir)
1431 if ":" in remotedir:
1432 chmod_cmd=
"ssh %s chmod -R 775 %s/%s"%(host,dir,arch)
1434 chmod_cmd=
"chmod -R 775 %s/%s"%(remotedir,arch)
1437 os.system(chmod_cmd)
1438 print(
"Successfully set permissions for IgProf reports directory %s"%remotedir)
1440 print(
"(Potential) issues with chmoding the remote directory %s!"%remotedir)
1455 CmsDriverCandle = CandFname
1459 IndexFile=
"%s/index.html" % WebArea
1460 TemplateHtml=
"%s/doc/index.html" % BASE_PERFORMANCE
1462 cmsverreg = re.compile(
"CMSSW_VERSION")
1463 hostreg = re.compile(
"HOST")
1464 lpathreg = re.compile(
"LocalPath")
1465 fsizereg = re.compile(
"FSizeTable")
1466 cpureg = re.compile(
"CPUTable")
1467 proddreg = re.compile(
"ProductionDate")
1468 logfreg = re.compile(
"LogfileLinks")
1469 dirbreg = re.compile(
"DirectoryBrowsing")
1470 pubdreg = re.compile(
"PublicationDate")
1471 candhreg = re.compile(
"CandlesHere")
1475 CandlTmpltHTML=
"%s/doc/candle.html" % BASE_PERFORMANCE
1477 print(
"Copying %s/doc/perf_style.css style file to %s/." % (BASE_PERFORMANCE,WebArea))
1478 print(
"Template used: %s" % TemplateHtml)
1480 syscp((BASE_PERFORMANCE +
"/doc/perf_style.css"),WebArea +
"/.")
1481 pureg = re.compile(
"(.*)_PILEUP")
1483 INDEX = open(IndexFile,
"w")
1484 for NewFileLine
in open(TemplateHtml) :
1485 if cmsverreg.search(NewFileLine):
1487 INDEX.write(
"Performance Reports for %s\n" % CMSSW_VERSION)
1489 globpath = os.path.join(repdir,
"REGRESSION.%s.vs.*" % (prevrev))
1490 globs = glob.glob(globpath)
1494 latestreg = re.compile(
"REGRESSION.%s.vs.(.*)" % prevrev)
1495 found = latestreg.search(os.path.basename(globs[0]))
1497 latestrel = found.groups()[0]
1498 INDEX.write(
"Performance Reports with regression: %s VS %s\n" % (prevrev,latestrel))
1500 INDEX.write(
"Performance Reports with regression: %s VS %s\n" % (prevrev,CMSSW_VERSION))
1501 elif hostreg.search(NewFileLine):
1502 INDEX.write(HOST +
"\n")
1504 elif fsizereg.search(NewFileLine):
1509 for cand
in Candles:
1510 fname = CandFname[cand]
1511 globpath = os.path.join(repdir,
"%s*_TimeSize" % cand,
"%s_*.root" % fname)
1512 rootfiles = glob.glob(globpath)
1513 rootfiles =
map(
lambda x: (fname,x), rootfiles)
1514 rootfiles.sort(cmp=rootfile_cmp)
1515 rootfiles =
map(
lambda x: x[1], rootfiles)
1516 stepreg = re.compile(
"%s_(.*).root" % fname)
1521 for rootf
in rootfiles:
1522 base = os.path.basename(rootf)
1523 found = stepreg.search(base)
1524 step =
"Unknown-step" 1526 step = found.groups()[0]
1527 realstep =
"Unknown-step" 1528 if "PILEUP" in step:
1529 found = pureg.search(step)
1531 realstep = found.groups()[0]
1534 puRow =
Row(fsize_tab)
1536 statinfo = os.stat(rootf)
1537 fsize = statinfo.st_size
1539 createNewRow =
False 1540 curRow = fsize_tab.newRow(cand)
1542 if "PILEUP" in step:
1543 puRow.addEntry(realstep,fsize)
1546 createNewRow =
False 1547 curRow = fsize_tab.newRow(cand)
1549 curRow.addEntry(step,fsize)
1550 except IOError
as detail:
1552 except OSError
as detail:
1557 fsize_tab.addRow(puRow,
"%s PILEUP" %cand)
1558 (ordered_keys,table_dict) = fsize_tab.getTable(1)
1559 cols = len(ordered_keys)
1561 if len(table_dict) > 1
and cols > 0:
1563 "Release ROOT file sizes",
1564 "Table showing current release ROOT filesizes in (k/M/G) bytes.",
1569 globpath = os.path.join(repdir,
"REGRESSION.%s.vs.*" % (prevrev))
1570 globs = glob.glob(globpath)
1572 raise IOError(2,globpath,
"File does not exist",
"File does not exist")
1573 idfile = open(globs[0])
1577 oldpath = oldpath.strip()
1581 for cand
in Candles:
1582 fname = CandFname[cand]
1583 globpath = os.path.join(repdir,
"%s*_TimeSize" % cand,
"%s_*.root" % fname)
1584 rootfiles = glob.glob(globpath)
1585 rootfiles =
map(
lambda x: (fname,x), rootfiles)
1586 rootfiles.sort(cmp=rootfile_cmp)
1587 rootfiles =
map(
lambda x: x[1], rootfiles)
1588 stepreg = re.compile(
"%s_(.*).root" % fname)
1593 for rootf
in rootfiles:
1594 base = os.path.basename(rootf)
1595 found = stepreg.search(base)
1596 step =
"Unknown-step" 1598 step = found.groups()[0]
1600 realstep =
"Unknown-step" 1601 if "PILEUP" in step:
1602 found = pureg.search(step)
1604 realstep = found.groups()[0]
1607 puRow =
Row(fsize_tab)
1609 statinfo = os.stat(rootf)
1610 fsize2 = statinfo.st_size
1611 oldfile = os.path.join(oldpath,
"%s_TimeSize" % cand,base)
1612 if "PILEUP" in step:
1613 oldfile = os.path.join(oldpath,
"%s_PU_TimeSize" % cand,base)
1616 if os.path.exists(oldfile):
1617 statinfo = os.stat(oldfile)
1618 fsize1 = statinfo.st_size
1620 print(
"######DID NOT FIND Previous file (needed for the filesize table): %s"%oldfile)
1623 createNewRow =
False 1624 curRow = fsize_tab.newRow(cand)
1626 data_tuple = (fsize1,fsize2)
1627 if "PILEUP" in step:
1628 puRow.addEntry(realstep,data_tuple)
1631 createNewRow =
False 1632 curRow = fsize_tab.newRow(cand)
1634 curRow.addEntry(step,data_tuple)
1635 except IOError
as detail:
1637 except OSError
as detail:
1642 fsize_tab.addRow(puRow,
"%s PILEUP" %cand)
1644 (ordered_keys,table_dict) = fsize_tab.getTable()
1645 cols = len(ordered_keys)
1647 if len(table_dict) > 1
and cols > 0:
1649 "Release ROOT file sizes",
1650 "Table showing previous release ROOT filesizes, fs1, latest sizes, fs2, and the difference between them Δ in (k/M/G) bytes.",
1652 except IOError
as detail:
1654 except OSError
as detail:
1657 elif cpureg.search(NewFileLine):
1662 for cand
in Candles:
1663 fname = CandFname[cand]
1664 globpath = os.path.join(repdir,
"%s*_TimeSize" % cand,
"%s_*_TimingReport.log" % fname)
1665 logfiles = glob.glob(globpath)
1666 logfiles =
map(
lambda x: (fname,x), logfiles)
1667 logfiles.sort(cmp=logrep_cmp)
1668 logfiles =
map(
lambda x: x[1], logfiles)
1670 stepreg = re.compile(
"%s_(.*)_TimingReport.log" % fname)
1675 for log
in logfiles:
1676 base = os.path.basename(log)
1677 found = stepreg.search(base)
1678 step =
"Unknown-step" 1680 step = found.groups()[0]
1682 realstep =
"Unknown-step" 1683 if "PILEUP" in step:
1684 found = pureg.search(step)
1686 realstep = found.groups()[0]
1689 puRow =
Row(time_tab)
1691 data = cpr.getTimingLogData(log)
1694 for evtnum, time
in data:
1698 mean = mean /
float(i)
1699 except ZeroDivisionError
as detail:
1700 print(
"WARNING: Could not calculate mean CPU time from log because no events could be parsed", log)
1702 if "PILEUP" in step:
1703 puRow.addEntry(realstep,mean)
1706 createNewRow =
False 1707 curRow = time_tab.newRow(cand)
1709 curRow.addEntry(step,mean)
1713 time_tab.addRow(puRow,
"%s PILEUP" %cand)
1715 (ordered_keys,table_dict) = time_tab.getTable(1)
1716 cols = len(ordered_keys)
1718 if len(table_dict) > 1
and cols > 0:
1720 "Release CPU times",
1721 "Table showing current release CPU times in secs.",
1739 (ordered_keys,table_dict) = cpu_time_tab.getTable()
1741 cols = len(ordered_keys)
1742 if len(table_dict) > 1
and cols > 0:
1744 "Release CPU times",
1745 "Table showing previous release CPU times, t1, latest times, t2, and the difference between them Δ in secs.",
1750 elif lpathreg.search(NewFileLine):
1751 INDEX.write(repdir +
"\n")
1752 elif proddreg.search(NewFileLine):
1753 INDEX.write(ExecutionDate +
"\n")
1754 elif logfreg.search(NewFileLine):
1755 INDEX.write(
"<br />\n")
1756 for log
in LogFiles:
1757 log = os.path.basename(log)
1759 print(
"linking log file %s" % log)
1760 INDEX.write(
"<a href=\"./%s\"> %s </a>" % (log,log))
1761 INDEX.write(
"<br />\n")
1763 INDEX.write(
"Results for cmsScimark2 benchmark (running on the other cores) available at:\n")
1764 for cmssci
in cmsScimarkResults:
1765 scimarkdirs=cmssci.split(
"/")
1766 localdir=scimarkdirs[-2]
1768 cmssci = os.path.basename(cmssci)
1769 relativelink=os.path.join(localdir,cmssci)
1771 INDEX.write(
"<a href=\"%s\"> %s </a>" % (relativelink,cmssci))
1772 INDEX.write(
"<br />\n")
1775 elif dirbreg.search(NewFileLine):
1783 INDEX.write(
"Click <a href=\"./DirectoryBrowsing/\">here</a> to browse the directory containing all results (except the root files)\n")
1785 elif pubdreg.search(NewFileLine):
1786 INDEX.write(date +
"\n")
1787 elif candhreg.search(NewFileLine):
1788 for acandle
in Candle:
1789 globpath = os.path.join(repdir,
"%s_*" % acandle)
1790 globs = glob.glob(globpath)
1792 candlHTML =
"%s.html" % acandle
1793 INDEX.write(
"<a href=\"./%s\"> %s </a>" % (candlHTML,acandle))
1794 INDEX.write(
"<br />\n")
1796 candlHTML=os.path.join(WebArea,candlHTML)
1797 createCandlHTML(CandlTmpltHTML,candlHTML,acandle,WebArea,repdir,ExecutionDate,LogFiles,cmsScimarkResults,date,prevrev)
1799 INDEX.write(NewFileLine)
1803 except IOError
as detail:
1804 print(
"Error: Could not create index Html file for some reason, check position. Details : %s" % detail)
1811 Dir = os.listdir(repdir)
1812 def _containsDirName(elem):
1813 return reduce(
lambda x,y: x
or y,
map(
lambda x: x
in elem, DirName))
1814 def _print4Lambda(elem,WebArea):
1816 print(
"Copying %s to %s\n" % (elem,WebArea))
1818 dirstocp = [x
for x
in map(
lambda x: repdir + x,Dir)
if _containsDirName(x)]
1819 map(
lambda x: _print4Lambda(x,WebArea),dirstocp)
1820 syscp(dirstocp,WebArea +
"/")
1821 os.mkdir(
"%s/DirectoryBrowsing" % WebArea)
1822 for file
in os.listdir(WebArea):
1823 if file !=
"index.html":
1825 os.symlink(
"%s/%s"%(
"..",file),
"%s/DirectoryBrowsing/%s" % (WebArea,file))
1836 args =
"--port=%s %s %s:%s" % (port,os.path.normpath(stage),drive,path)
1839 print(cmd +
" --dry-run " + args)
1840 retval = os.system(cmd +
" --dry-run " + args )
1843 retval = os.system(cmd +
" " + args)
1850 if os.path.exists(TMP_DIR)
and IS_TMP:
1851 os.system(
"rm -Rf " + TMP_DIR)
1858 def _walkpath(path):
1861 head , tail = os.path.split(path)
1866 for i
in range(len(dirs)-1,-1,-1):
1870 pwalk = _walkpath(parent)
1876 except StopIteration:
1882 cwalk = _walkpath(child)
1887 except StopIteration:
1888 print(
"ERROR: Unable to determine relative dir")
1894 relpath=os.path.join(relpath,
next(cwalk))
1895 except StopIteration:
1902 except OSError
as detail:
1903 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1904 except IOError
as detail:
1905 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1908 print(
"Copied %s to %s" % (src,dest))
1911 def _getNewLocation(source,child,dst,keepTop=keepTop):
1913 return os.path.join(dst,place)
1914 def _copyFilter(source,dst,curdir,fsnodes,filter,dirs=False):
1915 for node
in fsnodes:
1917 filterExist =
not len(filter) == 0
1919 dontFilter =
not reduce(
lambda x,y: x
or y,
map(
lambda x: fnmatch.fnmatch(node,x),filter))
1921 node = os.path.join(curdir,node)
1923 newnode = _getNewLocation(source,node,dst)
1928 except IOError
as detail:
1929 print(
"WARNING: Could not copy %s to %s because %s" % (node,newnode,detail))
1930 except OSError
as detail:
1931 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1932 except ReldirExcept:
1933 print(
"WARNING: Could not determine new location for source %s into destination %s" % (source,dst))
1937 match = fnmatch.fnmatch(node,filter[0])
1939 except AssertionError
as detail:
1940 print(node, filter[0], match)
1944 print(
"Filter %s Copied %s to %s" % (dontFilter,node,newnode))
1945 print(
"fnmatch %s" % fnmatch.fnmatch(node,cpFileFilter[0]))
1949 newloc = _getNewLocation(src,src,dest)
1959 _copyFilter(src,dest,curdir,dirs,cpDirFilter,dirs=
True)
1960 _copyFilter(src,dest,curdir,files,cpFileFilter)
1962 except StopIteration:
1964 except IOError
as detail:
1965 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1966 except OSError
as detail:
1967 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1968 except ReldirExcept:
1969 print(
"WARNING: Could not determine the new location for source %s into destination %s" % (src,dest))
1972 if isinstance(srcs, type(
"")):
1973 if os.path.exists(srcs):
1974 if os.path.isdir(srcs):
1979 print(
"ERROR: file to be copied %s does not exist" % foo)
1982 if os.path.exists(src):
1983 if os.path.isdir(src):
1989 print(
"ERROR: file to be copied %s does not exist" % foo)
1992 print(
"%s\n" % PROG_NAME)
1994 if __name__ ==
"__main__":
def optionparse()
Option parser.
def addRow(self, row, name)
S & print(S &os, JobReport::InputFile const &f)
def getArchVersionFromLog(logfile)
def stageIgProfReports(remotedir, arch, version)
def reg_dirname_cmp(x, y)
def copytree4(src, dest, keepTop=True)
def get_environ()
Get require environment variables.
def syncToRemoteLoc(stage, drive, path, port)
Upload stage to remote location.
def scanReportArea(repdir)
Scan report area for required things.
def getOutputNames(base, reportName)
def createRegressHTML(reghtml, repdir, outd, CurrentCandle, htmNames)
def addtrailingslash(adir)
def getStageRepDirs(options, args)
Determine locations of staging and report dirs.
def createCandlHTML(tmplfile, candlHTML, CurrentCandle, WebArea, repdir, ExecutionDate, LogFiles, cmsScimarkResults, date, prevrev)
Create HTML pages for candles.
def getTable(self, mode=0)
def getNumOfEventsFromLog(logfile)
def addEntry(self, colname, value)
def createHTMLtab(INDEX, table_dict, ordered_keys, header, caption, name, mode=0)
def delTmpDir()
Delete tmp dir if we used it.
def createWebReports(WebArea, repdir, ExecutionDate, LogFiles, cmsScimarkResults, date, prevrev)
Create web report index and create HTML file for each candle.
def __init__(self, table)
def populateFromTupleRoot(tupname, repdir, rootfile, pureg)
def getRelativeDir(parent, child, keepTop=True)
Some functions used for copying.
def getDirnameDirs(repdir, WebArea)
Grab dirs that end in strings defined in DirName.