14 import tempfile
as tmp
15 import optparse
as opt
16 import cmsPerfRegress
as cpr
17 import re, os, sys, time, glob, socket, fnmatch
18 from shutil
import copy2, copystat
20 from cmsPerfCommons
import CandFname, Step, ProductionSteps, Candles
24 from functools
import reduce
26 PROG_NAME = os.path.basename(sys.argv[0])
27 DEF_RELVAL =
"/afs/cern.ch/cms/sdt/web/performance/RelVal" 28 DEF_SIMUL =
"/afs/cern.ch/cms/sdt/web/performance/simulation" 30 cpFileFilter = (
"*.root", )
33 TimeSizeNumOfEvents = -9999
34 IgProfNumOfEvents = -9999
35 CallgrindNumOfEvents = -9999
36 MemcheckNumOfEvents = -9999
54 Steps=set(Step+ProductionSteps+[
"GEN,FASTSIM",
"GEN,FASTSIM_PILEUP"])
63 "Relative directory could not be determined" 71 trail = re.compile(
"/$")
72 if os.path.isdir(adir)
and not trail.search(adir):
82 return subprocess.Popen(cmd,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().
strip()
89 return subprocess.Popen(command,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().
strip()
95 suffixes = [(
"B",2**10), (
"k",2**20), (
"M",2**30), (
"G",2**40), (
"T",2**50)]
96 for suf, lim
in suffixes:
101 return "-" + round(size/
float(lim/2**10),2).
__str__() + suf
115 self.table._newCol(colname)
130 out +=
"\n" + self.
rows 137 self.colNames.append(name)
143 if name
in self.rows.keys():
146 self.keys.append(name)
149 return self.
rows[name]
154 for key
in self.
keys:
160 rowobj = self.
rows[key]
161 rowdict = rowobj.getRowDict()
165 elif col
in rowdict
and not col == name:
167 total1 += rowdict[col]
169 (step_tot1, step_tot2) = rowdict[col]
173 rowobj.addEntry(name,total1)
175 rowobj.addEntry(name,(total1,total2))
180 if name
in self.rows.keys():
183 self.keys.append(name)
184 self.
rows[name] = row
188 for col
in self.colnames:
189 rowobj = transp.newRow(col)
190 for key
in self.
keys:
194 row_dict = self.
rows[key].getRowDict()
196 rowobj.addEntry(key,row_dict[col])
204 global TimeSizeNumOfEvents,IgProfNumOfEvents,CallgrindNumOfEvents,MemcheckNumOfEvents
207 def _copyReportsToStaging(repdir,LogFiles,cmsScimarkDir,stage):
208 """Use function syscp to copy LogFiles and cmsScimarkDir over to staging area""" 210 print "Copying the logfiles to %s/." % stage
211 print "Copying the cmsScimark2 results to the %s/." % stage
213 syscp(LogFiles , stage +
"/")
214 syscp(cmsScimarkDir, stage +
"/")
217 def _createLogFile(LogFile,date,LocalPath,ShowTagsResult):
218 """Creating a small logfile with basic publication script running information (never used really by other scripts in the suite).""" 220 LOG = open(LogFile,
"w")
222 print "Writing Production Host, Location, Release and Tags information in %s" % LogFile
223 LOG.write(
"These performance tests were executed on host %s and published on %s" % (HOST,date))
224 LOG.write(
"They were run in %s" % LocalPath)
225 LOG.write(
"Results of showtags -r in the local release:\n%s" % ShowTagsResult)
227 except IOError
as detail:
228 print "WARNING: Can't create log file" 236 print "\n Getting Environment variables..." 243 print "\n Determining locations for input and staging..." 244 (drive,path,remote,stage,port,repdir,prevrev,igprof_remotedir) =
getStageRepDirs(options,args)
247 print "\n Getting the number of events for each test..." 249 cmsPerfSuiteLogfile=
"%s/cmsPerfSuite.log"%repdir
251 if os.path.exists(cmsPerfSuiteLogfile):
253 (TimeSizeNumOfEvents,IgProfNumOfEvents,CallgrindNumOfEvents,MemcheckNumOfEvents)=
getNumOfEventsFromLog(cmsPerfSuiteLogfile)
258 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
259 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!" 260 print "For now taking the default values for all tests (0)!" 262 print "\n Scan report directory..." 264 (ExecutionDate,LogFiles,date,cmsScimarkResults,cmsScimarkDir) =
scanReportArea(repdir)
265 print "cmsScimarkResults are %s"%cmsScimarkResults
266 print "\n Copy report files to staging directory..." 268 _copyReportsToStaging(repdir,LogFiles,cmsScimarkDir,stage)
270 print "\n Creating log file..." 272 _createLogFile(
"%s/ProductionLog.txt" % stage,date,repdir,ShowTagsResult)
275 for dirname
in os.listdir(repdir):
276 if "IgProf" in dirname:
277 print "\n Handling IgProf reports..." 281 print "\n Creating HTML files..." 283 createWebReports(stage,repdir,ExecutionDate,LogFiles,cmsScimarkResults,date,prevrev)
285 print "\n Copy profiling logs to staging directory..." 291 print "\n Uploading web report to remote location..." 293 print "\n Finished uploading! Now removing staging directory..." 296 print "\n Finished!!!" 303 global CMSSW_VERSION, CMSSW_RELEASE_BASE, CMSSW_BASE, HOST, USER, BASE_PERFORMANCE, CMSSW_WORK
304 global DEF_RELVAL, DEF_SIMUL
307 CMSSW_VERSION=os.environ[
'CMSSW_VERSION']
308 CMSSW_RELEASE_BASE=os.environ[
'CMSSW_RELEASE_BASE']
309 CMSSW_BASE=os.environ[
'CMSSW_BASE']
310 HOST=os.environ[
'HOST']
311 USER=os.environ[
'USER']
312 CMSSW_WORK = os.path.join(CMSSW_BASE,
"work/Results")
313 except KeyError
as detail:
314 fail(
"ERROR: Could not retrieve some necessary environment variables. Have you ran scramv1 runtime -csh yet?. Details: %s" % detail)
320 PerformancePkg=
"%s/src/Validation/Performance" % CMSSW_BASE
321 if (os.path.exists(PerformancePkg)):
322 BASE_PERFORMANCE=PerformancePkg
323 print "**Using LOCAL version of Validation/Performance instead of the RELEASE version**" 325 BASE_PERFORMANCE=
"%s/src/Validation/Performance" % CMSSW_RELEASE_BASE
327 return (LocalPath,ShowTagsResult)
333 global PROG_NAME, _debug, _dryrun, _verbose
335 parser = opt.OptionParser(usage=(
"""%s [HOST:]DEST_PATH [Options] 338 [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) 341 Publish report to default local directory 343 Publish report to \"/some/local/dir\" 345 Publish report to \"/some/other/dir\" remote host \"hal.cern.ch\" 346 ./%s hal.cern.ch:/some/other/dir 347 Publish report to default relval location (this could be remote or local depending on the hardcoded default) 349 % ( PROG_NAME, PROG_NAME, PROG_NAME, PROG_NAME, PROG_NAME)))
351 devel = opt.OptionGroup(parser,
"Developer Options",
352 "Caution: use these options at your own risk." 353 "It is believed that some of them bite.\n")
358 help=
'Use the default RelVal location',
367 help=
'output more information',
375 help=
'Use the default simulation location',
383 help=
'The override the name of the previous release. Default is the string obtain from the identification file REGRESSION.<prevrel>.vs.<newrel>',
392 help=
'The location of the report files to be published',
401 help=
'Use a particular port number to rsync material to a remote server',
408 default=
'IgProfData',
410 help=
'Specify an AFS or host:mydir remote directory instead of default one',
411 metavar=
'<IGPROF REMOTE DIRECTORY>' 419 help=
'Show debug output',
427 help=
'Do not send files to remote server, but run everything else',
431 repdirdef = os.getcwd()
432 parser.set_defaults(debug=0,simulation=
False,relval=
False,port=873,pretend=
False,repdir=repdirdef,verbose=
False)
433 parser.add_option_group(devel)
435 (options, args) = parser.parse_args()
437 _debug = options.debug
438 _dryrun = options.dryrun
439 _verbose = options.verbose
441 numofargs = len(args)
443 if (options.simulation
and options.relval)
or ((options.simulation
or options.relval)
and numofargs >= 1):
444 parser.error(
"You can not specify simulation and relval together. Neither can you specify simulation or relval AND a path")
447 return (options, args)
452 '''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!''' 453 log=open(logfile,
"r") 462 if 'TimeSizeEvents' in line
and not TimeSizeEvents:
463 lineitems=line.split()
464 TimeSizeEvents=lineitems[lineitems.index(
'TimeSizeEvents')+1]
465 if 'IgProfEvents' in line
and not IgProfEvents:
466 lineitems=line.split()
467 IgProfEvents=lineitems[lineitems.index(
'IgProfEvents')+1]
468 if 'CallgrindEvents' in line
and not CallgrindEvents:
469 lineitems=line.split()
470 CallgrindEvents=lineitems[lineitems.index(
'CallgrindEvents')+1]
471 if 'MemcheckEvents' in line
and not MemcheckEvents:
472 lineitems=line.split()
473 MemcheckEvents=lineitems[lineitems.index(
'MemcheckEvents')+1]
474 return (TimeSizeEvents,IgProfEvents,CallgrindEvents,MemcheckEvents)
477 '''Another very fragile function to get the architecture and the CMSSW version parsing the logfile...''' 478 log=open(logfile,
"r") 479 arch=re.compile("^Current Architecture is")
480 version=re.compile(
"^Current CMSSW version is")
481 CMSSW_arch=
"UNKNOWN_ARCH" 482 CMSSW_version=
"UNKNOWN_VERSION" 484 if arch.search(line):
485 CMSSW_arch=line.split()[3]
486 if version.search(line):
487 CMSSW_version=line.split()[4]
488 return(CMSSW_arch,CMSSW_version)
496 global TMP_DIR, IS_TMP, DEF_LOCAL, CMSSW_VERSION
497 DEF_LOCAL = CMSSW_WORK
498 numofargs = len(args)
500 repdir = os.path.abspath(options.repdir)
503 if not os.path.exists(repdir):
504 fail(
"ERROR: The specified report directory %s to retrieve report information from does not exist, exiting" % repdir)
506 previousrev = options.previousrev
507 if previousrev ==
"":
508 regressfiles = glob.glob(
"%s/REGRESSION.*.vs.*" % repdir)
509 if not len(regressfiles) == 0:
510 regressID = regressfiles[0]
511 base = os.path.basename(regressID)
512 split = base.split(
".")
513 previousrev = split[1]
514 currentrel = split[3]
515 print "Regression Identification file exists, renaming report title for regression report. Old ver: %s" % previousrev
517 print "No regression ID file exists and previous release name was not specified. Producing normal report." 519 print "Previous release name was specified, renaming report title for regression report. Old ver %s" % previousrev
523 if options.simulation:
544 drive, path = uri.split(
":",1)
549 path = os.path.abspath(path)
550 remote =
not drive ==
"" 555 socket.getaddrinfo(drive,53)
557 except socket.gaierror:
563 socket.gethostbyaddr(drive)
565 except socket.gaierror:
568 print "ERROR: Can not determine your hostname or ipv{4,6} address %s" % drive
569 if not (_dryrun
or _test):
572 if (
not remote)
and (
not options.port == 873) :
573 print "WARNING: Can not use a port if not performing a remote copy, ignoring" 582 localExists = os.path.exists(
"%s/%s" % (CMSSW_WORK,CMSSW_VERSION))
587 TMP_DIR=tmp.mkdtemp(prefix=
"/build/%s" % PROG_NAME)
588 StagingArea = TMP_DIR
590 elif defaultlocal
and localExists:
591 TMP_DIR=tmp.mkdtemp(prefix=
"%s/%s" % (CMSSW_WORK,CMSSW_VERSION))
592 StagingArea = TMP_DIR
593 print "WARNING: %s already exists, creating a temporary staging area %s" % (CMSSW_WORK,TMP_DIR)
596 StagingArea = CMSSW_WORK
598 os.mkdir(os.path.join(CMSSW_BASE,
"work"))
599 os.mkdir(os.path.join(CMSSW_BASE,
"work",
"Results"))
602 print "**User did not specify location of results, staging in default %s**" % StagingArea
604 print "**User chose to publish results in a local directory**" 606 if not os.path.exists(path):
608 os.mkdir(
"%s" % path)
609 except OSError
as detail:
610 if detail.errno == 13:
611 fail(
"ERROR: Failed to create staging area %s because permission was denied " % StagingArea)
612 elif detail.errno == 17:
616 fail(
"ERROR: There was some problem (%s) when creating the staging directory" % detail)
618 IS_TMP =
not TMP_DIR ==
"" 624 StagingArea=
"%s/%s" % (StagingArea,CMSSW_VERSION)
626 os.mkdir(
"%s" % StagingArea)
627 except OSError
as detail:
628 if detail.errno == 13:
629 fail(
"ERROR: Failed to create staging area %s because permission was denied " % StagingArea)
630 elif detail.errno == 17:
634 fail(
"ERROR: There was some problem (%s) when creating the staging directory" % detail)
636 return (drive,path,remote,StagingArea,port,repdir,previousrev,options.ig_remotedir)
643 """Scans the working directory for cms*.logs (cmsPerfSuite.log and cmsScimark*.log, and cmsScimark results. 644 It returns Execution date (completion), current date, list of logfiles and cmsScimark results""" 646 LogFiles = glob.glob(repdir +
"cms*.log")
648 print "Found the following log files:" 651 cmsScimarkDir = glob.glob(repdir +
"cmsScimarkResults_*")
653 print "Found the following cmsScimark2 results directories:" 656 cmsScimarkResults = []
657 for adir
in cmsScimarkDir:
658 htmlfiles = glob.glob(adir +
"/*.html")
662 map(cmsScimarkResults.append,htmlfiles)
664 ExecutionDateLast =
"" 667 cmsreg = re.compile(
"^cmsPerfSuite")
668 for logf
in LogFiles:
669 if cmsreg.search(logf):
670 ExecutionDateLastSec = os.stat(logf)[ST_CTIME]
671 ExecutionDateLast = os.stat(logf)[ST_MTIME]
673 print "Execution (completion) date for %s was: %s" % (logf,ExecutionDateLast)
674 if (ExecutionDateLastSec > ExecutionDateSec):
675 ExecutionDateSec = ExecutionDateLastSec
676 ExecutionDate = ExecutionDateLast
678 if ExecutionDate ==
"":
679 ExecutionDate = ExecutionDateLast
681 return (ExecutionDate,LogFiles,date,cmsScimarkResults,cmsScimarkDir)
684 RegressTmplHTML=
"%s/doc/regress.html" % (BASE_PERFORMANCE)
685 candnreg = re.compile(
"CandleName")
686 candhreg = re.compile(
"CandlesHere")
688 REGR = open(reghtml,
"w")
689 for line
in open(RegressTmplHTML):
690 if candhreg.search(line):
694 abspath = os.path.join(repdir,outd)
695 if os.path.exists(abspath):
696 html +=
"<tr><td><a href=\"./%s/%s\"><img src=\"./%s/%s\" /></a></td></tr>\n" % (outd,x,outd,x)
698 html +=
"<tr><td> %s does not exist probably because the log file for the previous release was missing</td></tr>" % (abspath)
701 elif candnreg.search(line):
702 REGR.write(CurrentCandle)
705 except IOError
as detail:
706 print "ERROR: Could not write regression html %s because %s" % (os.path.basename(reghtml),detail)
709 logreg = re.compile(
"(.*)\.log$")
710 matches = logreg.search(reportName)
711 logdir = logreg.sub(matches.groups()[0],reportName)
712 outd = os.path.join(base,logdir)
713 nologext = matches.groups()[0]
714 return (nologext,outd)
719 x = os.path.basename(x)
720 y = os.path.basename(y)
721 stepreg = re.compile(
"%s_(..*)\.root" % fname)
722 if stepreg.search(x):
723 x = stepreg.search(x).groups()[0]
724 if stepreg.search(y):
725 y = stepreg.search(y).groups()[0]
731 x = os.path.basename(x)
732 y = os.path.basename(y)
733 stepreg = re.compile(
"%s_(..*)_%s" % (candle,prof))
734 if stepreg.search(x):
735 x = stepreg.search(x).groups()[0]
736 if stepreg.search(y):
737 y = stepreg.search(y).groups()[0]
743 x = os.path.basename(x)
744 y = os.path.basename(y)
745 stepreg = re.compile(
"%s_(..*)_%s_regression" % (candle,prof))
746 if stepreg.search(x):
747 x = stepreg.search(x).groups()[0]
748 if stepreg.search(y):
749 y = stepreg.search(y).groups()[0]
755 x = os.path.basename(x)
756 y = os.path.basename(y)
757 stepreg = re.compile(
"%s_(..*)_TimingReport.log" % fname)
758 if stepreg.search(x):
759 x = stepreg.search(x).groups()[0]
760 if stepreg.search(y):
761 y = stepreg.search(y).groups()[0]
767 x = os.path.basename(x)
768 y = os.path.basename(y)
769 stepreg = re.compile(
"%s_(..*)_TimingReport" % fname)
770 if stepreg.search(x):
771 x = stepreg.search(x).groups()[0]
772 if stepreg.search(y):
773 y = stepreg.search(y).groups()[0]
787 for i
in range(len(Step)):
788 stepreg = re.compile(
"^%s.*" % Step[i])
790 if Step[i]
in xstr
and sndbst_x == -1:
792 if Step[i]
in ystr
and sndbst_y == -1:
795 if xstr
in Step[i]
and bestx_idx == -1:
797 if ystr
in Step[i]
and besty_idx == -1:
800 if stepreg.search(xstr)
and x_idx == -1:
802 if stepreg.search(ystr)
and y_idx == -1:
805 if Step[i] == xstr
and x_idx == -1:
807 if Step[i] == ystr
and y_idx == -1:
809 if not ( x_idx == -1
or y_idx == -1):
830 if x_idx == -1
or y_idx == -1:
831 print "WARNING: No valid step names could be found in the logfiles or root filenames being sorted: x: %s y: %s." % (xstr,ystr)
832 print "x", x_idx,
"y", y_idx
846 def createCandlHTML(tmplfile,candlHTML,CurrentCandle,WebArea,repdir,ExecutionDate,LogFiles,cmsScimarkResults,date,prevrev):
847 global TimeSizeNumOfEvents,IgProfNumOfEvents,CallgrindNumOfEvents,MemcheckNumOfEvents
848 def _stripbase(base, astr):
849 basereg = re.compile(
"^%s/?(.*)" % base)
851 found = basereg.search(astr)
853 out = found.groups()[0]
856 def _getProfileReportLink(repdir,CurrentCandle,CurDir,step,CurrentProfile,Profiler):
859 ProfileTemplate=os.path.join(repdir,
"%s_%s" % (CurrentCandle,CurDir),
"*_%s_%s*" % (step,CurrentProfile),Profiler)
862 ProfileTemplateLowCaps=os.path.join(repdir,
"%s_%s" % (CurrentCandle,CurDir),
"*_%s_%s*" % (step.lower(),CurrentProfile),Profiler)
863 ProfileReportLink = glob.glob(ProfileTemplate)
870 if len(ProfileReportLink) > 0:
872 if not reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentCandle
in x,ProfileReportLink)):
873 ProfileReportLink = glob.glob(ProfileTemplateLowCaps)
875 ProfileReportLink = glob.glob(ProfileTemplateLowCaps)
876 ProfileReportLink =
map(
lambda x: _stripbase(repdir,x),ProfileReportLink)
878 return ProfileReportLink
880 def _writeReportLink(INDEX,ProfileReportLink,CurrentProfile,step,NumOfEvents,Profiler=""):
882 INDEX.write(
"<li><a href=\"%s\">%s %s (%s events)</a></li>\n" % (ProfileReportLink,CurrentProfile,step,NumOfEvents))
885 if CurrentProfile ==
"memcheck_valgrind":
886 INDEX.write(
"<li><a href=\"%s\">%s %s %s (%s events)</a></li>\n" % (ProfileReportLink,CurrentProfile,Profiler,step,
"5"))
888 INDEX.write(
"<li><a href=\"%s\">%s %s %s (%s events)</a></li>\n" % (ProfileReportLink,CurrentProfile,Profiler,step,NumOfEvents))
889 def IgProfDumpsTable(INDEX,ProfileLinks,step):
891 EndOfJobProfileLink=
filter(
lambda x:
"IgProfMemTotal.res" in x
or "IgProfMemLive.res" in x, ProfileLinks)[0]
893 ProfileLinks.remove(EndOfJobProfileLink)
895 ProfileLinks.sort(key=
lambda x:
int(x.split(
".")[-2]))
897 IgProfMemLive_regexp=re.compile(
"IgProfMemLive")
898 if IgProfMemLive_regexp.search(EndOfJobProfileLink):
899 MemProfile=
"IgProf MEM LIVE" 901 MemProfile=
"IgProf MEM TOTAL" 903 INDEX.write(
"<li>%s"%MemProfile)
904 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>")
905 for link
in ProfileLinks:
907 gzProfile=os.path.join(link.split(
"/")[-3],link.split(
"/")[-1])[:-3]+
"gz" 908 if IgProfMemLive_regexp.search(gzProfile):
909 gzProfile=IgProfMemLive_regexp.sub(
r"IgProfMemTotal",gzProfile)
910 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))) 912 gzEndOfJobProfileLink=os.path.join(EndOfJobProfileLink.split(
"/")[-3],EndOfJobProfileLink.split(
"/")[-1])[:-3]+
"gz" 913 if IgProfMemLive_regexp.search(gzEndOfJobProfileLink):
914 gzEndOfJobProfileLink=IgProfMemLive_regexp.sub(
r"IgProfMemTotal",gzEndOfJobProfileLink)
915 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))) 917 INDEX.write(
"</table>")
924 DirName[0] : TimeSizeNumOfEvents,
925 DirName[1] : IgProfNumOfEvents,
926 DirName[2] : IgProfNumOfEvents,
927 DirName[3] : IgProfNumOfEvents,
928 DirName[4] : CallgrindNumOfEvents,
929 DirName[5] : MemcheckNumOfEvents,
930 DirName[6] : TimeSizeNumOfEvents,
931 DirName[7] : IgProfNumOfEvents,
932 DirName[8] : IgProfNumOfEvents,
933 DirName[9] : IgProfNumOfEvents,
934 DirName[10] : CallgrindNumOfEvents,
935 DirName[11] : MemcheckNumOfEvents
951 IgProfMemAnalyseOut=(
952 "doBeginJob_output.html",
953 "doEvent_output.html",
957 memcheck_valgrindOut=(
963 Profile[0] :
"*TimingReport.html",
964 Profile[1] :
"TimeReport.html",
965 Profile[2] :
"*.html",
966 Profile[3] :
"objects_pp.html",
967 Profile[4] :
"overall.html",
968 Profile[5] :
"overall.html",
969 Profile[6] :
"overall.html",
970 Profile[7] :
"doBeginJob_output.html",
971 Profile[8] :
"overall.html",
972 Profile[9] :
"beginjob.html" 976 candnreg = re.compile(
"CandleName")
977 candhreg = re.compile(
"CandlesHere")
979 CAND = open(candlHTML,
"w")
980 for line
in open(tmplfile):
981 if candhreg.search(line):
982 CAND.write(
'<div id="content">')
984 CAND.write(CurrentCandle)
985 CAND.write(
"</h2>\n")
988 print "Producing candles html: ", CurrentCandle
990 for CurDir
in DirName:
992 LocalPath = os.path.join(repdir,
"%s_%s" % (CurrentCandle,CurDir))
993 LocalDirname = os.path.basename(LocalPath)
995 if not prevrev ==
"":
1000 if CurDir == DirName[0]
or CurDir == DirName[6]:
1001 profs = Profile[0:4]
1002 elif CurDir == DirName[1]
or CurDir == DirName[7]:
1003 profs = Profile[4:8]
1004 elif CurDir == DirName[2]
or CurDir == DirName[8]:
1006 elif CurDir == DirName[3]
or CurDir == DirName[9]:
1008 elif CurDir == DirName[4]
or CurDir == DirName[10]:
1009 profs = [Profile[8]]
1010 elif CurDir == DirName[5]
or CurDir == DirName[11]:
1011 profs = [Profile[9]]
1016 print "Scanning for profile information for: ", prof
1019 fullprof = (CurrentCandle,prof)
1022 if prof ==
"TimingReport":
1023 timeReports = glob.glob(os.path.join(LocalPath,
"%s_*_%s.log" % (CandFname[CurrentCandle],prof)))
1024 if len(timeReports) > 0:
1026 CAND.write(
"<p><strong>%s %s</strong></p>\n" % (prof,
"Regression Analysis"))
1028 for log
in timeReports:
1029 reportName = os.path.basename(log)
1031 CAND.write(
"<h4>%s</h4>\n" % reportName)
1032 htmNames = [
"changes.png"]
1033 otherNames = [
"graphs.png" ,
"histos.png"]
1034 regressHTML=
"%s-regress.html" % nologext
1035 pathsExist = reduce (
lambda x,y: x
or y,
map(os.path.exists,
map(
lambda x: os.path.join(repdir,outd,x),otherNames)))
1038 html =
"<p>Performance graphs and histograms superimposed for %s are <a href=\"%s\">here</a></p>\n" % (reportName,regressHTML)
1040 html =
"<p>No change in performance graph available</p>\n" 1041 regressHTML=
"%s/%s" % (WebArea,regressHTML)
1044 abspath = os.path.join(repdir,outd,x)
1045 if os.path.exists(abspath):
1046 html +=
"<p><a href=\"./%s/%s\"><img src=\"./%s/%s\" /></a></p>\n" % (outd,x,outd,x)
1048 html +=
"<p>%s does not exist probably because the log file for the previous release was missing</p>" % (abspath)
1052 CAND.write(
"\n</tr></table>")
1055 elif prof ==
"SimpleMemReport":
1056 simMemReports = glob.glob(os.path.join(LocalPath,
"%s_*_%s" % (CandFname[CurrentCandle],prof)))
1057 simMemReports =
map(
lambda x: (CandFname[CurrentCandle],prof,x), simMemReports )
1058 simMemReports.sort(cmp=dirname_cmp)
1059 simMemReports =
map(
lambda x: x[2], simMemReports )
1060 if len(simMemReports) > 0:
1062 CAND.write(
"<p><strong>%s %s</strong></p>\n" % (prof,
"Regression Analysis"))
1064 for adir
in simMemReports:
1065 reportName = os.path.basename(adir)
1066 CAND.write(
"<h4>%s</h4>\n" % reportName)
1067 htmNames = [
"vsize_change.png",
"rss_change.png"]
1068 otherNames = [
"vsize_graphs.png",
"rss_graphs.png"]
1069 nologext = reportName
1071 regressHTML=
"%s-regress.html" % nologext
1072 pathsExist = reduce (
lambda x,y: x
or y,
map(os.path.exists,
map(
lambda x: os.path.join(repdir,LocalDirname,outd,x),otherNames)))
1075 html =
"<p>Superimposed memory performance graphs for %s are <a href=\"%s\">here</a></p>\n" % (reportName,regressHTML)
1077 html =
"<p>No change in performance graph available</p>\n" 1078 regressHTML=
"%s/%s" % (WebArea,regressHTML)
1081 abspath = os.path.join(repdir,LocalDirname,outd,x)
1082 if os.path.exists(abspath):
1083 html +=
"<p><a href=\"./%s/%s/%s\"><img src=\"./%s/%s/%s\" /></a></p>\n" % (LocalDirname,outd,x,LocalDirname,outd,x)
1085 html +=
"<p>%s does not exist probably because the log file for the previous release was missing</p>" % (abspath)
1087 createRegressHTML(regressHTML,repdir,
"%s/%s" % (LocalDirname,outd),CurrentCandle,otherNames)
1089 CAND.write(
"\n</tr></table>")
1091 elif prof ==
"EdmSize" or prof ==
"IgProfMemTotal" or prof ==
"IgProfMemLive" or prof==
"IgProfperf" or prof ==
"Callgrind":
1092 regresPath = os.path.join(LocalPath,
"%s_*_%s_regression" % (CandFname[CurrentCandle],prof))
1093 regresses = glob.glob(regresPath)
1094 stepreg = re.compile(
"%s_([^_]*(_PILEUP)?)_%s_regression" % (CandFname[CurrentCandle],prof))
1095 if len(regresses) > 0:
1097 CAND.write(
"<p><strong>%s %s</strong></p>\n" % (prof,
"Regression Analysis"))
1099 regresses =
map(
lambda x: (CandFname[CurrentCandle],prof,x),regresses)
1100 regresses.sort(cmp=reg_dirname_cmp)
1101 regresses =
map(
lambda x: x[2],regresses)
1102 for rep
in regresses:
1103 base = os.path.basename(rep)
1104 found = stepreg.search(base)
1105 step =
"Unknown-step" 1107 step = found.groups()[0]
1109 if prof ==
"IgProfMemLive" or prof ==
"IgProfMemTotal" or prof==
"IgProfperf" or prof ==
"Callgrind":
1110 htmlpage =
"overall.html" 1112 htmlpage =
"objects_pp.html" 1113 CAND.write(
"<a href=\"%s/%s/%s\">%s %s regression report</a><br/>\n" % (LocalDirname,base,htmlpage,prof,step))
1116 if os.path.exists(LocalPath):
1117 thedir = os.listdir(LocalPath)
1118 CandleLogFiles =
filter(
lambda x: (x.endswith(
".log")
or x.endswith(
"EdmSize"))
and not os.path.isdir(x)
and os.path.exists(x),
map(
lambda x: os.path.abspath(os.path.join(LocalPath,x)),thedir))
1120 if (len(CandleLogFiles)>0):
1122 syscp(CandleLogFiles,WebArea +
"/")
1123 base = os.path.basename(LocalPath)
1126 for cand
in CandleLogFiles:
1127 cand = os.path.basename(cand)
1129 print "Found %s in %s\n" % (cand,LocalPath)
1131 if not "EdmSize" in cand:
1132 lfileshtml +=
"<a href=\"./%s/%s\">%s </a><br/>" % (base,cand,cand)
1134 CAND.write(
"<p><strong>Logfiles for %s</strong></p>\n" % CurDir)
1135 CAND.write(lfileshtml)
1138 for CurrentProfile
in Profile:
1143 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1147 OutputHtml[CurrentProfile])
1150 isProfinLink =
False 1151 if len (ProfileReportLink) > 0:
1152 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1157 if (PrintedOnce==
False):
1161 CAND.write(
"<p><strong>%s</strong></p>\n" % CurDir)
1162 CAND.write(
"<ul>\n")
1167 if (CurrentProfile == Profile[5]
or CurrentProfile == Profile[6]):
1168 for prolink
in ProfileReportLink:
1169 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir])
1170 for igprofmem
in [
"*IgProfMemTotal*.res",
"*IgProfMemLive*.res"]:
1171 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1176 isProfinLink =
False 1177 if len (ProfileReportLink) > 0:
1178 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1181 IgProfDumpsTable(CAND,ProfileReportLink,step)
1184 elif (CurrentProfile == Profile[7]):
1185 for igprof
in IgProfMemAnalyseOut:
1186 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1191 isProfinLink =
False 1192 if len (ProfileReportLink) > 0:
1193 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1195 for prolink
in ProfileReportLink:
1196 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir],Profiler=igprof)
1199 elif (CurrentProfile == Profile[9]):
1201 for memprof
in memcheck_valgrindOut:
1203 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1209 isProfinLink =
False 1210 if len (ProfileReportLink) > 0:
1211 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1213 for prolink
in ProfileReportLink:
1214 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir],Profiler=memprof)
1217 for prolink
in ProfileReportLink:
1218 if "regression" not in prolink:
1219 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir])
1224 CAND.write(
"</ul>\n")
1227 CAND.write(
"<hr />")
1228 CAND.write(
"<br />\n")
1229 CAND.write(
"</div>\n")
1230 elif candnreg.search(line):
1231 CAND.write(CurrentCandle)
1236 except IOError
as detail:
1237 print "ERROR: Could not write candle html %s because %s" % (os.path.basename(candlHTML),detail)
1242 for cand
in Candles:
1243 fname = CandFname[cand]
1244 globpath = os.path.join(repdir,
"%s_TimeSize" % cand,
"%s_*_TimingReport" % fname)
1245 stepDirs = glob.glob(globpath)
1246 stepDirs =
map(
lambda x: (fname,x), stepDirs)
1247 stepDirs.sort(cmp=timerep_cmp)
1248 stepDirs =
map(
lambda x: x[1], stepDirs)
1249 stepreg = re.compile(
"%s_(.*)_TimingReport" % fname)
1254 for stepdir
in stepDirs:
1255 base = os.path.basename(stepdir)
1256 found = stepreg.search(base)
1257 step =
"Unknown-step" 1259 step = found.groups()[0]
1260 realstep =
"Unknown-step" 1261 if "PILEUP" in step:
1262 found = pureg.search(step)
1264 realstep = found.groups()[0]
1268 rootf = os.path.join(stepdir,rootfile)
1270 if os.path.exists(rootf):
1271 f = ROOT.TFile(rootf)
1273 cpu_time_tree = ROOT.TTree()
1274 f.GetObject(
"cpu_time_tuple;1",cpu_time_tree)
1276 if cpu_time_tree.InheritsFrom(
"TTree"):
1279 for t
in cpu_time_tree:
1284 createNewRow =
False 1285 curRow = table.newRow(cand)
1286 data_tuple = (data1,data2)
1288 if "PILEUP" in step:
1289 puRow.addEntry(realstep,data_tuple)
1292 createNewRow =
False 1293 curRow = table.newRow(cand)
1295 curRow.addEntry(step,data_tuple)
1300 table.addRow(puRow,
"%s PILEUP" %cand)
1305 cols = len(ordered_keys)
1306 totcols = (cols * 3) + 1
1308 colspan = totcols - 1
1311 labels = [
"fs1",
"fs2",
"Δ"]
1312 elif mode == 2
or mode == 3:
1316 labels = [
"t1" ,
"t2" ,
"Δ"]
1319 INDEX.write(
"<h3>%s</h3>\n" % header)
1320 INDEX.write(
"<table>\n")
1321 INDEX.write(
"<caption>%s</caption>\n" % caption)
1322 INDEX.write(
"<thead><tr><th></th><th colspan=\"%s\" scope=\"colgroup\">%s</th></tr></thead>" % (colspan,name))
1323 INDEX.write(
"<tbody>\n")
1324 for key
in ordered_keys:
1327 INDEX.write(
"<th></th>")
1329 INDEX.write(
"<td scope=\"row\">")
1331 INDEX.write(
"</td>")
1332 for col
in table_dict[
None]:
1334 INDEX.write(
"<th colspan=\"%s\" scope=\"col\">" % innercol)
1336 INDEX.write(
"</th>")
1338 rowdict = table_dict[key].getRowDict()
1343 INDEX.write(
"%s" % dat)
1344 INDEX.write(
"</td>")
1349 INDEX.write(
"%6.2f" % dat)
1350 INDEX.write(
"</td>")
1352 (data1, data2) = rowdict[col]
1353 diff = data2 - data1
1360 seq = [ data1, data2, diff ]
1362 INDEX.write(
"<td id=\"data\">")
1364 INDEX.write(
"%s" % dat)
1366 INDEX.write(
"%6.2f" % dat)
1368 INDEX.write(
"</td>")
1370 if mode == 2
or mode == 3:
1373 INDEX.write(
"</td>")
1378 INDEX.write(
"</td>")
1379 INDEX.write(
"</tr>\n")
1382 if not (mode == 2
or mode == 3 ):
1385 INDEX.write(
"<th>Candles</th>")
1386 for col
in table_dict[
None]:
1387 INDEX.write(
"<th>%s</th>" % labels[0])
1388 INDEX.write(
"<th>%s</th>" % labels[1])
1389 INDEX.write(
"<th>%s</th>" % labels[2])
1390 INDEX.write(
"</tr>\n")
1391 INDEX.write(
"</tbody></table>\n")
1393 INDEX.write(
"<br />")
1396 '''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.''' 1399 if ":" in remotedir:
1400 (host,dir)=remotedir.split(
":")
1401 mkdir_cmd=
"ssh %s (mkdir %s;mkdir %s/%s)"%(host,dir,dir,arch)
1403 mkdir_cmd=
"mkdir %s;mkdir %s/%s"%(remotedir,remotedir,arch)
1408 os.system(mkdir_cmd)
1409 print "Successfully created publication directory" 1411 print "Issues with publication directory existence/creation!" 1416 if ":" in remotedir:
1417 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)
1419 tarpipe_cmd=
'tar cf - *_IgProf_*/*.sql3 | (cd %s/%s; mkdir %s; cd %s; tar xf -; mv *_IgProf_*/*.sql3 .; rmdir *_IgProf_*)'%(remotedir,arch,version,version)
1424 os.system(tarpipe_cmd)
1425 print "Successfully copied IgProf reports to %s"%remotedir
1427 print "Issues with rsyncing to the remote directory %s!"%remotedir
1430 if ":" in remotedir:
1431 chmod_cmd=
"ssh %s chmod -R 775 %s/%s"%(host,dir,arch)
1433 chmod_cmd=
"chmod -R 775 %s/%s"%(remotedir,arch)
1436 os.system(chmod_cmd)
1437 print "Successfully set permissions for IgProf reports directory %s"%remotedir
1439 print "(Potential) issues with chmoding the remote directory %s!"%remotedir
1454 CmsDriverCandle = CandFname
1458 IndexFile=
"%s/index.html" % WebArea
1459 TemplateHtml=
"%s/doc/index.html" % BASE_PERFORMANCE
1461 cmsverreg = re.compile(
"CMSSW_VERSION")
1462 hostreg = re.compile(
"HOST")
1463 lpathreg = re.compile(
"LocalPath")
1464 fsizereg = re.compile(
"FSizeTable")
1465 cpureg = re.compile(
"CPUTable")
1466 proddreg = re.compile(
"ProductionDate")
1467 logfreg = re.compile(
"LogfileLinks")
1468 dirbreg = re.compile(
"DirectoryBrowsing")
1469 pubdreg = re.compile(
"PublicationDate")
1470 candhreg = re.compile(
"CandlesHere")
1474 CandlTmpltHTML=
"%s/doc/candle.html" % BASE_PERFORMANCE
1476 print "Copying %s/doc/perf_style.css style file to %s/." % (BASE_PERFORMANCE,WebArea)
1477 print "Template used: %s" % TemplateHtml
1479 syscp((BASE_PERFORMANCE +
"/doc/perf_style.css"),WebArea +
"/.")
1480 pureg = re.compile(
"(.*)_PILEUP")
1482 INDEX = open(IndexFile,
"w")
1483 for NewFileLine
in open(TemplateHtml) :
1484 if cmsverreg.search(NewFileLine):
1486 INDEX.write(
"Performance Reports for %s\n" % CMSSW_VERSION)
1488 globpath = os.path.join(repdir,
"REGRESSION.%s.vs.*" % (prevrev))
1489 globs = glob.glob(globpath)
1493 latestreg = re.compile(
"REGRESSION.%s.vs.(.*)" % prevrev)
1494 found = latestreg.search(os.path.basename(globs[0]))
1496 latestrel = found.groups()[0]
1497 INDEX.write(
"Performance Reports with regression: %s VS %s\n" % (prevrev,latestrel))
1499 INDEX.write(
"Performance Reports with regression: %s VS %s\n" % (prevrev,CMSSW_VERSION))
1500 elif hostreg.search(NewFileLine):
1501 INDEX.write(HOST +
"\n")
1503 elif fsizereg.search(NewFileLine):
1508 for cand
in Candles:
1509 fname = CandFname[cand]
1510 globpath = os.path.join(repdir,
"%s*_TimeSize" % cand,
"%s_*.root" % fname)
1511 rootfiles = glob.glob(globpath)
1512 rootfiles =
map(
lambda x: (fname,x), rootfiles)
1513 rootfiles.sort(cmp=rootfile_cmp)
1514 rootfiles =
map(
lambda x: x[1], rootfiles)
1515 stepreg = re.compile(
"%s_(.*).root" % fname)
1520 for rootf
in rootfiles:
1521 base = os.path.basename(rootf)
1522 found = stepreg.search(base)
1523 step =
"Unknown-step" 1525 step = found.groups()[0]
1526 realstep =
"Unknown-step" 1527 if "PILEUP" in step:
1528 found = pureg.search(step)
1530 realstep = found.groups()[0]
1533 puRow =
Row(fsize_tab)
1535 statinfo = os.stat(rootf)
1536 fsize = statinfo.st_size
1538 createNewRow =
False 1539 curRow = fsize_tab.newRow(cand)
1541 if "PILEUP" in step:
1542 puRow.addEntry(realstep,fsize)
1545 createNewRow =
False 1546 curRow = fsize_tab.newRow(cand)
1548 curRow.addEntry(step,fsize)
1549 except IOError
as detail:
1551 except OSError
as detail:
1556 fsize_tab.addRow(puRow,
"%s PILEUP" %cand)
1557 (ordered_keys,table_dict) = fsize_tab.getTable(1)
1558 cols = len(ordered_keys)
1560 if len(table_dict) > 1
and cols > 0:
1562 "Release ROOT file sizes",
1563 "Table showing current release ROOT filesizes in (k/M/G) bytes.",
1568 globpath = os.path.join(repdir,
"REGRESSION.%s.vs.*" % (prevrev))
1569 globs = glob.glob(globpath)
1571 raise IOError(2,globpath,
"File does not exist",
"File does not exist")
1572 idfile = open(globs[0])
1576 oldpath = oldpath.strip()
1580 for cand
in Candles:
1581 fname = CandFname[cand]
1582 globpath = os.path.join(repdir,
"%s*_TimeSize" % cand,
"%s_*.root" % fname)
1583 rootfiles = glob.glob(globpath)
1584 rootfiles =
map(
lambda x: (fname,x), rootfiles)
1585 rootfiles.sort(cmp=rootfile_cmp)
1586 rootfiles =
map(
lambda x: x[1], rootfiles)
1587 stepreg = re.compile(
"%s_(.*).root" % fname)
1592 for rootf
in rootfiles:
1593 base = os.path.basename(rootf)
1594 found = stepreg.search(base)
1595 step =
"Unknown-step" 1597 step = found.groups()[0]
1599 realstep =
"Unknown-step" 1600 if "PILEUP" in step:
1601 found = pureg.search(step)
1603 realstep = found.groups()[0]
1606 puRow =
Row(fsize_tab)
1608 statinfo = os.stat(rootf)
1609 fsize2 = statinfo.st_size
1610 oldfile = os.path.join(oldpath,
"%s_TimeSize" % cand,base)
1611 if "PILEUP" in step:
1612 oldfile = os.path.join(oldpath,
"%s_PU_TimeSize" % cand,base)
1615 if os.path.exists(oldfile):
1616 statinfo = os.stat(oldfile)
1617 fsize1 = statinfo.st_size
1619 print "######DID NOT FIND Previous file (needed for the filesize table): %s"%oldfile
1622 createNewRow =
False 1623 curRow = fsize_tab.newRow(cand)
1625 data_tuple = (fsize1,fsize2)
1626 if "PILEUP" in step:
1627 puRow.addEntry(realstep,data_tuple)
1630 createNewRow =
False 1631 curRow = fsize_tab.newRow(cand)
1633 curRow.addEntry(step,data_tuple)
1634 except IOError
as detail:
1636 except OSError
as detail:
1641 fsize_tab.addRow(puRow,
"%s PILEUP" %cand)
1643 (ordered_keys,table_dict) = fsize_tab.getTable()
1644 cols = len(ordered_keys)
1646 if len(table_dict) > 1
and cols > 0:
1648 "Release ROOT file sizes",
1649 "Table showing previous release ROOT filesizes, fs1, latest sizes, fs2, and the difference between them Δ in (k/M/G) bytes.",
1651 except IOError
as detail:
1653 except OSError
as detail:
1656 elif cpureg.search(NewFileLine):
1661 for cand
in Candles:
1662 fname = CandFname[cand]
1663 globpath = os.path.join(repdir,
"%s*_TimeSize" % cand,
"%s_*_TimingReport.log" % fname)
1664 logfiles = glob.glob(globpath)
1665 logfiles =
map(
lambda x: (fname,x), logfiles)
1666 logfiles.sort(cmp=logrep_cmp)
1667 logfiles =
map(
lambda x: x[1], logfiles)
1669 stepreg = re.compile(
"%s_(.*)_TimingReport.log" % fname)
1674 for log
in logfiles:
1675 base = os.path.basename(log)
1676 found = stepreg.search(base)
1677 step =
"Unknown-step" 1679 step = found.groups()[0]
1681 realstep =
"Unknown-step" 1682 if "PILEUP" in step:
1683 found = pureg.search(step)
1685 realstep = found.groups()[0]
1688 puRow =
Row(time_tab)
1690 data = cpr.getTimingLogData(log)
1693 for evtnum, time
in data:
1697 mean = mean /
float(i)
1698 except ZeroDivisionError
as detail:
1699 print "WARNING: Could not calculate mean CPU time from log because no events could be parsed", log
1701 if "PILEUP" in step:
1702 puRow.addEntry(realstep,mean)
1705 createNewRow =
False 1706 curRow = time_tab.newRow(cand)
1708 curRow.addEntry(step,mean)
1712 time_tab.addRow(puRow,
"%s PILEUP" %cand)
1714 (ordered_keys,table_dict) = time_tab.getTable(1)
1715 cols = len(ordered_keys)
1717 if len(table_dict) > 1
and cols > 0:
1719 "Release CPU times",
1720 "Table showing current release CPU times in secs.",
1738 (ordered_keys,table_dict) = cpu_time_tab.getTable()
1740 cols = len(ordered_keys)
1741 if len(table_dict) > 1
and cols > 0:
1743 "Release CPU times",
1744 "Table showing previous release CPU times, t1, latest times, t2, and the difference between them Δ in secs.",
1749 elif lpathreg.search(NewFileLine):
1750 INDEX.write(repdir +
"\n")
1751 elif proddreg.search(NewFileLine):
1752 INDEX.write(ExecutionDate +
"\n")
1753 elif logfreg.search(NewFileLine):
1754 INDEX.write(
"<br />\n")
1755 for log
in LogFiles:
1756 log = os.path.basename(log)
1758 print "linking log file %s" % log
1759 INDEX.write(
"<a href=\"./%s\"> %s </a>" % (log,log))
1760 INDEX.write(
"<br />\n")
1762 INDEX.write(
"Results for cmsScimark2 benchmark (running on the other cores) available at:\n")
1763 for cmssci
in cmsScimarkResults:
1764 scimarkdirs=cmssci.split(
"/")
1765 localdir=scimarkdirs[-2]
1767 cmssci = os.path.basename(cmssci)
1768 relativelink=os.path.join(localdir,cmssci)
1770 INDEX.write(
"<a href=\"%s\"> %s </a>" % (relativelink,cmssci))
1771 INDEX.write(
"<br />\n")
1774 elif dirbreg.search(NewFileLine):
1782 INDEX.write(
"Click <a href=\"./DirectoryBrowsing/\">here</a> to browse the directory containing all results (except the root files)\n")
1784 elif pubdreg.search(NewFileLine):
1785 INDEX.write(date +
"\n")
1786 elif candhreg.search(NewFileLine):
1787 for acandle
in Candle:
1788 globpath = os.path.join(repdir,
"%s_*" % acandle)
1789 globs = glob.glob(globpath)
1791 candlHTML =
"%s.html" % acandle
1792 INDEX.write(
"<a href=\"./%s\"> %s </a>" % (candlHTML,acandle))
1793 INDEX.write(
"<br />\n")
1795 candlHTML=os.path.join(WebArea,candlHTML)
1796 createCandlHTML(CandlTmpltHTML,candlHTML,acandle,WebArea,repdir,ExecutionDate,LogFiles,cmsScimarkResults,date,prevrev)
1798 INDEX.write(NewFileLine)
1802 except IOError
as detail:
1803 print "Error: Could not create index Html file for some reason, check position. Details : %s" % detail
1810 Dir = os.listdir(repdir)
1811 def _containsDirName(elem):
1812 return reduce(
lambda x,y: x
or y,
map(
lambda x: x
in elem, DirName))
1813 def _print4Lambda(elem,WebArea):
1815 print "Copying %s to %s\n" % (elem,WebArea)
1817 dirstocp =
filter(
lambda x: _containsDirName(x),
map(
lambda x: repdir + x,Dir))
1818 map(
lambda x: _print4Lambda(x,WebArea),dirstocp)
1819 syscp(dirstocp,WebArea +
"/")
1820 os.mkdir(
"%s/DirectoryBrowsing" % WebArea)
1821 for file
in os.listdir(WebArea):
1822 if file !=
"index.html":
1824 os.symlink(
"%s/%s"%(
"..",file),
"%s/DirectoryBrowsing/%s" % (WebArea,file))
1835 args =
"--port=%s %s %s:%s" % (port,os.path.normpath(stage),drive,path)
1838 print cmd +
" --dry-run " + args
1839 retval = os.system(cmd +
" --dry-run " + args )
1842 retval = os.system(cmd +
" " + args)
1849 if os.path.exists(TMP_DIR)
and IS_TMP:
1850 os.system(
"rm -Rf " + TMP_DIR)
1857 def _walkpath(path):
1860 head , tail = os.path.split(path)
1865 for i
in range(len(dirs)-1,-1,-1):
1869 pwalk = _walkpath(parent)
1875 except StopIteration:
1881 cwalk = _walkpath(child)
1886 except StopIteration:
1887 print "ERROR: Unable to determine relative dir" 1893 relpath=os.path.join(relpath,
next(cwalk))
1894 except StopIteration:
1901 except OSError
as detail:
1902 print "WARNING: Could not copy %s to %s because %s" % (src,dest,detail)
1903 except IOError
as detail:
1904 print "WARNING: Could not copy %s to %s because %s" % (src,dest,detail)
1907 print "Copied %s to %s" % (src,dest)
1910 def _getNewLocation(source,child,dst,keepTop=keepTop):
1912 return os.path.join(dst,place)
1913 def _copyFilter(source,dst,curdir,fsnodes,filter,dirs=False):
1914 for node
in fsnodes:
1916 filterExist =
not len(filter) == 0
1918 dontFilter =
not reduce(
lambda x,y: x
or y,
map(
lambda x: fnmatch.fnmatch(node,x),filter))
1920 node = os.path.join(curdir,node)
1922 newnode = _getNewLocation(source,node,dst)
1927 except IOError
as detail:
1928 print "WARNING: Could not copy %s to %s because %s" % (node,newnode,detail)
1929 except OSError
as detail:
1930 print "WARNING: Could not copy %s to %s because %s" % (src,dest,detail)
1931 except ReldirExcept:
1932 print "WARNING: Could not determine new location for source %s into destination %s" % (source,dst)
1936 match = fnmatch.fnmatch(node,filter[0])
1938 except AssertionError
as detail:
1939 print node, filter[0], match
1943 print "Filter %s Copied %s to %s" % (dontFilter,node,newnode)
1944 print "fnmatch %s" % fnmatch.fnmatch(node,cpFileFilter[0])
1948 newloc = _getNewLocation(src,src,dest)
1958 _copyFilter(src,dest,curdir,dirs,cpDirFilter,dirs=
True)
1959 _copyFilter(src,dest,curdir,files,cpFileFilter)
1961 except StopIteration:
1963 except IOError
as detail:
1964 print "WARNING: Could not copy %s to %s because %s" % (src,dest,detail)
1965 except OSError
as detail:
1966 print "WARNING: Could not copy %s to %s because %s" % (src,dest,detail)
1967 except ReldirExcept:
1968 print "WARNING: Could not determine the new location for source %s into destination %s" % (src,dest)
1971 if type(srcs) == type(
""):
1972 if os.path.exists(srcs):
1973 if os.path.isdir(srcs):
1978 print "ERROR: file to be copied %s does not exist" % foo
1981 if os.path.exists(src):
1982 if os.path.isdir(src):
1988 print "ERROR: file to be copied %s does not exist" % foo
1991 print "%s\n" % PROG_NAME
1993 if __name__ ==
"__main__":
def optionparse()
Option parser.
def addRow(self, row, name)
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)
return(e1-e2)*(e1-e2)+dp *dp
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.