1 from __future__
import print_function
12 from array
import array
13 from copy
import deepcopy
14 from os
import chdir,getcwd,listdir,makedirs,rmdir
15 from os.path
import exists,join
22 from definitions
import *
23 from utils
import setTDRStyle
36 if msg_level>=_log_level:
37 print(
"[%s] %s" %(asctime(),message))
49 def __init__(self,sample1="",sample2="",release1="",release2="",run1="",run2="",tier1=0,tier2=0):
61 def __init__(self,name,mother_dir="",meta=CompInfo(),draw_success=
False,do_pngs=
False):
76 Weighted.__init__(self,name)
80 self.rank_histo.SetDirectory(0)
95 '''Walk all subdirs and calculate weight,fails and successes. 96 Moreove propagate the sample and releases names. 116 self.
subdirs = [subdir
for subdir
in self.
subdirs if not subdir.is_empty()]
119 if comp.status == SKIPED:
124 self.rank_histo.Fill(comp.rank)
126 if comp.status == FAIL:
129 elif comp.status == SUCCESS:
139 subdir.calcStats(make_pie)
140 subdir.meta=self.
meta 141 self.
weight+=subdir.weight
149 self.rank_histo.Add(subdir.rank_histo)
159 subdirdict[subdir.name]=subdir
165 subdirnames.append(subdir.name)
169 """Emit the ajax to build a pie chart using google apis... 171 url =
"https://chart.googleapis.com/chart?" 174 url+=
"&chco=00FF00|FFFF00|FF0000|7A7A7A" 175 url+=
"&chs=%sx%s" %(w,h)
186 fail_comps=[comp
for comp
in self.
comparisons if comp.status==FAIL]
187 fail_comps=sorted(fail_comps,key=
lambda comp:comp.name )
188 if len(fail_comps)>0:
190 for comp
in fail_comps:
191 print(indent+
" - %s: %s Test Failed (pval = %s) " %(comp.name,comp.test_name,comp.rank))
193 subdir.print_report(indent+
" ",verbose)
204 if self.
weight == 0:
return 0
207 if self.
weight == 0:
return 0
211 if self.
weight == 0:
return 1
215 if self.
weight == 0:
return 0
228 if not exists(full_path)
and len(full_path)>0:
242 valsa=
array(
'f',vals)
243 colorsa=
array(
'i',colors)
244 can = TCanvas(
"cpie",
"TPie test",100,100);
246 pie = TPie(
"ThePie",self.
name,len(vals),valsa,colorsa);
259 pie.SetAngularOffset(0.);
260 pie.SetLabelsOffset(-.3);
266 print(
"len(vals) = %s (vals=%s)" %(len(vals),vals))
267 print(
"valsa = %s" %valsa)
268 print(
"colorsa = %s" %colorsa)
271 """Eliminate from the tree the directory the expandable ones. 279 subdir.mother_dir=subdir.mother_dir.replace(
"/"+expandable_dir,
"")
280 if subdir.name==expandable_dir:
286 exp_dir=self.
subdirs[exp_index]
287 for subsubdir
in exp_dir.subdirs:
289 subsubdir.mother_dir=subsubdir.mother_dir.replace(
"/"+expandable_dir,
"")
290 while "//" in subsubdir.mother_dir:
291 print(subsubdir.mother_dir)
292 subsubdir.mother_dir=subsubdir.mother_dir.replace(
"//",
"/")
294 self.subdirs.append(subsubdir)
296 for comp
in exp_dir.comparisons:
297 comp.mother_dir=comp.mother_dir.replace(
"/"+expandable_dir,
"")
298 while "//" in comp.mother_dir:
300 comp.mother_dir=comp.mother_dir.replace(
"/")
302 self.comparisons.append(comp)
309 self.
prune(expandable_dir)
312 subdir.prune(expandable_dir)
316 return "%s seems to be empty. Please check!" %self.
name 319 content+=
" %s\n" % subdir
321 content+=
" %s\n" % comp
325 from multiprocessing
import Process
327 canvas.Print(img_name)
329 tcanvas_print_processes=[]
335 def __init__(self,name,mother_dir,h1,h2,stat_test,draw_success=False,do_pngs=False, skip=False):
341 Weighted.__init__(self,name)
343 stat_test.set_operands(h1,h2)
351 self.
status=stat_test.get_status()
352 self.
rank=stat_test.get_rank()
369 self.
img_name=self.img_name.replace(
"Run summary",
"")
370 self.
img_name=self.img_name.replace(
"/",
"_")
371 self.
img_name=self.img_name.strip(
"_")
380 p = Process(target=print_multi_threaded, args=(canvas,self.
img_name))
382 tcanvas_print_processes.append(p)
383 n_proc=len(tcanvas_print_processes)
386 for iprocess
in xrange(0,n_proc):
387 p=tcanvas_print_processes[iprocess]
389 p_to_remove.append(iprocess)
392 for iprocess
in p_to_remove:
393 tcanvas_print_processes.pop(iprocess-adjustment)
401 canvas=TCanvas(self.
name,self.
name,Comparison.canvas_xsize,Comparison.canvas_ysize)
405 obj1.SetTitle(self.
name)
407 if obj1.GetNbinsY()!=0
and not "2" in obj1.ClassName() :
408 obj1 .SetLineWidth(2)
409 obj2 .SetLineWidth(2)
411 obj1.SetMarkerStyle(8)
412 obj1.SetMarkerSize(.8)
414 obj2.SetMarkerStyle(8)
415 obj2.SetMarkerSize(.8)
417 obj1.SetMarkerColor(kBlue)
418 obj1.SetLineColor(kBlue)
420 obj2.SetMarkerColor(kRed)
421 obj2.SetLineColor(kRed)
425 obj2.Draw(
"HistSames")
449 print(
"This comparison failed %f" %self.
rank)
456 lat_text=
"#scale[.7]{#color[%s]{%s: %2.2f}}" %(color,self.
test_name,self.
rank)
457 lat=TLatex(.1,.91,lat_text)
473 lat_text1=
"#scale[.7]{#color[%s]{Entries: %s}}" %(obj1.GetLineColor(),n1)
474 lat1=TLatex(.3,.91,lat_text1)
479 lat_text2=
"#scale[.7]{#color[%s]{Entries: %s}}" %(obj2.GetLineColor(),n2)
480 lat2=TLatex(.6,.91,lat_text2)
def __get_full_path(self)
def __init__(self, name, mother_dir, h1, h2, stat_test, draw_success=False, do_pngs=False, skip=False)
def calcStats(self, make_pie=True)
def prune(self, expandable_dir)
def replace(string, replacements)
def get_success_rate(self)
S & print(S &os, JobReport::InputFile const &f)
def __create_on_disk(self)
def __init__(self, sample1="", sample2="", release1="", release2="", run1="", run2="", tier1=0, tier2=0)
def print_report(self, indent="", verbose=False)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def get_summary_chart_name(self)
def __init__(self, name, mother_dir="", meta=CompInfo(), draw_success=False, do_pngs=False)
def get_subdirs_names(self)
def get_subdirs_dict(self)
def tcanvas_slow(self, canvas)
def get_summary_chart_ajax(self, w=400, h=300)
static std::string join(char **cmd)
def print_multi_threaded(canvas, img_name)
def logger(msg_level, message)
def __create_pie_image(self)
def __init__(self, name, weight=1)
def __make_image(self, obj1, obj2)
def get_skiped_rate(self)