14 from __future__
import print_function
15 from builtins
import range
16 import tempfile
as tmp
17 import optparse
as opt
18 import cmsPerfRegress
as cpr
19 import re, os, sys, time, glob, socket, fnmatch
20 from shutil
import copy2, copystat
22 from cmsPerfCommons
import CandFname, Step, ProductionSteps, Candles
26 from functools
import reduce
28 PROG_NAME = os.path.basename(sys.argv[0])
29 DEF_RELVAL =
"/afs/cern.ch/cms/sdt/web/performance/RelVal" 30 DEF_SIMUL =
"/afs/cern.ch/cms/sdt/web/performance/simulation" 32 cpFileFilter = (
"*.root", )
35 TimeSizeNumOfEvents = -9999
36 IgProfNumOfEvents = -9999
37 CallgrindNumOfEvents = -9999
38 MemcheckNumOfEvents = -9999
56 Steps=set(Step+ProductionSteps+[
"GEN,FASTSIM",
"GEN,FASTSIM_PILEUP"])
65 "Relative directory could not be determined" 73 trail = re.compile(
"/$")
74 if os.path.isdir(adir)
and not trail.search(adir):
84 return subprocess.Popen(cmd,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().
strip()
91 return subprocess.Popen(command,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().
strip()
97 suffixes = [(
"B",2**10), (
"k",2**20), (
"M",2**30), (
"G",2**40), (
"T",2**50)]
98 for suf, lim
in suffixes:
103 return "-" + round(size/
float(lim/2**10),2).
__str__() + suf
117 self.table._newCol(colname)
132 out +=
"\n" + self.
rows 139 self.colNames.append(name)
145 if name
in self.rows.keys():
148 self.keys.append(name)
151 return self.
rows[name]
156 for key
in self.
keys:
162 rowobj = self.
rows[key]
163 rowdict = rowobj.getRowDict()
167 elif col
in rowdict
and not col == name:
169 total1 += rowdict[col]
171 (step_tot1, step_tot2) = rowdict[col]
175 rowobj.addEntry(name,total1)
177 rowobj.addEntry(name,(total1,total2))
182 if name
in self.rows.keys():
185 self.keys.append(name)
186 self.
rows[name] = row
190 for col
in self.colnames:
191 rowobj = transp.newRow(col)
192 for key
in self.
keys:
196 row_dict = self.
rows[key].getRowDict()
198 rowobj.addEntry(key,row_dict[col])
206 global TimeSizeNumOfEvents,IgProfNumOfEvents,CallgrindNumOfEvents,MemcheckNumOfEvents
209 def _copyReportsToStaging(repdir,LogFiles,cmsScimarkDir,stage):
210 """Use function syscp to copy LogFiles and cmsScimarkDir over to staging area""" 212 print(
"Copying the logfiles to %s/." % stage)
213 print(
"Copying the cmsScimark2 results to the %s/." % stage)
215 syscp(LogFiles , stage +
"/")
216 syscp(cmsScimarkDir, stage +
"/")
219 def _createLogFile(LogFile,date,LocalPath,ShowTagsResult):
220 """Creating a small logfile with basic publication script running information (never used really by other scripts in the suite).""" 222 LOG = open(LogFile,
"w")
224 print(
"Writing Production Host, Location, Release and Tags information in %s" % LogFile)
225 LOG.write(
"These performance tests were executed on host %s and published on %s" % (HOST,date))
226 LOG.write(
"They were run in %s" % LocalPath)
227 LOG.write(
"Results of showtags -r in the local release:\n%s" % ShowTagsResult)
229 except IOError
as detail:
230 print(
"WARNING: Can't create log file")
238 print(
"\n Getting Environment variables...")
245 print(
"\n Determining locations for input and staging...")
246 (drive,path,remote,stage,port,repdir,prevrev,igprof_remotedir) =
getStageRepDirs(options,args)
249 print(
"\n Getting the number of events for each test...")
251 cmsPerfSuiteLogfile=
"%s/cmsPerfSuite.log"%repdir
253 if os.path.exists(cmsPerfSuiteLogfile):
255 (TimeSizeNumOfEvents,IgProfNumOfEvents,CallgrindNumOfEvents,MemcheckNumOfEvents)=
getNumOfEventsFromLog(cmsPerfSuiteLogfile)
260 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)
261 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!")
262 print(
"For now taking the default values for all tests (0)!")
264 print(
"\n Scan report directory...")
266 (ExecutionDate,LogFiles,date,cmsScimarkResults,cmsScimarkDir) =
scanReportArea(repdir)
267 print(
"cmsScimarkResults are %s"%cmsScimarkResults)
268 print(
"\n Copy report files to staging directory...")
270 _copyReportsToStaging(repdir,LogFiles,cmsScimarkDir,stage)
272 print(
"\n Creating log file...")
274 _createLogFile(
"%s/ProductionLog.txt" % stage,date,repdir,ShowTagsResult)
277 for dirname
in os.listdir(repdir):
278 if "IgProf" in dirname:
279 print(
"\n Handling IgProf reports...")
283 print(
"\n Creating HTML files...")
285 createWebReports(stage,repdir,ExecutionDate,LogFiles,cmsScimarkResults,date,prevrev)
287 print(
"\n Copy profiling logs to staging directory...")
293 print(
"\n Uploading web report to remote location...")
295 print(
"\n Finished uploading! Now removing staging directory...")
298 print(
"\n Finished!!!")
305 global CMSSW_VERSION, CMSSW_RELEASE_BASE, CMSSW_BASE, HOST, USER, BASE_PERFORMANCE, CMSSW_WORK
306 global DEF_RELVAL, DEF_SIMUL
309 CMSSW_VERSION=os.environ[
'CMSSW_VERSION']
310 CMSSW_RELEASE_BASE=os.environ[
'CMSSW_RELEASE_BASE']
311 CMSSW_BASE=os.environ[
'CMSSW_BASE']
312 HOST=os.environ[
'HOST']
313 USER=os.environ[
'USER']
314 CMSSW_WORK = os.path.join(CMSSW_BASE,
"work/Results")
315 except KeyError
as detail:
316 fail(
"ERROR: Could not retrieve some necessary environment variables. Have you ran scramv1 runtime -csh yet?. Details: %s" % detail)
322 PerformancePkg=
"%s/src/Validation/Performance" % CMSSW_BASE
323 if (os.path.exists(PerformancePkg)):
324 BASE_PERFORMANCE=PerformancePkg
325 print(
"**Using LOCAL version of Validation/Performance instead of the RELEASE version**")
327 BASE_PERFORMANCE=
"%s/src/Validation/Performance" % CMSSW_RELEASE_BASE
329 return (LocalPath,ShowTagsResult)
335 global PROG_NAME, _debug, _dryrun, _verbose
337 parser = opt.OptionParser(usage=(
"""%s [HOST:]DEST_PATH [Options] 340 [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) 343 Publish report to default local directory 345 Publish report to \"/some/local/dir\" 347 Publish report to \"/some/other/dir\" remote host \"hal.cern.ch\" 348 ./%s hal.cern.ch:/some/other/dir 349 Publish report to default relval location (this could be remote or local depending on the hardcoded default) 351 % ( PROG_NAME, PROG_NAME, PROG_NAME, PROG_NAME, PROG_NAME)))
353 devel = opt.OptionGroup(parser,
"Developer Options",
354 "Caution: use these options at your own risk." 355 "It is believed that some of them bite.\n")
360 help=
'Use the default RelVal location',
369 help=
'output more information',
377 help=
'Use the default simulation location',
385 help=
'The override the name of the previous release. Default is the string obtain from the identification file REGRESSION.<prevrel>.vs.<newrel>',
394 help=
'The location of the report files to be published',
403 help=
'Use a particular port number to rsync material to a remote server',
410 default=
'IgProfData',
412 help=
'Specify an AFS or host:mydir remote directory instead of default one',
413 metavar=
'<IGPROF REMOTE DIRECTORY>' 421 help=
'Show debug output',
429 help=
'Do not send files to remote server, but run everything else',
433 repdirdef = os.getcwd()
434 parser.set_defaults(debug=0,simulation=
False,relval=
False,port=873,pretend=
False,repdir=repdirdef,verbose=
False)
435 parser.add_option_group(devel)
437 (options, args) = parser.parse_args()
439 _debug = options.debug
440 _dryrun = options.dryrun
441 _verbose = options.verbose
443 numofargs = len(args)
445 if (options.simulation
and options.relval)
or ((options.simulation
or options.relval)
and numofargs >= 1):
446 parser.error(
"You can not specify simulation and relval together. Neither can you specify simulation or relval AND a path")
449 return (options, args)
454 '''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!''' 455 log=open(logfile,
"r") 464 if 'TimeSizeEvents' in line
and not TimeSizeEvents:
465 lineitems=line.split()
466 TimeSizeEvents=lineitems[lineitems.index(
'TimeSizeEvents')+1]
467 if 'IgProfEvents' in line
and not IgProfEvents:
468 lineitems=line.split()
469 IgProfEvents=lineitems[lineitems.index(
'IgProfEvents')+1]
470 if 'CallgrindEvents' in line
and not CallgrindEvents:
471 lineitems=line.split()
472 CallgrindEvents=lineitems[lineitems.index(
'CallgrindEvents')+1]
473 if 'MemcheckEvents' in line
and not MemcheckEvents:
474 lineitems=line.split()
475 MemcheckEvents=lineitems[lineitems.index(
'MemcheckEvents')+1]
476 return (TimeSizeEvents,IgProfEvents,CallgrindEvents,MemcheckEvents)
479 '''Another very fragile function to get the architecture and the CMSSW version parsing the logfile...''' 480 log=open(logfile,
"r") 481 arch=re.compile("^Current Architecture is")
482 version=re.compile(
"^Current CMSSW version is")
483 CMSSW_arch=
"UNKNOWN_ARCH" 484 CMSSW_version=
"UNKNOWN_VERSION" 486 if arch.search(line):
487 CMSSW_arch=line.split()[3]
488 if version.search(line):
489 CMSSW_version=line.split()[4]
490 return(CMSSW_arch,CMSSW_version)
498 global TMP_DIR, IS_TMP, DEF_LOCAL, CMSSW_VERSION
499 DEF_LOCAL = CMSSW_WORK
500 numofargs = len(args)
502 repdir = os.path.abspath(options.repdir)
505 if not os.path.exists(repdir):
506 fail(
"ERROR: The specified report directory %s to retrieve report information from does not exist, exiting" % repdir)
508 previousrev = options.previousrev
509 if previousrev ==
"":
510 regressfiles = glob.glob(
"%s/REGRESSION.*.vs.*" % repdir)
511 if not len(regressfiles) == 0:
512 regressID = regressfiles[0]
513 base = os.path.basename(regressID)
514 split = base.split(
".")
515 previousrev = split[1]
516 currentrel = split[3]
517 print(
"Regression Identification file exists, renaming report title for regression report. Old ver: %s" % previousrev)
519 print(
"No regression ID file exists and previous release name was not specified. Producing normal report.")
521 print(
"Previous release name was specified, renaming report title for regression report. Old ver %s" % previousrev)
525 if options.simulation:
546 drive, path = uri.split(
":",1)
551 path = os.path.abspath(path)
552 remote =
not drive ==
"" 557 socket.getaddrinfo(drive,53)
559 except socket.gaierror:
565 socket.gethostbyaddr(drive)
567 except socket.gaierror:
570 print(
"ERROR: Can not determine your hostname or ipv{4,6} address %s" % drive)
571 if not (_dryrun
or _test):
574 if (
not remote)
and (
not options.port == 873) :
575 print(
"WARNING: Can not use a port if not performing a remote copy, ignoring")
584 localExists = os.path.exists(
"%s/%s" % (CMSSW_WORK,CMSSW_VERSION))
589 TMP_DIR=tmp.mkdtemp(prefix=
"/build/%s" % PROG_NAME)
590 StagingArea = TMP_DIR
592 elif defaultlocal
and localExists:
593 TMP_DIR=tmp.mkdtemp(prefix=
"%s/%s" % (CMSSW_WORK,CMSSW_VERSION))
594 StagingArea = TMP_DIR
595 print(
"WARNING: %s already exists, creating a temporary staging area %s" % (CMSSW_WORK,TMP_DIR))
598 StagingArea = CMSSW_WORK
600 os.mkdir(os.path.join(CMSSW_BASE,
"work"))
601 os.mkdir(os.path.join(CMSSW_BASE,
"work",
"Results"))
604 print(
"**User did not specify location of results, staging in default %s**" % StagingArea)
606 print(
"**User chose to publish results in a local directory**")
608 if not os.path.exists(path):
610 os.mkdir(
"%s" % path)
611 except OSError
as detail:
612 if detail.errno == 13:
613 fail(
"ERROR: Failed to create staging area %s because permission was denied " % StagingArea)
614 elif detail.errno == 17:
618 fail(
"ERROR: There was some problem (%s) when creating the staging directory" % detail)
620 IS_TMP =
not TMP_DIR ==
"" 626 StagingArea=
"%s/%s" % (StagingArea,CMSSW_VERSION)
628 os.mkdir(
"%s" % StagingArea)
629 except OSError
as detail:
630 if detail.errno == 13:
631 fail(
"ERROR: Failed to create staging area %s because permission was denied " % StagingArea)
632 elif detail.errno == 17:
636 fail(
"ERROR: There was some problem (%s) when creating the staging directory" % detail)
638 return (drive,path,remote,StagingArea,port,repdir,previousrev,options.ig_remotedir)
645 """Scans the working directory for cms*.logs (cmsPerfSuite.log and cmsScimark*.log, and cmsScimark results. 646 It returns Execution date (completion), current date, list of logfiles and cmsScimark results""" 648 LogFiles = glob.glob(repdir +
"cms*.log")
650 print(
"Found the following log files:")
653 cmsScimarkDir = glob.glob(repdir +
"cmsScimarkResults_*")
655 print(
"Found the following cmsScimark2 results directories:")
658 cmsScimarkResults = []
659 for adir
in cmsScimarkDir:
660 htmlfiles = glob.glob(adir +
"/*.html")
664 map(cmsScimarkResults.append,htmlfiles)
666 ExecutionDateLast =
"" 669 cmsreg = re.compile(
"^cmsPerfSuite")
670 for logf
in LogFiles:
671 if cmsreg.search(logf):
672 ExecutionDateLastSec = os.stat(logf)[ST_CTIME]
673 ExecutionDateLast = os.stat(logf)[ST_MTIME]
675 print(
"Execution (completion) date for %s was: %s" % (logf,ExecutionDateLast))
676 if (ExecutionDateLastSec > ExecutionDateSec):
677 ExecutionDateSec = ExecutionDateLastSec
678 ExecutionDate = ExecutionDateLast
680 if ExecutionDate ==
"":
681 ExecutionDate = ExecutionDateLast
683 return (ExecutionDate,LogFiles,date,cmsScimarkResults,cmsScimarkDir)
686 RegressTmplHTML=
"%s/doc/regress.html" % (BASE_PERFORMANCE)
687 candnreg = re.compile(
"CandleName")
688 candhreg = re.compile(
"CandlesHere")
690 REGR = open(reghtml,
"w")
691 for line
in open(RegressTmplHTML):
692 if candhreg.search(line):
696 abspath = os.path.join(repdir,outd)
697 if os.path.exists(abspath):
698 html +=
"<tr><td><a href=\"./%s/%s\"><img src=\"./%s/%s\" /></a></td></tr>\n" % (outd,x,outd,x)
700 html +=
"<tr><td> %s does not exist probably because the log file for the previous release was missing</td></tr>" % (abspath)
703 elif candnreg.search(line):
704 REGR.write(CurrentCandle)
707 except IOError
as detail:
708 print(
"ERROR: Could not write regression html %s because %s" % (os.path.basename(reghtml),detail))
711 logreg = re.compile(
"(.*)\.log$")
712 matches = logreg.search(reportName)
713 logdir = logreg.sub(matches.groups()[0],reportName)
714 outd = os.path.join(base,logdir)
715 nologext = matches.groups()[0]
716 return (nologext,outd)
721 x = os.path.basename(x)
722 y = os.path.basename(y)
723 stepreg = re.compile(
"%s_(..*)\.root" % fname)
724 if stepreg.search(x):
725 x = stepreg.search(x).groups()[0]
726 if stepreg.search(y):
727 y = stepreg.search(y).groups()[0]
733 x = os.path.basename(x)
734 y = os.path.basename(y)
735 stepreg = re.compile(
"%s_(..*)_%s" % (candle,prof))
736 if stepreg.search(x):
737 x = stepreg.search(x).groups()[0]
738 if stepreg.search(y):
739 y = stepreg.search(y).groups()[0]
745 x = os.path.basename(x)
746 y = os.path.basename(y)
747 stepreg = re.compile(
"%s_(..*)_%s_regression" % (candle,prof))
748 if stepreg.search(x):
749 x = stepreg.search(x).groups()[0]
750 if stepreg.search(y):
751 y = stepreg.search(y).groups()[0]
757 x = os.path.basename(x)
758 y = os.path.basename(y)
759 stepreg = re.compile(
"%s_(..*)_TimingReport.log" % fname)
760 if stepreg.search(x):
761 x = stepreg.search(x).groups()[0]
762 if stepreg.search(y):
763 y = stepreg.search(y).groups()[0]
769 x = os.path.basename(x)
770 y = os.path.basename(y)
771 stepreg = re.compile(
"%s_(..*)_TimingReport" % fname)
772 if stepreg.search(x):
773 x = stepreg.search(x).groups()[0]
774 if stepreg.search(y):
775 y = stepreg.search(y).groups()[0]
789 for i
in range(len(Step)):
790 stepreg = re.compile(
"^%s.*" % Step[i])
792 if Step[i]
in xstr
and sndbst_x == -1:
794 if Step[i]
in ystr
and sndbst_y == -1:
797 if xstr
in Step[i]
and bestx_idx == -1:
799 if ystr
in Step[i]
and besty_idx == -1:
802 if stepreg.search(xstr)
and x_idx == -1:
804 if stepreg.search(ystr)
and y_idx == -1:
807 if Step[i] == xstr
and x_idx == -1:
809 if Step[i] == ystr
and y_idx == -1:
811 if not ( x_idx == -1
or y_idx == -1):
832 if x_idx == -1
or y_idx == -1:
833 print(
"WARNING: No valid step names could be found in the logfiles or root filenames being sorted: x: %s y: %s." % (xstr,ystr))
834 print(
"x", x_idx,
"y", y_idx)
848 def createCandlHTML(tmplfile,candlHTML,CurrentCandle,WebArea,repdir,ExecutionDate,LogFiles,cmsScimarkResults,date,prevrev):
849 global TimeSizeNumOfEvents,IgProfNumOfEvents,CallgrindNumOfEvents,MemcheckNumOfEvents
850 def _stripbase(base, astr):
851 basereg = re.compile(
"^%s/?(.*)" % base)
853 found = basereg.search(astr)
855 out = found.groups()[0]
858 def _getProfileReportLink(repdir,CurrentCandle,CurDir,step,CurrentProfile,Profiler):
861 ProfileTemplate=os.path.join(repdir,
"%s_%s" % (CurrentCandle,CurDir),
"*_%s_%s*" % (step,CurrentProfile),Profiler)
864 ProfileTemplateLowCaps=os.path.join(repdir,
"%s_%s" % (CurrentCandle,CurDir),
"*_%s_%s*" % (step.lower(),CurrentProfile),Profiler)
865 ProfileReportLink = glob.glob(ProfileTemplate)
872 if len(ProfileReportLink) > 0:
874 if not reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentCandle
in x,ProfileReportLink)):
875 ProfileReportLink = glob.glob(ProfileTemplateLowCaps)
877 ProfileReportLink = glob.glob(ProfileTemplateLowCaps)
878 ProfileReportLink =
map(
lambda x: _stripbase(repdir,x),ProfileReportLink)
880 return ProfileReportLink
882 def _writeReportLink(INDEX,ProfileReportLink,CurrentProfile,step,NumOfEvents,Profiler=""):
884 INDEX.write(
"<li><a href=\"%s\">%s %s (%s events)</a></li>\n" % (ProfileReportLink,CurrentProfile,step,NumOfEvents))
887 if CurrentProfile ==
"memcheck_valgrind":
888 INDEX.write(
"<li><a href=\"%s\">%s %s %s (%s events)</a></li>\n" % (ProfileReportLink,CurrentProfile,Profiler,step,
"5"))
890 INDEX.write(
"<li><a href=\"%s\">%s %s %s (%s events)</a></li>\n" % (ProfileReportLink,CurrentProfile,Profiler,step,NumOfEvents))
891 def IgProfDumpsTable(INDEX,ProfileLinks,step):
893 EndOfJobProfileLink=
filter(
lambda x:
"IgProfMemTotal.res" in x
or "IgProfMemLive.res" in x, ProfileLinks)[0]
895 ProfileLinks.remove(EndOfJobProfileLink)
897 ProfileLinks.sort(key=
lambda x:
int(x.split(
".")[-2]))
899 IgProfMemLive_regexp=re.compile(
"IgProfMemLive")
900 if IgProfMemLive_regexp.search(EndOfJobProfileLink):
901 MemProfile=
"IgProf MEM LIVE" 903 MemProfile=
"IgProf MEM TOTAL" 905 INDEX.write(
"<li>%s"%MemProfile)
906 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>")
907 for link
in ProfileLinks:
909 gzProfile=os.path.join(link.split(
"/")[-3],link.split(
"/")[-1])[:-3]+
"gz" 910 if IgProfMemLive_regexp.search(gzProfile):
911 gzProfile=IgProfMemLive_regexp.sub(
r"IgProfMemTotal",gzProfile)
912 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))) 914 gzEndOfJobProfileLink=os.path.join(EndOfJobProfileLink.split(
"/")[-3],EndOfJobProfileLink.split(
"/")[-1])[:-3]+
"gz" 915 if IgProfMemLive_regexp.search(gzEndOfJobProfileLink):
916 gzEndOfJobProfileLink=IgProfMemLive_regexp.sub(
r"IgProfMemTotal",gzEndOfJobProfileLink)
917 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))) 919 INDEX.write(
"</table>")
926 DirName[0] : TimeSizeNumOfEvents,
927 DirName[1] : IgProfNumOfEvents,
928 DirName[2] : IgProfNumOfEvents,
929 DirName[3] : IgProfNumOfEvents,
930 DirName[4] : CallgrindNumOfEvents,
931 DirName[5] : MemcheckNumOfEvents,
932 DirName[6] : TimeSizeNumOfEvents,
933 DirName[7] : IgProfNumOfEvents,
934 DirName[8] : IgProfNumOfEvents,
935 DirName[9] : IgProfNumOfEvents,
936 DirName[10] : CallgrindNumOfEvents,
937 DirName[11] : MemcheckNumOfEvents
953 IgProfMemAnalyseOut=(
954 "doBeginJob_output.html",
955 "doEvent_output.html",
959 memcheck_valgrindOut=(
965 Profile[0] :
"*TimingReport.html",
966 Profile[1] :
"TimeReport.html",
967 Profile[2] :
"*.html",
968 Profile[3] :
"objects_pp.html",
969 Profile[4] :
"overall.html",
970 Profile[5] :
"overall.html",
971 Profile[6] :
"overall.html",
972 Profile[7] :
"doBeginJob_output.html",
973 Profile[8] :
"overall.html",
974 Profile[9] :
"beginjob.html" 978 candnreg = re.compile(
"CandleName")
979 candhreg = re.compile(
"CandlesHere")
981 CAND = open(candlHTML,
"w")
982 for line
in open(tmplfile):
983 if candhreg.search(line):
984 CAND.write(
'<div id="content">')
986 CAND.write(CurrentCandle)
987 CAND.write(
"</h2>\n")
990 print(
"Producing candles html: ", CurrentCandle)
992 for CurDir
in DirName:
994 LocalPath = os.path.join(repdir,
"%s_%s" % (CurrentCandle,CurDir))
995 LocalDirname = os.path.basename(LocalPath)
997 if not prevrev ==
"":
1002 if CurDir == DirName[0]
or CurDir == DirName[6]:
1003 profs = Profile[0:4]
1004 elif CurDir == DirName[1]
or CurDir == DirName[7]:
1005 profs = Profile[4:8]
1006 elif CurDir == DirName[2]
or CurDir == DirName[8]:
1008 elif CurDir == DirName[3]
or CurDir == DirName[9]:
1010 elif CurDir == DirName[4]
or CurDir == DirName[10]:
1011 profs = [Profile[8]]
1012 elif CurDir == DirName[5]
or CurDir == DirName[11]:
1013 profs = [Profile[9]]
1018 print(
"Scanning for profile information for: ", prof)
1021 fullprof = (CurrentCandle,prof)
1024 if prof ==
"TimingReport":
1025 timeReports = glob.glob(os.path.join(LocalPath,
"%s_*_%s.log" % (CandFname[CurrentCandle],prof)))
1026 if len(timeReports) > 0:
1028 CAND.write(
"<p><strong>%s %s</strong></p>\n" % (prof,
"Regression Analysis"))
1030 for log
in timeReports:
1031 reportName = os.path.basename(log)
1033 CAND.write(
"<h4>%s</h4>\n" % reportName)
1034 htmNames = [
"changes.png"]
1035 otherNames = [
"graphs.png" ,
"histos.png"]
1036 regressHTML=
"%s-regress.html" % nologext
1037 pathsExist = reduce (
lambda x,y: x
or y,
map(os.path.exists,
map(
lambda x: os.path.join(repdir,outd,x),otherNames)))
1040 html =
"<p>Performance graphs and histograms superimposed for %s are <a href=\"%s\">here</a></p>\n" % (reportName,regressHTML)
1042 html =
"<p>No change in performance graph available</p>\n" 1043 regressHTML=
"%s/%s" % (WebArea,regressHTML)
1046 abspath = os.path.join(repdir,outd,x)
1047 if os.path.exists(abspath):
1048 html +=
"<p><a href=\"./%s/%s\"><img src=\"./%s/%s\" /></a></p>\n" % (outd,x,outd,x)
1050 html +=
"<p>%s does not exist probably because the log file for the previous release was missing</p>" % (abspath)
1054 CAND.write(
"\n</tr></table>")
1057 elif prof ==
"SimpleMemReport":
1058 simMemReports = glob.glob(os.path.join(LocalPath,
"%s_*_%s" % (CandFname[CurrentCandle],prof)))
1059 simMemReports =
map(
lambda x: (CandFname[CurrentCandle],prof,x), simMemReports )
1060 simMemReports.sort(cmp=dirname_cmp)
1061 simMemReports =
map(
lambda x: x[2], simMemReports )
1062 if len(simMemReports) > 0:
1064 CAND.write(
"<p><strong>%s %s</strong></p>\n" % (prof,
"Regression Analysis"))
1066 for adir
in simMemReports:
1067 reportName = os.path.basename(adir)
1068 CAND.write(
"<h4>%s</h4>\n" % reportName)
1069 htmNames = [
"vsize_change.png",
"rss_change.png"]
1070 otherNames = [
"vsize_graphs.png",
"rss_graphs.png"]
1071 nologext = reportName
1073 regressHTML=
"%s-regress.html" % nologext
1074 pathsExist = reduce (
lambda x,y: x
or y,
map(os.path.exists,
map(
lambda x: os.path.join(repdir,LocalDirname,outd,x),otherNames)))
1077 html =
"<p>Superimposed memory performance graphs for %s are <a href=\"%s\">here</a></p>\n" % (reportName,regressHTML)
1079 html =
"<p>No change in performance graph available</p>\n" 1080 regressHTML=
"%s/%s" % (WebArea,regressHTML)
1083 abspath = os.path.join(repdir,LocalDirname,outd,x)
1084 if os.path.exists(abspath):
1085 html +=
"<p><a href=\"./%s/%s/%s\"><img src=\"./%s/%s/%s\" /></a></p>\n" % (LocalDirname,outd,x,LocalDirname,outd,x)
1087 html +=
"<p>%s does not exist probably because the log file for the previous release was missing</p>" % (abspath)
1089 createRegressHTML(regressHTML,repdir,
"%s/%s" % (LocalDirname,outd),CurrentCandle,otherNames)
1091 CAND.write(
"\n</tr></table>")
1093 elif prof ==
"EdmSize" or prof ==
"IgProfMemTotal" or prof ==
"IgProfMemLive" or prof==
"IgProfperf" or prof ==
"Callgrind":
1094 regresPath = os.path.join(LocalPath,
"%s_*_%s_regression" % (CandFname[CurrentCandle],prof))
1095 regresses = glob.glob(regresPath)
1096 stepreg = re.compile(
"%s_([^_]*(_PILEUP)?)_%s_regression" % (CandFname[CurrentCandle],prof))
1097 if len(regresses) > 0:
1099 CAND.write(
"<p><strong>%s %s</strong></p>\n" % (prof,
"Regression Analysis"))
1101 regresses =
map(
lambda x: (CandFname[CurrentCandle],prof,x),regresses)
1102 regresses.sort(cmp=reg_dirname_cmp)
1103 regresses =
map(
lambda x: x[2],regresses)
1104 for rep
in regresses:
1105 base = os.path.basename(rep)
1106 found = stepreg.search(base)
1107 step =
"Unknown-step" 1109 step = found.groups()[0]
1111 if prof ==
"IgProfMemLive" or prof ==
"IgProfMemTotal" or prof==
"IgProfperf" or prof ==
"Callgrind":
1112 htmlpage =
"overall.html" 1114 htmlpage =
"objects_pp.html" 1115 CAND.write(
"<a href=\"%s/%s/%s\">%s %s regression report</a><br/>\n" % (LocalDirname,base,htmlpage,prof,step))
1118 if os.path.exists(LocalPath):
1119 thedir = os.listdir(LocalPath)
1120 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)]
1122 if (len(CandleLogFiles)>0):
1124 syscp(CandleLogFiles,WebArea +
"/")
1125 base = os.path.basename(LocalPath)
1128 for cand
in CandleLogFiles:
1129 cand = os.path.basename(cand)
1131 print(
"Found %s in %s\n" % (cand,LocalPath))
1133 if not "EdmSize" in cand:
1134 lfileshtml +=
"<a href=\"./%s/%s\">%s </a><br/>" % (base,cand,cand)
1136 CAND.write(
"<p><strong>Logfiles for %s</strong></p>\n" % CurDir)
1137 CAND.write(lfileshtml)
1140 for CurrentProfile
in Profile:
1145 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1149 OutputHtml[CurrentProfile])
1152 isProfinLink =
False 1153 if len (ProfileReportLink) > 0:
1154 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1159 if (PrintedOnce==
False):
1163 CAND.write(
"<p><strong>%s</strong></p>\n" % CurDir)
1164 CAND.write(
"<ul>\n")
1169 if (CurrentProfile == Profile[5]
or CurrentProfile == Profile[6]):
1170 for prolink
in ProfileReportLink:
1171 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir])
1172 for igprofmem
in [
"*IgProfMemTotal*.res",
"*IgProfMemLive*.res"]:
1173 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1178 isProfinLink =
False 1179 if len (ProfileReportLink) > 0:
1180 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1183 IgProfDumpsTable(CAND,ProfileReportLink,step)
1186 elif (CurrentProfile == Profile[7]):
1187 for igprof
in IgProfMemAnalyseOut:
1188 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1193 isProfinLink =
False 1194 if len (ProfileReportLink) > 0:
1195 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1197 for prolink
in ProfileReportLink:
1198 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir],Profiler=igprof)
1201 elif (CurrentProfile == Profile[9]):
1203 for memprof
in memcheck_valgrindOut:
1205 ProfileReportLink = _getProfileReportLink(repdir,CurrentCandle,
1211 isProfinLink =
False 1212 if len (ProfileReportLink) > 0:
1213 isProfinLink = reduce(
lambda x,y: x
or y,
map(
lambda x: CurrentProfile
in x,ProfileReportLink))
1215 for prolink
in ProfileReportLink:
1216 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir],Profiler=memprof)
1219 for prolink
in ProfileReportLink:
1220 if "regression" not in prolink:
1221 _writeReportLink(CAND,prolink,CurrentProfile,step,NumOfEvents[CurDir])
1226 CAND.write(
"</ul>\n")
1229 CAND.write(
"<hr />")
1230 CAND.write(
"<br />\n")
1231 CAND.write(
"</div>\n")
1232 elif candnreg.search(line):
1233 CAND.write(CurrentCandle)
1238 except IOError
as detail:
1239 print(
"ERROR: Could not write candle html %s because %s" % (os.path.basename(candlHTML),detail))
1244 for cand
in Candles:
1245 fname = CandFname[cand]
1246 globpath = os.path.join(repdir,
"%s_TimeSize" % cand,
"%s_*_TimingReport" % fname)
1247 stepDirs = glob.glob(globpath)
1248 stepDirs =
map(
lambda x: (fname,x), stepDirs)
1249 stepDirs.sort(cmp=timerep_cmp)
1250 stepDirs =
map(
lambda x: x[1], stepDirs)
1251 stepreg = re.compile(
"%s_(.*)_TimingReport" % fname)
1256 for stepdir
in stepDirs:
1257 base = os.path.basename(stepdir)
1258 found = stepreg.search(base)
1259 step =
"Unknown-step" 1261 step = found.groups()[0]
1262 realstep =
"Unknown-step" 1263 if "PILEUP" in step:
1264 found = pureg.search(step)
1266 realstep = found.groups()[0]
1270 rootf = os.path.join(stepdir,rootfile)
1272 if os.path.exists(rootf):
1273 f = ROOT.TFile(rootf)
1275 cpu_time_tree = ROOT.TTree()
1276 f.GetObject(
"cpu_time_tuple;1",cpu_time_tree)
1278 if cpu_time_tree.InheritsFrom(
"TTree"):
1281 for t
in cpu_time_tree:
1286 createNewRow =
False 1287 curRow = table.newRow(cand)
1288 data_tuple = (data1,data2)
1290 if "PILEUP" in step:
1291 puRow.addEntry(realstep,data_tuple)
1294 createNewRow =
False 1295 curRow = table.newRow(cand)
1297 curRow.addEntry(step,data_tuple)
1302 table.addRow(puRow,
"%s PILEUP" %cand)
1307 cols = len(ordered_keys)
1308 totcols = (cols * 3) + 1
1310 colspan = totcols - 1
1313 labels = [
"fs1",
"fs2",
"Δ"]
1314 elif mode == 2
or mode == 3:
1318 labels = [
"t1" ,
"t2" ,
"Δ"]
1321 INDEX.write(
"<h3>%s</h3>\n" % header)
1322 INDEX.write(
"<table>\n")
1323 INDEX.write(
"<caption>%s</caption>\n" % caption)
1324 INDEX.write(
"<thead><tr><th></th><th colspan=\"%s\" scope=\"colgroup\">%s</th></tr></thead>" % (colspan,name))
1325 INDEX.write(
"<tbody>\n")
1326 for key
in ordered_keys:
1329 INDEX.write(
"<th></th>")
1331 INDEX.write(
"<td scope=\"row\">")
1333 INDEX.write(
"</td>")
1334 for col
in table_dict[
None]:
1336 INDEX.write(
"<th colspan=\"%s\" scope=\"col\">" % innercol)
1338 INDEX.write(
"</th>")
1340 rowdict = table_dict[key].getRowDict()
1345 INDEX.write(
"%s" % dat)
1346 INDEX.write(
"</td>")
1351 INDEX.write(
"%6.2f" % dat)
1352 INDEX.write(
"</td>")
1354 (data1, data2) = rowdict[col]
1355 diff = data2 - data1
1362 seq = [ data1, data2, diff ]
1364 INDEX.write(
"<td id=\"data\">")
1366 INDEX.write(
"%s" % dat)
1368 INDEX.write(
"%6.2f" % dat)
1370 INDEX.write(
"</td>")
1372 if mode == 2
or mode == 3:
1375 INDEX.write(
"</td>")
1380 INDEX.write(
"</td>")
1381 INDEX.write(
"</tr>\n")
1384 if not (mode == 2
or mode == 3 ):
1387 INDEX.write(
"<th>Candles</th>")
1388 for col
in table_dict[
None]:
1389 INDEX.write(
"<th>%s</th>" % labels[0])
1390 INDEX.write(
"<th>%s</th>" % labels[1])
1391 INDEX.write(
"<th>%s</th>" % labels[2])
1392 INDEX.write(
"</tr>\n")
1393 INDEX.write(
"</tbody></table>\n")
1395 INDEX.write(
"<br />")
1398 '''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.''' 1401 if ":" in remotedir:
1402 (host,dir)=remotedir.split(
":")
1403 mkdir_cmd=
"ssh %s (mkdir %s;mkdir %s/%s)"%(host,dir,dir,arch)
1405 mkdir_cmd=
"mkdir %s;mkdir %s/%s"%(remotedir,remotedir,arch)
1410 os.system(mkdir_cmd)
1411 print(
"Successfully created publication directory")
1413 print(
"Issues with publication directory existence/creation!")
1418 if ":" in remotedir:
1419 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)
1421 tarpipe_cmd=
'tar cf - *_IgProf_*/*.sql3 | (cd %s/%s; mkdir %s; cd %s; tar xf -; mv *_IgProf_*/*.sql3 .; rmdir *_IgProf_*)'%(remotedir,arch,version,version)
1426 os.system(tarpipe_cmd)
1427 print(
"Successfully copied IgProf reports to %s"%remotedir)
1429 print(
"Issues with rsyncing to the remote directory %s!"%remotedir)
1432 if ":" in remotedir:
1433 chmod_cmd=
"ssh %s chmod -R 775 %s/%s"%(host,dir,arch)
1435 chmod_cmd=
"chmod -R 775 %s/%s"%(remotedir,arch)
1438 os.system(chmod_cmd)
1439 print(
"Successfully set permissions for IgProf reports directory %s"%remotedir)
1441 print(
"(Potential) issues with chmoding the remote directory %s!"%remotedir)
1456 CmsDriverCandle = CandFname
1460 IndexFile=
"%s/index.html" % WebArea
1461 TemplateHtml=
"%s/doc/index.html" % BASE_PERFORMANCE
1463 cmsverreg = re.compile(
"CMSSW_VERSION")
1464 hostreg = re.compile(
"HOST")
1465 lpathreg = re.compile(
"LocalPath")
1466 fsizereg = re.compile(
"FSizeTable")
1467 cpureg = re.compile(
"CPUTable")
1468 proddreg = re.compile(
"ProductionDate")
1469 logfreg = re.compile(
"LogfileLinks")
1470 dirbreg = re.compile(
"DirectoryBrowsing")
1471 pubdreg = re.compile(
"PublicationDate")
1472 candhreg = re.compile(
"CandlesHere")
1476 CandlTmpltHTML=
"%s/doc/candle.html" % BASE_PERFORMANCE
1478 print(
"Copying %s/doc/perf_style.css style file to %s/." % (BASE_PERFORMANCE,WebArea))
1479 print(
"Template used: %s" % TemplateHtml)
1481 syscp((BASE_PERFORMANCE +
"/doc/perf_style.css"),WebArea +
"/.")
1482 pureg = re.compile(
"(.*)_PILEUP")
1484 INDEX = open(IndexFile,
"w")
1485 for NewFileLine
in open(TemplateHtml) :
1486 if cmsverreg.search(NewFileLine):
1488 INDEX.write(
"Performance Reports for %s\n" % CMSSW_VERSION)
1490 globpath = os.path.join(repdir,
"REGRESSION.%s.vs.*" % (prevrev))
1491 globs = glob.glob(globpath)
1495 latestreg = re.compile(
"REGRESSION.%s.vs.(.*)" % prevrev)
1496 found = latestreg.search(os.path.basename(globs[0]))
1498 latestrel = found.groups()[0]
1499 INDEX.write(
"Performance Reports with regression: %s VS %s\n" % (prevrev,latestrel))
1501 INDEX.write(
"Performance Reports with regression: %s VS %s\n" % (prevrev,CMSSW_VERSION))
1502 elif hostreg.search(NewFileLine):
1503 INDEX.write(HOST +
"\n")
1505 elif fsizereg.search(NewFileLine):
1510 for cand
in Candles:
1511 fname = CandFname[cand]
1512 globpath = os.path.join(repdir,
"%s*_TimeSize" % cand,
"%s_*.root" % fname)
1513 rootfiles = glob.glob(globpath)
1514 rootfiles =
map(
lambda x: (fname,x), rootfiles)
1515 rootfiles.sort(cmp=rootfile_cmp)
1516 rootfiles =
map(
lambda x: x[1], rootfiles)
1517 stepreg = re.compile(
"%s_(.*).root" % fname)
1522 for rootf
in rootfiles:
1523 base = os.path.basename(rootf)
1524 found = stepreg.search(base)
1525 step =
"Unknown-step" 1527 step = found.groups()[0]
1528 realstep =
"Unknown-step" 1529 if "PILEUP" in step:
1530 found = pureg.search(step)
1532 realstep = found.groups()[0]
1535 puRow =
Row(fsize_tab)
1537 statinfo = os.stat(rootf)
1538 fsize = statinfo.st_size
1540 createNewRow =
False 1541 curRow = fsize_tab.newRow(cand)
1543 if "PILEUP" in step:
1544 puRow.addEntry(realstep,fsize)
1547 createNewRow =
False 1548 curRow = fsize_tab.newRow(cand)
1550 curRow.addEntry(step,fsize)
1551 except IOError
as detail:
1553 except OSError
as detail:
1558 fsize_tab.addRow(puRow,
"%s PILEUP" %cand)
1559 (ordered_keys,table_dict) = fsize_tab.getTable(1)
1560 cols = len(ordered_keys)
1562 if len(table_dict) > 1
and cols > 0:
1564 "Release ROOT file sizes",
1565 "Table showing current release ROOT filesizes in (k/M/G) bytes.",
1570 globpath = os.path.join(repdir,
"REGRESSION.%s.vs.*" % (prevrev))
1571 globs = glob.glob(globpath)
1573 raise IOError(2,globpath,
"File does not exist",
"File does not exist")
1574 idfile = open(globs[0])
1578 oldpath = oldpath.strip()
1582 for cand
in Candles:
1583 fname = CandFname[cand]
1584 globpath = os.path.join(repdir,
"%s*_TimeSize" % cand,
"%s_*.root" % fname)
1585 rootfiles = glob.glob(globpath)
1586 rootfiles =
map(
lambda x: (fname,x), rootfiles)
1587 rootfiles.sort(cmp=rootfile_cmp)
1588 rootfiles =
map(
lambda x: x[1], rootfiles)
1589 stepreg = re.compile(
"%s_(.*).root" % fname)
1594 for rootf
in rootfiles:
1595 base = os.path.basename(rootf)
1596 found = stepreg.search(base)
1597 step =
"Unknown-step" 1599 step = found.groups()[0]
1601 realstep =
"Unknown-step" 1602 if "PILEUP" in step:
1603 found = pureg.search(step)
1605 realstep = found.groups()[0]
1608 puRow =
Row(fsize_tab)
1610 statinfo = os.stat(rootf)
1611 fsize2 = statinfo.st_size
1612 oldfile = os.path.join(oldpath,
"%s_TimeSize" % cand,base)
1613 if "PILEUP" in step:
1614 oldfile = os.path.join(oldpath,
"%s_PU_TimeSize" % cand,base)
1617 if os.path.exists(oldfile):
1618 statinfo = os.stat(oldfile)
1619 fsize1 = statinfo.st_size
1621 print(
"######DID NOT FIND Previous file (needed for the filesize table): %s"%oldfile)
1624 createNewRow =
False 1625 curRow = fsize_tab.newRow(cand)
1627 data_tuple = (fsize1,fsize2)
1628 if "PILEUP" in step:
1629 puRow.addEntry(realstep,data_tuple)
1632 createNewRow =
False 1633 curRow = fsize_tab.newRow(cand)
1635 curRow.addEntry(step,data_tuple)
1636 except IOError
as detail:
1638 except OSError
as detail:
1643 fsize_tab.addRow(puRow,
"%s PILEUP" %cand)
1645 (ordered_keys,table_dict) = fsize_tab.getTable()
1646 cols = len(ordered_keys)
1648 if len(table_dict) > 1
and cols > 0:
1650 "Release ROOT file sizes",
1651 "Table showing previous release ROOT filesizes, fs1, latest sizes, fs2, and the difference between them Δ in (k/M/G) bytes.",
1653 except IOError
as detail:
1655 except OSError
as detail:
1658 elif cpureg.search(NewFileLine):
1663 for cand
in Candles:
1664 fname = CandFname[cand]
1665 globpath = os.path.join(repdir,
"%s*_TimeSize" % cand,
"%s_*_TimingReport.log" % fname)
1666 logfiles = glob.glob(globpath)
1667 logfiles =
map(
lambda x: (fname,x), logfiles)
1668 logfiles.sort(cmp=logrep_cmp)
1669 logfiles =
map(
lambda x: x[1], logfiles)
1671 stepreg = re.compile(
"%s_(.*)_TimingReport.log" % fname)
1676 for log
in logfiles:
1677 base = os.path.basename(log)
1678 found = stepreg.search(base)
1679 step =
"Unknown-step" 1681 step = found.groups()[0]
1683 realstep =
"Unknown-step" 1684 if "PILEUP" in step:
1685 found = pureg.search(step)
1687 realstep = found.groups()[0]
1690 puRow =
Row(time_tab)
1692 data = cpr.getTimingLogData(log)
1695 for evtnum, time
in data:
1699 mean = mean /
float(i)
1700 except ZeroDivisionError
as detail:
1701 print(
"WARNING: Could not calculate mean CPU time from log because no events could be parsed", log)
1703 if "PILEUP" in step:
1704 puRow.addEntry(realstep,mean)
1707 createNewRow =
False 1708 curRow = time_tab.newRow(cand)
1710 curRow.addEntry(step,mean)
1714 time_tab.addRow(puRow,
"%s PILEUP" %cand)
1716 (ordered_keys,table_dict) = time_tab.getTable(1)
1717 cols = len(ordered_keys)
1719 if len(table_dict) > 1
and cols > 0:
1721 "Release CPU times",
1722 "Table showing current release CPU times in secs.",
1740 (ordered_keys,table_dict) = cpu_time_tab.getTable()
1742 cols = len(ordered_keys)
1743 if len(table_dict) > 1
and cols > 0:
1745 "Release CPU times",
1746 "Table showing previous release CPU times, t1, latest times, t2, and the difference between them Δ in secs.",
1751 elif lpathreg.search(NewFileLine):
1752 INDEX.write(repdir +
"\n")
1753 elif proddreg.search(NewFileLine):
1754 INDEX.write(ExecutionDate +
"\n")
1755 elif logfreg.search(NewFileLine):
1756 INDEX.write(
"<br />\n")
1757 for log
in LogFiles:
1758 log = os.path.basename(log)
1760 print(
"linking log file %s" % log)
1761 INDEX.write(
"<a href=\"./%s\"> %s </a>" % (log,log))
1762 INDEX.write(
"<br />\n")
1764 INDEX.write(
"Results for cmsScimark2 benchmark (running on the other cores) available at:\n")
1765 for cmssci
in cmsScimarkResults:
1766 scimarkdirs=cmssci.split(
"/")
1767 localdir=scimarkdirs[-2]
1769 cmssci = os.path.basename(cmssci)
1770 relativelink=os.path.join(localdir,cmssci)
1772 INDEX.write(
"<a href=\"%s\"> %s </a>" % (relativelink,cmssci))
1773 INDEX.write(
"<br />\n")
1776 elif dirbreg.search(NewFileLine):
1784 INDEX.write(
"Click <a href=\"./DirectoryBrowsing/\">here</a> to browse the directory containing all results (except the root files)\n")
1786 elif pubdreg.search(NewFileLine):
1787 INDEX.write(date +
"\n")
1788 elif candhreg.search(NewFileLine):
1789 for acandle
in Candle:
1790 globpath = os.path.join(repdir,
"%s_*" % acandle)
1791 globs = glob.glob(globpath)
1793 candlHTML =
"%s.html" % acandle
1794 INDEX.write(
"<a href=\"./%s\"> %s </a>" % (candlHTML,acandle))
1795 INDEX.write(
"<br />\n")
1797 candlHTML=os.path.join(WebArea,candlHTML)
1798 createCandlHTML(CandlTmpltHTML,candlHTML,acandle,WebArea,repdir,ExecutionDate,LogFiles,cmsScimarkResults,date,prevrev)
1800 INDEX.write(NewFileLine)
1804 except IOError
as detail:
1805 print(
"Error: Could not create index Html file for some reason, check position. Details : %s" % detail)
1812 Dir = os.listdir(repdir)
1813 def _containsDirName(elem):
1814 return reduce(
lambda x,y: x
or y,
map(
lambda x: x
in elem, DirName))
1815 def _print4Lambda(elem,WebArea):
1817 print(
"Copying %s to %s\n" % (elem,WebArea))
1819 dirstocp = [x
for x
in map(
lambda x: repdir + x,Dir)
if _containsDirName(x)]
1820 map(
lambda x: _print4Lambda(x,WebArea),dirstocp)
1821 syscp(dirstocp,WebArea +
"/")
1822 os.mkdir(
"%s/DirectoryBrowsing" % WebArea)
1823 for file
in os.listdir(WebArea):
1824 if file !=
"index.html":
1826 os.symlink(
"%s/%s"%(
"..",file),
"%s/DirectoryBrowsing/%s" % (WebArea,file))
1837 args =
"--port=%s %s %s:%s" % (port,os.path.normpath(stage),drive,path)
1840 print(cmd +
" --dry-run " + args)
1841 retval = os.system(cmd +
" --dry-run " + args )
1844 retval = os.system(cmd +
" " + args)
1851 if os.path.exists(TMP_DIR)
and IS_TMP:
1852 os.system(
"rm -Rf " + TMP_DIR)
1859 def _walkpath(path):
1862 head , tail = os.path.split(path)
1867 for i
in range(len(dirs)-1,-1,-1):
1871 pwalk = _walkpath(parent)
1877 except StopIteration:
1883 cwalk = _walkpath(child)
1888 except StopIteration:
1889 print(
"ERROR: Unable to determine relative dir")
1895 relpath=os.path.join(relpath,
next(cwalk))
1896 except StopIteration:
1903 except OSError
as detail:
1904 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1905 except IOError
as detail:
1906 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1909 print(
"Copied %s to %s" % (src,dest))
1912 def _getNewLocation(source,child,dst,keepTop=keepTop):
1914 return os.path.join(dst,place)
1915 def _copyFilter(source,dst,curdir,fsnodes,filter,dirs=False):
1916 for node
in fsnodes:
1918 filterExist =
not len(filter) == 0
1920 dontFilter =
not reduce(
lambda x,y: x
or y,
map(
lambda x: fnmatch.fnmatch(node,x),filter))
1922 node = os.path.join(curdir,node)
1924 newnode = _getNewLocation(source,node,dst)
1929 except IOError
as detail:
1930 print(
"WARNING: Could not copy %s to %s because %s" % (node,newnode,detail))
1931 except OSError
as detail:
1932 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1933 except ReldirExcept:
1934 print(
"WARNING: Could not determine new location for source %s into destination %s" % (source,dst))
1938 match = fnmatch.fnmatch(node,filter[0])
1940 except AssertionError
as detail:
1941 print(node, filter[0], match)
1945 print(
"Filter %s Copied %s to %s" % (dontFilter,node,newnode))
1946 print(
"fnmatch %s" % fnmatch.fnmatch(node,cpFileFilter[0]))
1950 newloc = _getNewLocation(src,src,dest)
1960 _copyFilter(src,dest,curdir,dirs,cpDirFilter,dirs=
True)
1961 _copyFilter(src,dest,curdir,files,cpFileFilter)
1963 except StopIteration:
1965 except IOError
as detail:
1966 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1967 except OSError
as detail:
1968 print(
"WARNING: Could not copy %s to %s because %s" % (src,dest,detail))
1969 except ReldirExcept:
1970 print(
"WARNING: Could not determine the new location for source %s into destination %s" % (src,dest))
1973 if isinstance(srcs, type(
"")):
1974 if os.path.exists(srcs):
1975 if os.path.isdir(srcs):
1980 print(
"ERROR: file to be copied %s does not exist" % foo)
1983 if os.path.exists(src):
1984 if os.path.isdir(src):
1990 print(
"ERROR: file to be copied %s does not exist" % foo)
1993 print(
"%s\n" % PROG_NAME)
1995 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.