diff --git a/contrib/mkHTML.py b/contrib/mkHTML.py --- a/contrib/mkHTML.py +++ b/contrib/mkHTML.py @@ -1,282 +1,291 @@ #!/usr/bin/env python -import os, sys, yoda +import os, sys, yoda, collections,operator -PREF=sys.argv[2] -def find_tests(root_dir=sys.argv[1]): + +def find_tests(root_dir="./"): for dirpath, dirs, files in os.walk(root_dir): - if not dirs: + if "ref.yoda" in files: yield dirpath -def readObs(tname): - fname = "observables_%s"%tname +def readObs(): + fname = "observables" if not os.path.exists(fname): print "could not find file %s"%fname return [] with open(fname) as f: onames=[l.strip() for l in f if not l.startswith("#") and not len(l.strip()) ==0] return sorted(onames) def gof(a, b): temp = 0.0 N=0 if type(a)==yoda.core.Histo1D or type(b)==yoda.core.Histo1D: for num, x in enumerate(a.bins): if (x.heightErr>0 or b.bins[num].heightErr>0): N+=1 temp += (x.height - b.bins[num].height)**2 / (x.heightErr**2 + b.bins[num].heightErr**2) elif type(a)==yoda.core.Scatter2D or type(b)==yoda.core.Scatter2D: for num, x in enumerate(a.points): N+=1 temp += (x.y - b.points[num].y)**2 else: print "Comparison of", type(a), "with", type(b), "not implemented" return if N>0: return temp/(N) else: return -1 # Taken from andy's tune killing effort def mk_css_colorstr(x, xbad=2.0): h, s, b = mk_hsbcolor(x, xbad) colorstr = "hsl(%d,%d%%,%d%%)" % (h, 100*s, 100*b) return colorstr def mk_hsbcolor(x, xbad=2.0): "Return a 3-tuple in the Hsb (angle, mag, mag) scheme, where angle is in degrees and the two magnitudes are in [0,1]." # def transfer_function(x): # return (1 + math.tanh(0.25*x - 20))/2 def transfer_function(x): return min(x/xbad, 1.0) #print x, transfer_function(x) h = int(120 * (1 - transfer_function(x))) # in degrees: red = 0, green = 120 s = 0.9 # in % l = 0.5 # in % return (h,s,l) -def mkPlots(f1, f2, obs): - test=f1.split("/")[1] - rev1=f1.rsplit("/")[-1].split("_")[-1].split(".yoda")[0] - rev2=f2.rsplit("/")[-1].split("_")[-1].split(".yoda")[0] - outdir="%s_plots"%PREF - cmd = "rivet-mkhtml --mc-errs -o %s/%s/%s-%s"%(outdir, test, rev1, rev2) +def mkPlots(test,f1,rev1, f2,rev2, obs): + outdir="%s"%test + cmd = "rivet-mkhtml --mc-errs -o %s"%test for o in obs: cmd += " -m %s"%o cmd += " %s:'%s' %s:'%s':ConnectGaps=1"%(f1,rev1,f2,rev2) - #print cmd + #print "////", cmd import os - if len(sys.argv)<=3: - if not os.path.exists("%s/%s/%s-%s"%(outdir, test, rev1, rev2)): - os.system(cmd) + if not os.path.exists("%s"%test): + os.system(cmd) + # os.system("mv %s/%s-%s %s/%s-%s.bac"%(test, rev1, rev2,test, rev1, rev2)) + # os.system("mv %s/%s-%s.tmp %s/%s-%s"%(test, rev1, rev2,test, rev1, rev2)) # Taken from andy's tune killing effort def htmlwrap2(content, title=None): html = " <style>\n" html += " body { font-family: Georgia, Tahoma, sans; }\n" html += " a { color: #11c; text-decoration: none; }\n" html += " table { border-collapse: collapse; margin-top: 1em; margin-bottom: 1em; }\n" html += " table { border-top: 2px solid black; border-bottom: 2px solid black; }\n" html += " table { border-left: 1px solid grey; border-right: 1px solid grey; }\n" html += " th { border-bottom: 1px solid black; }\n" html += " table, td, th { padding: 1ex; }\n" html += " td.metric { border: 1px dotted black; text-align: right; }\n" html += " td.rev { border-bottom: 1px solid black;border-top: 1px solid black; text-align: left; }\n" html += " td.na { border-bottom: 1px solid black;border-top: 1px solid black; text-align: center; }\n" html += " </style>\n" for line in content.splitlines(): html += " " + line + "\n" return html # Taken from andy's tune killing effort def htmlwrap(content, title=None): html = "<html>\n" html += "<head>\n" if title is not None: html += " <title>%s</title>\n" % title html += " <style>\n" html += " body { font-family: Georgia, Tahoma, sans; }\n" html += " a { color: #11c; text-decoration: none; }\n" html += " table { border-collapse: collapse; margin-top: 1em; margin-bottom: 1em; }\n" html += " table { border-top: 2px solid black; border-bottom: 2px solid black; }\n" html += " table { border-left: 1px solid grey; border-right: 1px solid grey; }\n" html += " th { border-bottom: 1px solid black; }\n" html += " table, td, th { padding: 1ex; }\n" html += " td.metric { border: 1px dotted black; text-align: right; }\n" html += " td.rev { border-bottom: 1px solid black;border-top: 1px solid black; text-align: left; }\n" html += " td.na { border-bottom: 1px solid black;border-top: 1px solid black; text-align: center; }\n" html += " </style>\n" html += " </head>\n" html += " <body>\n" if title is not None: html += " <h1>%s</h1>\n" % title html += "\n\n" for line in content.splitlines(): html += " " + line + "\n" html += "\n\n" html += " </body>\n" html += "<html>\n" return html # Taken from andy's tune killing effort def writetofile(text, dest): + destdir = os.path.dirname(dest) if not os.path.exists(destdir): os.makedirs(destdir) f = open(dest, "w") f.write(text) f.close() -def writeSummaryIndex(results): - testlabels=sorted(results.keys()) +def writeSummaryIndex(results,resultslist): html="" - html += "<a href='../all_tests'>Return to test selection</a>" + #html += "<a href='../all_tests'>Return to test selection</a>" html += " <h3>Mean goodness-of-fit (gof)</h3>\n" html += "The columns show the mean gof of the tests given in the table header<br>when comparing two consecutive revisions.\n" html += "<br><br>The gof for one observable is defined as: <b>Σ<sub>b</sub>(N<sub>b</sub>-M<sub>b</sub>)<sup>2</sup>/(σ<sub>N(b)</sub><sup>2</sup>+σ<sub>M(b)</sub><sup>2</sup>)</b> \n" html += "<br>where the sum runs over all bins b of the observable.<br>\n" html += "<br><br>Click on the gof score for detailed results.\n" html += "<table>\n" html += " <tr>\n" - for h in ["Revisions"] + testlabels: + + resultslist= sorted(resultslist, key=operator.itemgetter(1)) + + + + xlist=[x[0] for x in resultslist ] + print resultslist + + for h in [" "] + [x[1] for x in resultslist ]: + html += " <th>%s</th>\n" % h + html += " </tr>\n" + html += " <tr>\n" + for h in ["Revisions"] + xlist: html += " <th>%s</th>\n" % h html += " </tr>\n" - for revisions in reversed(sorted(results[testlabels[0]].keys())): + #print testlabels + #print results[testlabels[0]] + for revision in results.keys(): html += " <tr>\n" - html += " <td class='metric'>%s</td>\n" % revisions - for test in testlabels: + html += " <td class='metric'>%s</td>\n" % revision + for test in resultslist: + test=test[0] #print revisions - val = "—" - colorstr = "grey" - try: - groupmetrics = sum(results[test][revisions].values())/len(results[test][revisions]) + val = "—" + colorstr = "grey" + try: + groupmetrics = sum(results[revision][test].values())/len(results[revision][test]) val = "%0.2f" % groupmetrics - #val = "<a href='%s'>%s</a>" % ("../%s_results/%s_%s.html"%(PREF, test,revisions), val) - val = "<a href='%s'>%s</a>" % ("../%s_results/%s.html"%(PREF, test), val) + val = "<a href='%s'>%s</a>" % ("%s.html"%(test), val) colorstr = mk_css_colorstr(groupmetrics) html += " <td class='metric' style='background-color: %s;'>%s</td>\n" % (colorstr, val) - except: + except: html += " <td class='na'>---</td>\n" pass html += " </tr>\n" html += " </tr>\n" html += "</table>\n" - html = htmlwrap2(html, "Sherpa %s test summary"%PREF) - #html = htmlwrap(html, "Sherpa %s test summary"%PREF) - writetofile(html, os.path.join("html","index.html")) + html = htmlwrap2(html) + writetofile(html, os.path.join("./index.html")) -def writeTestResultBackup(testlabel, res): - for revisions in reversed(res.keys()): - html = "<a href='../%s_test'>Back to index page...</a>\n"%PREF - html += "<br><br>The gof for one observable is defined as: <b>Σ<sub>b</sub>(N<sub>b</sub>-M<sub>b</sub>)<sup>2</sup>/(σ<sub>N(b)</sub><sup>2</sup>+σ<sub>M(b)</sub><sup>2</sup>)</b> \n" - html += "<br>where the sum runs over all bins b of the observable.<br>\n" - html += "<br><br>Click on the gof score for plots.\n" - html += "<table>\n" - html += " <tr>\n" - for h in ["Observable"] + sorted(res[revisions].keys()): - html += " <th>%s</th>\n" % h - html += " </tr>\n" - - - html += " <tr>\n" - html += " <td class='metric'> <a href='../%s_plots/%s/%s/index.html'>%s</a> </td>\n" % (PREF, testlabel,revisions, revisions) - #html += " <td class='metric'> <a href='%s/index.html'>%s</a> </td>\n" % ( "../%s_plots/%s/%s"%(PREF, testlabel,revisions), revisions) - - for obs in sorted(res[revisions].keys()): - val = "—" - colorstr = "grey" - try: - metric = res[revisions][obs] - val = "%0.2f" % metric - val = "<a href='%s'>%s</a>" % ("../%s_plots/%s/%s/%s/%s.png"%(PREF,testlabel,revisions,obs.split("/")[1],obs.split("/")[2]), val) - colorstr = mk_css_colorstr(metric) - html += " <td class='metric' style='background-color: %s;'>%s</td>\n" % (colorstr, val) - except: - html += " <td class='na'>---</td>\n" - pass - - html += " </tr>\n" - html += " </tr>\n" - html += "</table>\n" - html = htmlwrap2(html, "Sherpa run test %s"%testlabel) - writetofile(html, os.path.join("html/%s_results"%PREF, "%s_%s.html"%(testlabel,revisions))) - -def writeTestResult(testlabel, res): - html = "<a href='../%s_test'>Back to index page...</a>\n"%PREF +def writeTestResult( res,allres): + html = "<a href='index.html'>Back to index page...</a>\n" html += "<br><br>The gof for one observable is defined as: <b>Σ<sub>b</sub>(N<sub>b</sub>-M<sub>b</sub>)<sup>2</sup>/(σ<sub>N(b)</sub><sup>2</sup>+σ<sub>M(b)</sub><sup>2</sup>)</b> \n" html += "<br>where the sum runs over all bins b of the observable.<br>\n" html += "<br><br>Click on the gof score for plots.\n" html += "<table>\n" html += " <tr>\n" - if len(res.keys()) < 1: - return + + obser=[] + for x in allres.values(): + if res in x.keys() : + obser+=x[res].keys() + + obser=list(set(obser)) - for h in ["Observable"] + sorted(res[res.keys()[0]].keys()): + + + for h in ["Revision vs. Observable"] + obser: html += " <th>%s</th>\n" % h.split("/")[-1] html += " </tr>\n" - for revisions in reversed(sorted(res.keys())): + for revision in allres.keys(): html += " <tr>\n" - html += " <td class='metric'> <a href='../%s_plots/%s/%s/index.html'>%s</a> </td>\n" % (PREF, testlabel,revisions, revisions) - #html += " <td class='metric'> <a href='%s/index.html'>%s</a> </td>\n" % ( "../%s_plots/%s/%s"%(PREF, testlabel,revisions), revisions) + html += " <td class='metric'> <a href='%s/%s/index.html'>%s</a> </td>\n" % (revision,res, "%s_%s"%(revision,res)) - for obs in sorted(res[revisions].keys()): + for obs in obser: val = "—" colorstr = "grey" try: - metric = res[revisions][obs] + metric = allres[revision][res][obs] val = "%0.2f" % metric - val = "<a href='%s'>%s</a>" % ("../%s_plots/%s/%s/%s/%s.png"%(PREF,testlabel,revisions,obs.split("/")[1],obs.split("/")[2]), val) + #print "revisions ", revisions + val = "<a href='%s'>%s</a>" % ("%s/%s/%s/%s.png"%(revision,res,obs.split("/")[1],obs.split("/")[2]), val) colorstr = mk_css_colorstr(metric) html += " <td class='metric' style='background-color: %s;'>%s</td>\n" % (colorstr, val) except: html += " <td class='na'>---</td>\n" pass html += " </tr>\n" html += "</table>\n" - html = htmlwrap2(html, "Sherpa run test %s"%testlabel) - writetofile(html, os.path.join("html/%s_results"%PREF, "%s.html"%(testlabel))) + html = htmlwrap2(html) -TESTS = list(find_tests()) + writetofile(html, os.path.join("./%s.html"%res)) +def sorted_ls(path): + mtime = lambda f: os.stat(os.path.join(path, f)).st_mtime + return list(sorted(os.listdir(path), key=mtime)) -RES={} -for t in TESTS: - yodas = [os.path.join(t,f) for f in sorted(os.listdir(t)) if f.endswith(".yoda") ] - thistest=t.split("/")[1] - OBS=readObs(thistest) - Y=[yoda.readYODA(f, patterns=OBS) for f in yodas] +def sorted_allyodas(): + mtime = lambda f: os.path.getmtime(f)#time.ctime()os.stat(f).st_ctime + allyodas=[] + for root, dir, files in os.walk("."): + allyodas+=[os.path.join(root, fi) for fi in files if fi.endswith(".yoda") and fi.count('-')>2 and "ref.yoda" in files] + return list(sorted(allyodas, key=mtime)) + + + +allyodas=sorted_allyodas() +#assume revission is the longest sting +revisions=reversed(list(set([sorted(yo.split("-"), key=len)[-1] for yo in allyodas]))) + +OBS=readObs() + +resultslist=[] +RES=collections.OrderedDict() +for rev in revisions: + if "/" not in rev: + results = {} - for i in xrange(1,len(Y)): - a=Y[0-i] - r_a=yodas[0-i].split(".")[0].split("_")[-1] - b=Y[0-(i+1)] - r_b=yodas[0-(i+1)].split(".")[0].split("_")[-1] + print rev + for yodax in allyodas: + if rev in yodax: + refpath=os.path.dirname(yodax)+"/ref.yoda" + ref=yoda.readYODA(os.path.join(os.path.dirname(yodax),"ref.yoda"), patterns=OBS) + + Y=yoda.readYODA(os.path.join(yodax), patterns=OBS) + r_a="ref" + a=ref + b=Y + r_b=yodax.split("/")[-1].split(".")[0] temp = {} for o in OBS: - try: - chi2 = gof(a[o], b[o]) - if chi2 is not None: - #print o, chi2 - temp[o]=chi2 - except Exception, e: - print "Error processing", o, e - results["%s-%s"%(r_a, r_b)] = temp - mkPlots(yodas[0-i], yodas[0-(i+1)], OBS) + try: + chi2 = gof(a[o], b[o]) + if chi2 is not None: + temp[o]=chi2 + except Exception, e: + pass + # print "Error processing", o, e + #exit() - RES[thistest]=results + results["%s"%(r_b.replace(rev,""))]= temp + if "%s"%(r_b.replace(rev,"")) not in [x[0] for x in resultslist]: + resultslist+=[["%s"%(r_b.replace(rev,"")),os.path.dirname(yodax).split("/")[-1]]] + mkPlots("%s/%s"%(rev,r_b.replace(rev,"")),refpath,r_a,yodax,r_b, OBS) + RES[rev]=results -writeSummaryIndex(RES) -for k, v in RES.iteritems(): - writeTestResult(k, v) +writeSummaryIndex(RES,resultslist) +#exit() +for result in resultslist: + #print "//>> ",k,v + writeTestResult(result[0], RES) import sys sys.exit(0) diff --git a/contrib/observables b/contrib/observables new file mode 100755 --- /dev/null +++ b/contrib/observables @@ -0,0 +1,106 @@ +/ALEPH_1991_S2435284/d01-x01-y01 +/ALEPH_1996_S3486095/d01-x01-y01 +/ALEPH_1996_S3486095/d04-x01-y01 +/ALEPH_1996_S3486095/d05-x01-y01 +/ALEPH_1996_S3486095/d18-x01-y01 +/ALEPH_1996_S3486095/d19-x01-y01 +/ALEPH_1996_S3486095/d37-x01-y01 +/ALEPH_1996_S3486095/d44-x01-y12 +/ALEPH_1996_S3486095/d44-x01-y15 +/ALEPH_1996_S3486095/d44-x01-y16 +/ALEPH_1999_S4193598/d01-x01-y01 +/ALEPH_2001_S4656318/d01-x01-y01 +/ALEPH_2002_S4823664/d03-x01-y02 +/ALEPH_2004_S5765862/d01-x01-y01 +/ALEPH_2004_S5765862/d141-x01-y01 +/ALEPH_2004_S5765862/d149-x01-y01 +/ALEPH_2004_S5765862/d187-x01-y01 +/ALEPH_2004_S5765862/d227-x01-y01 +/ALEPH_2004_S5765862/d54-x01-y01 +/ALEPH_2004_S5765862/d78-x01-y01 +/ALEPH_2004_S5765862/d86-x01-y01 +/ALEPH_2004_S5765862/d94-x01-y01 +/DELPHI_1995_S3137023/d02-x01-y01 +/DELPHI_1995_S3137023/d03-x01-y01 +/DELPHI_1996_S3430090/d01-x01-y01 +/DELPHI_1996_S3430090/d36-x01-y01 +/DELPHI_1996_S3430090/d36-x01-y08 +/DELPHI_1996_S3430090/d36-x01-y09 +/DELPHI_1996_S3430090/d40-x01-y01 +/DELPHI_1996_S3430090/d40-x01-y08 +/DELPHI_1999_S3960137/d01-x01-y01 +/DELPHI_1999_S3960137/d01-x01-y02 +/DELPHI_1999_S3960137/d01-x01-y03 +/DELPHI_2002_069_CONF_603/d01-x01-y01 +/DELPHI_2002_069_CONF_603/d02-x01-y01 +/DELPHI_2002_069_CONF_603/d05-x01-y01 +/JADE_OPAL_2000_S4300807/d09-x01-y01 +/JADE_OPAL_2000_S4300807/d09-x01-y04 +/JADE_OPAL_2000_S4300807/d18-x01-y02 +/JADE_OPAL_2000_S4300807/d26-x01-y01 +/JADE_OPAL_2000_S4300807/d26-x01-y02 +/OPAL_1994_S2927284/d01-x01-y01 +/OPAL_1994_S2927284/d02-x01-y01 +/OPAL_1997_S3396100/d02-x01-y01 +/OPAL_1997_S3396100/d07-x01-y01 +/OPAL_1997_S3396100/d12-x01-y01 +/OPAL_1997_S3608263/d01-x01-y01 +/OPAL_1998_S3702294/d02-x01-y01 +/OPAL_1998_S3749908/d02-x01-y01 +/OPAL_1998_S3749908/d07-x01-y01 +/OPAL_1998_S3749908/d10-x01-y01 +/OPAL_1998_S3780481/d02-x01-y01 +/OPAL_1998_S3780481/d09-x01-y01 +/OPAL_1998_S3780481/d09-x01-y04 +/OPAL_2000_S4418603/d03-x01-y01 +/OPAL_2001_S4553896/d03-x01-y01 +/OPAL_2004_S6132243/d01-x01-y01 +/OPAL_2004_S6132243/d05-x01-y01 +/OPAL_2004_S6132243/d06-x01-y01 +/OPAL_2004_S6132243/d25-x01-y01 +/OPAL_2004_S6132243/d26-x01-y01 +/PDG_HADRON_MULTIPLICITIES/d01-x01-y03 +/PDG_HADRON_MULTIPLICITIES/d15-x01-y03 +/PDG_HADRON_MULTIPLICITIES/d16-x01-y01 +/PDG_HADRON_MULTIPLICITIES/d54-x01-y02 +/SLD_1996_S3398250/d05-x01-y01 +/SLD_1999_S3743934/d07-x01-y01 +/SLD_1999_S3743934/d10-x01-y01 +/SLD_1999_S3743934/d34-x01-y02 +/SLD_2004_S5693039/d01-x01-y01 +/SLD_2004_S5693039/d02-x01-y02 +/SLD_2004_S5693039/d08-x02-y03 +/SLD_2004_S5693039/d09-x01-y03 +/ATLAS_2014_I1279489/d01-x02-y01 +/ATLAS_2014_I1279489/d01-x02-y02 +/ATLAS_2014_I1279489/d01-x02-y03 +/ATLAS_2014_I1279489/d01-x02-y04 +/ATLAS_2014_I1279489/d05-x04-y01 +/ATLAS_2014_I1279489/d05-x05-y01 +/MC_ZJETS/jet_HT +/_EVTCOUNT +/MC_ZINC/Z_y +/MC_ZJETS/jet_eta_pmratio_1 +/MC_ZJETS/Z_jet1_dR +/MC_ZINC/lepton_pT +/MC_ZJETS/jet_pT_1 +/MC_ZINC/Z_mass +/MC_ZINC/Z_phi +/MC_ZJETS/jet_y_pmratio_1 +/MC_ZJETS/jets_deta_12 +/MC_ZJETS/jet_y_2 +/MC_ZINC/Z_pT_peak +/MC_ZJETS/jet_y_1 +/MC_XS/XS +/MC_ZJETS/jet_multi_exclusive +/MC_ZJETS/jet_pT_2 +/MC_ZJETS/jet_multi_inclusive +/MC_ZINC/Z_pT +/MC_ZJETS/jet_mass_1 +/MC_XS/pmN +/MC_ZJETS/jets_dphi_12 +/MC_ZJETS/jets_dR_12 +/MC_ZJETS/jet_eta_2 +/MC_ZJETS/jet_eta_1 +/MC_ZJETS/Z_jet1_deta +/MC_ZINC/lepton_eta diff --git a/contrib/results.sh b/contrib/results.sh new file mode 100755 --- /dev/null +++ b/contrib/results.sh @@ -0,0 +1,5 @@ +#!/bin/bas +source /scratch/herwig_bootstrap/bin/activate +./mkHTML.py +chmod -R 755 * +exit 0 diff --git a/helper.py b/helper.py --- a/helper.py +++ b/helper.py @@ -1,225 +1,262 @@ from buildbot.plugins import * from buildbot.plugins import worker from buildbot.plugins import reporters +from buildbot.www.auth import HTPasswdAuth +#from buildbot.www.html import WebStatus import yaml +import os def fillDictFromFile(fileName): infoFile=open(fileName) info = yaml.safe_load(infoFile) infoFile.close() return info def buildTests(filename,masterConf,generalinfo): testinfo=fillDictFromFile(filename) ####### CHANGESOURCES - masterConf['change_source'].append( + + + if "svn+ssh" in testinfo['Repo']: + masterConf['change_source'].append( + changes.SVNPoller( + repourl=testinfo['Repo'], + project=testinfo['Name']) + ) + + + else: #assume hg + masterConf['change_source'].append( changes.HgPoller( repourl=testinfo['Repo'], workdir=testinfo['Dir'], branch=testinfo['Branch'], project=testinfo['Name'], - pollInterval=600) + pollInterval=600, + ) ) bnames=[] for builder,build in testinfo['Builders'].iteritems(): bnames+=[builder] ####### SCHEDULERS sbScheduler=schedulers.SingleBranchScheduler( name="SBS"+builder, change_filter=util.ChangeFilter(branch=testinfo['Branch'], project=testinfo['ProjectName']), treeStableTimer=testinfo['TreeStableTimer'], builderNames=[builder]) masterConf['schedulers'].append(sbScheduler) - environment=dict() + envi={} ####### BUILDERS try: - environment = {"PATH":build['AddPath']+os.environ["PATH"], - "PYTHONPATH":build['AddPythonPath']+os.environ["PYTHONPATH"]} + envi = { 'PATH' : '%s%s'%(build['AddPath'],os.environ["PATH"])} + for i in build['Enviroment']: + envi[i[0]]=i[1] except: pass + testFactory = util.BuildFactory() - testFactory = util.BuildFactory() - if build['CleanDir']: - testFactory.addStep(steps.RemoveDirectory(dir="%s/%s/%s/%s"%(generalinfo['SlaveDir'],testinfo['ProjectName'],testinfo['Dir'],testinfo['Branch']))) -# testFactory.addStep(steps.MakeDirectory(dir="build/build")) + workdirect="" + + if "svn+ssh" in testinfo['Repo']: + workdirect="%s/%s/%s"%(generalinfo['SlaveDir'],testinfo['ProjectName'],testinfo['Dir']) + if build['CleanDir']: + testFactory.addStep(steps.RemoveDirectory(dir=workdirect)) + testFactory.addStep(steps.SVN(repourl=testinfo["Repo"], + mode="full", + method="clobber", + env=envi, + workdir=workdirect)) + else: + testFactory.addStep(steps.SVN(repourl=testinfo["Repo"], + mode="full", + method="clean", + env=envi, + workdir=workdirect)) + + + + else: + if build['CleanDir']: + workdirect="%s/%s/%s/%s"%(generalinfo['SlaveDir'],testinfo['ProjectName'],testinfo['Dir'],testinfo['Branch']) + testFactory.addStep(steps.RemoveDirectory(dir=workdirect)) testFactory.addStep(steps.Mercurial(repourl=testinfo["Repo"], mode="full", method="clobber", defaultBranch=testinfo['Branch'], branchType="inrepo", - workdir="%s/%s/%s/%s"%(generalinfo['SlaveDir'],testinfo['ProjectName'],testinfo['Dir'],testinfo['Branch']))) - else: + env=envi, + workdir=workdirect)) + else: testFactory.addStep(steps.Mercurial(repourl=testinfo["Repo"], mode="full", method="clean", branchType="inrepo", + env=envi, defaultBranch=testinfo['Branch'], - workdir="%s/%s/%s/%s"%(generalinfo['SlaveDir'],testinfo['ProjectName'],testinfo['Dir'],testinfo['Branch']))) + workdir=workdirect)) cmds=[] lognum=1 for com in build['Test']: - testFactory.addStep(steps.ShellCommand(command=com.split(), env=environment,workdir="%s/%s/%s/%s"%(generalinfo['SlaveDir'],testinfo['ProjectName'],testinfo['Dir'],testinfo['Branch']))) - # cmds+=[util.ShellArg(command=com.split(),logfile='%s-%s'%(build["LogFile"],lognum))] + testFactory.addStep(steps.ShellCommand(command=com.split(),timeout=None, env=envi,workdir=workdirect)) lognum+=1 - # testFactory.addStep(steps.ShellSequence(commands=cmds, env=environment,workdir="build/work")) if build['Results']: - testFactory.addStep(steps.DirectoryUpload(workersrc="results", + testFactory.addStep(steps.DirectoryUpload(workersrc="%s"%build['YodaFolder'], masterdest=util.Interpolate(generalinfo['Results']+"/"+testinfo['Dir']+"/"+builder+"-%(prop:workername)s-%(prop:got_revision)s"), - url="~/buildbot/results", - workdir="%s/%s/%s/%s"%(generalinfo['SlaveDir'],testinfo['ProjectName'],testinfo['Dir'],testinfo['Branch']))) + url="~/buildbot/%s"%build['YodaFolder'], + workdir=workdirect)) try: for mvfile in build['YodaFiles']: - testFactory.addStep(steps.FileUpload(workersrc="results/%s"%mvfile, + testFactory.addStep(steps.FileUpload(workersrc="%s/%s"%(build['YodaFolder'],mvfile), masterdest=util.Interpolate(generalinfo['Results']+"/"+testinfo['Dir']+"/"+build['YodaFolder']+"/"+builder+"-%(prop:workername)s-%(prop:got_revision)s-"+mvfile), - workdir="%s/%s/%s/%s"%(generalinfo['SlaveDir'],testinfo['ProjectName'],testinfo['Dir'],testinfo['Branch']))) + workdir=workdirect)) except: pass ####### WORKERS masterConf['builders'].append( util.BuilderConfig(name=builder, workernames=build['Workers'], factory=testFactory)) forceScheduler=schedulers.ForceScheduler( name="force"+builder, builderNames=[builder]) masterConf['schedulers'].append(forceScheduler) bnames+=["force"+builder] - resultFactory = util.BuildFactory() resultFactory.addStep(steps.ShellCommand(command="bash results.sh".split(),workdir=generalinfo['Results'])) masterConf['builders'].append( util.BuilderConfig(name="result"+builder, workernames=[generalinfo["LocalWorker"]], factory=resultFactory)) masterConf['schedulers'].append(schedulers.Dependent(name="RESULTsb"+builder, upstream=sbScheduler, # <- no quotes! builderNames=["result"+builder])) masterConf['schedulers'].append(schedulers.Dependent(name="RESULTf"+builder, upstream=forceScheduler, # <- no quotes! builderNames=["result"+builder])) bnames+=["RESULTsb"+builder,"RESULTf"+builder] mn = reporters.MailNotifier( fromaddr=generalinfo['MailName'], sendToInterestedUsers=False, builders=bnames, extraRecipients=testinfo['Mail'], mode=('failing', 'change')) masterConf['services'].append(mn) def buildProject(generalinfo,masterConf,pwd): # the 'title' string will appear at the top of this buildbot installation's # home pages (linked to the 'titleURL'). masterConf['title'] = generalinfo['Title'] masterConf['titleURL'] = generalinfo['TitleURL'] masterConf['buildbotURL'] = generalinfo['BuildBotURL'] masterConf['protocols'] = {'pb': {'port': generalinfo['Port']}} # minimalistic config to activate new web UI - masterConf['www'] = dict(port=8433, + masterConf['www'] = dict(port=generalinfo['BuildBotPort'], plugins=dict(waterfall_view= {'lazy_limit_waterfall':500, 'num_builds': 500, 'scaling_waterfall':0.2}, console_view={}), + auth=util.UserPasswordAuth({generalinfo['WebsiteUser']: generalinfo['WebsitePassword']}) ) - masterConf['www']['auth']= util.UserPasswordAuth({generalinfo['WebsiteUser']: - generalinfo['WebsitePassword']}) + + authz = util.Authz( + allowRules=[ + util.StopBuildEndpointMatcher(role="admins"), + util.ForceBuildEndpointMatcher(role="admins"), + util.RebuildBuildEndpointMatcher(role="admins") + ], + roleMatchers=[ + util.RolesFromEmails(admins=[generalinfo['WebsiteUser']]) + ] + ) + masterConf['www']['authz'] = authz + masterConf['db'] = {'db_url' : "sqlite:///state.sqlite"} masterConf['workers'] = [] masterConf['builders'] = [] masterConf['services'] = [] masterConf['change_source'] = [] masterConf['schedulers'] = [] - - - # resDir="%s/results"%(pwd) - # if not os.path.exists(resDir): - # os.makedirs(resDir) - # os.chdir(resDir) - # os.sys("hg init") - - - - ####### WORKERS for computer in generalinfo['Workers']: masterConf['workers'].append(worker.Worker("%s"%computer[1] , generalinfo['Password'])) def writeScripts(generalinfo): #remote create slaves cS=open("createSlaves.sh","w") cS.write("#!/bin/bash\n") cS.write("#Create slaves\n") for slave in generalinfo['Workers']: cS.write("\nssh %s buildslave create-slave %s/%s %s:%s %s %s"%(slave[0],generalinfo['SlaveDir'],slave[1],generalinfo['MasterIP'],generalinfo['Port'],slave[1],generalinfo['Password'])) cS.close() #remote restart slaves rS=open("restartSlaves.sh","w") rS.write("#!/bin/bash\n") rS.write("#Restart slaves\n") for slave in generalinfo['Workers']: rS.write("\nssh %s buildslave stop %s/%s "%(slave[0],generalinfo['SlaveDir'],slave[1])) rS.write("\nssh %s buildslave start %s/%s "%(slave[0],generalinfo['SlaveDir'],slave[1])) rS.close() diff --git a/install_buildbot.sh b/install_buildbot.sh --- a/install_buildbot.sh +++ b/install_buildbot.sh @@ -1,22 +1,23 @@ #!/usr/bin/bash VERSION=0.9.0rc1 sudo pip install --upgrade pip sudo pip install \ buildbot==${VERSION} \ buildbot-worker==${VERSION} \ buildbot-waterfall-view==${VERSION} \ buildbot-console-view==${VERSION} sudo pip install mercurial sudo pip install buildbot-www sudo pip install buildbot-slave +sudo pip install pyyaml -sudo apt-get install zlib gengetopt automake gfortran +sudo apt-get install ^zlib gengetopt automake gfortran mkdir -p ~/texmf/tex/latex/commonstuff/ (cd ~/texmf/tex/latex/commonstuff/; wget http://mirrors.ctan.org/macros/latex/contrib/relsize/relsize.sty) diff --git a/setup/general.cfg b/setup/general.cfg --- a/setup/general.cfg +++ b/setup/general.cfg @@ -1,31 +1,31 @@ -# This is the general local setup for all tests ( in YAML format ) +#sswdPath This is the general local setup for all tests ( in YAML format ) Title: "CrashTest Bot" TitleURL: "http://crashtest.hepforge.org" # #BuildBotURL: "http://hepbox.dur.scotgrid.ac.uk:8433/" -BuildBotURL: "http://localhost:8433/" -WebsiteUser: "Homer" -WebsitePassword: "doh!!!" - +BuildBotURL: "http://jbellmbox.dur.scotgrid.ac.uk:8433/" +WebsiteUser: "herwig" +WebsitePassword: "find your own password" +BuildBotPort: "8433" # The 'workers' list defines the set of recognized workers. Each element is # a Worker object, specifying a unique worker name and password. The same # worker name and password must be configured on the worker. -Workers: [["localhost","jo_local"]] +Workers: [["localhost","jo_local"],["d71.phyip3.dur.ac.uk","jo_d71"],[mac1.phyip3.dur.ac.uk,jo_mac1]] #[["localhost","jo_local"],["d12","jo_d12"],["d17","jo_d17"],["mac1","jo_mac1"],["mac2","jo_mac2"]] LocalWorker: "jo_local" -SlaveDir: "/scratch" +SlaveDir: "/scratch/H7Bot" # Define the port the workers talk to #MasterIP: 193.60.193.70 -MasterIP: 127.0.0.1 -Port: 8070 -Password: "pass" -Results: "/home/osboxes/crash-test/RESULTS" +MasterIP: 193.60.193.69 +Port: "8070" +Password: "find another password" +Results: "/home/jbellm/herwigtester/RESULTS" # Define the mail adress for error messages -MailName: "buildbot@hepbox.dur.scotgrid.ac.uk" +MailName: "buildbot@jbellmbox.dur.scotgrid.ac.uk" diff --git a/tests/herwig.cfg b/tests/herwig.cfg deleted file mode 100644 --- a/tests/herwig.cfg +++ /dev/null @@ -1,76 +0,0 @@ -#Test: YAML format - -Name: "crashtest-herwig" - -ProjectName: "herwig_public" -Repo: "ssh://bellm@login.hepforge.org//hepforge/hg/herwig/public/herwig" -Branch: "herwig-7-0" -Dir: "herwig_7_0" - -UserName: jbellm -Mail: ["johannes.bellm@durham.ac.uk","holger.schulz@durham.ac.uk"] - - - -# Define the tests - -Builders: - HerwigTest1a: - Workers: ["jo_local"] - LogFile: "linux.log" - Results: True - YodaFiles: - - "LEP-91.yoda" - YodaFolder: "LEP" - CleanDir: False - Test: - - "wget https://herwig.hepforge.org/herwig-bootstrap" - - "chmod +x herwig-bootstrap" - - "./herwig-bootstrap --without-njet --without-gosam --without-hjets --without-vbfnlo --without-openloops /scratch/herwig_bootstrap" -# - "source /scratch/herwig_bootstrap/bin/activate" -# - "autoreconf -vi" -# - "./configure --prefix=/scratch/buildbotherwig/build --with-thepeg=/scratch/herwig_bootstrap --with-boost=/scratch/herwig_bootstrap --with-gsl=/scratch/herwig_bootstrap --with-fastjet=/scratch/herwig_bootstrap CC=gcc CXX=g++ FC=gfortran" -# - "make -j2" -# - "make install" - - "make Rivet-inputfiles -C Tests" - - "./src/Herwig read Tests/Rivet/LEP-91.in" - - "./src/Herwig run LEP-91.run -N100" - - "mkdir results" - - "rm LEP-91.run LEP-91.tex" - - "mv LEP-91.out LEP-91.log LEP-91.yoda results" - - HerwigTest1b: - Workers: ["jo_local"] - LogFile: "linux.log" - Results: True - YodaFiles: - - "LHC-8-Z-mu.yoda" - YodaFolder: "LHC" - CleanDir: False - Test: - - "wget https://herwig.hepforge.org/herwig-bootstrap" - - "chmod +x herwig-bootstrap" - - "./herwig-bootstrap --without-njet --without-gosam --without-hjets --without-vbfnlo --without-openloops /scratch/herwig_bootstrap" -# - "source /scratch/herwig_bootstrap/bin/activate" -# - "autoreconf -vi" -# - "./configure --prefix=/scratch/buildbotherwig/build --with-thepeg=/scratch/herwig_bootstrap --with-boost=/scratch/herwig_bootstrap --with-gsl=/scratch/herwig_bootstrap --with-fastjet=/scratch/herwig_bootstrap CC=gcc CXX=g++ FC=gfortran" -# - "make -j2" -# - "make install" - - "make Rivet-inputfiles -C Tests" - - "./src/Herwig read Tests/Rivet/LHC-8-Z-mu.in" - - "./src/Herwig run LHC-8-Z-mu.run -N100" - - "mkdir results" - - "rm LHC-8-Z-mu.run LHC-8-Z-mu.tex" - - "mv LHC-8-Z-mu.out LHC-8-Z-mu.log LHC-8-Z-mu.yoda results" - - - - - - - - -# Standard Variables ----------------------------------# -# Variables for validation time -TreeStableTimer: 300 -PollInterval: 600 diff --git a/tests/test1.cfg b/tests/test1.cfg --- a/tests/test1.cfg +++ b/tests/test1.cfg @@ -1,47 +1,47 @@ #Test: YAML format Name: "crashtest-hg-Test1" ProjectName: "hg-Test1" Repo: "/scratch/test-hg1" Branch: "default" Dir: "hg-Test1" UserName: jbellm -Mail: ["johannes.bellm@durham.ac.uk","holger.schulz@durham.ac.uk"] +Mail: ["johannes.bellm@durham.ac.uk"] # Define the tests Builders: LinuxTest1: Workers: ["jo_local"] LogFile: "linux.log" Results: True CleanDir: True Test: - "make" - "make testLEP -C Test" - "mkdir results" - "mv Test/res.dat results" LinuxTest1a: Workers: ["jo_local"] LogFile: "linux.log" Results: True CleanDir: False Test: - "make" - "make testLEP -C Test" - "mkdir results" - "mv Test/res.dat results" # Standard Variables ----------------------------------# # Variables for validation time TreeStableTimer: 300 PollInterval: 600 diff --git a/tests/test2.cfg b/tests/test2.cfg --- a/tests/test2.cfg +++ b/tests/test2.cfg @@ -1,34 +1,34 @@ #Test: YAML format Name: "crashtest-hg-Test2" ProjectName: "hg-Test2" Repo: "/scratch/test-hg2" Branch: "default" Dir: "hg-Test2" UserName: jbellm -Mail: ["johannes.bellm@durham.ac.uk","holger.schulz@durham.ac.uk"] +Mail: ["johannes.bellm@durham.ac.uk"] # Define the tests Builders: LinuxTest2: Workers: ["jo_local"] LogFile: "linux.log" Results: True CleanDir: True Test: - "make" - "./a.out" - "make testLEP -C Test" - "mkdir results" - "mv Test/res.dat results" # Standard Variables ----------------------------------# # Variables for validation time TreeStableTimer: 300 PollInterval: 600