CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
MatrixRunner.MatrixRunner Class Reference
Inheritance diagram for MatrixRunner.MatrixRunner:

Public Member Functions

def __init__
 
def activeThreads
 
def runTests
 

Public Attributes

 maxThreads
 
 runDirs
 
 threadList
 
 workFlows
 

Detailed Description

Definition at line 10 of file MatrixRunner.py.

Constructor & Destructor Documentation

def MatrixRunner.MatrixRunner.__init__ (   self,
  wfIn = None,
  nThrMax = 4 
)

Definition at line 12 of file MatrixRunner.py.

12 
13  def __init__(self, wfIn=None, nThrMax=4):
14 
15  self.workFlows = wfIn
16 
17  self.threadList = []
18  self.maxThreads = nThrMax
19 
20  #the directories in which it happened
21  self.runDirs={}

Member Function Documentation

def MatrixRunner.MatrixRunner.activeThreads (   self)

Definition at line 22 of file MatrixRunner.py.

References MatrixRunner.MatrixRunner.threadList.

Referenced by MatrixRunner.MatrixRunner.runTests(), and addOnTests.StandardTester.runTests().

22 
23  def activeThreads(self):
24 
25  nActive = 0
26  for t in self.threadList:
27  if t.isAlive() : nActive += 1
28 
29  return nActive
30 
def MatrixRunner.MatrixRunner.runTests (   self,
  opt 
)

Definition at line 31 of file MatrixRunner.py.

References MatrixRunner.MatrixRunner.activeThreads(), prof2calltree.count, join(), python.multivaluedict.map(), MatrixRunner.MatrixRunner.maxThreads, MatrixRunner.MatrixRunner.runDirs, MatrixRunner.MatrixRunner.threadList, MatrixRunner.MatrixRunner.workFlows, and MatrixReader.MatrixReader.workFlows.

31 
32  def runTests(self, opt):
33 
34  testList=opt.testList
35  dryRun=opt.dryRun
36  cafVeto=opt.cafVeto
37 
38  startDir = os.getcwd()
39 
40  report=''
41  noRun=(self.maxThreads==0)
42  if noRun:
43  print 'Not running the wf, only creating cfgs and logs'
44  print 'resetting to default number of threads'
45  self.maxThreads=4
46 
47  print 'Running in %s thread(s)' % self.maxThreads
48 
49 
50  for wf in self.workFlows:
51 
52  if testList and float(wf.numId) not in [float(x) for x in testList]: continue
53 
54  item = wf.nameId
55  if os.path.islink(item) : continue # ignore symlinks
56 
57  # make sure we don't run more than the allowed number of threads:
58  while self.activeThreads() >= self.maxThreads:
59  time.sleep(10)
60  continue
61 
62  print '\nPreparing to run %s %s' % (wf.numId, item)
63 
64  current = WorkFlowRunner(wf,noRun,dryRun,cafVeto)
65  self.threadList.append(current)
66  current.start()
67  if not dryRun:
68  time.sleep(random.randint(1,5)) # try to avoid race cond by sleeping random amount of time [1,5] sec
69 
70  # wait until all threads are finished
71  while self.activeThreads() > 0:
72  time.sleep(0.5)
73 
74 
75  #wrap up !
76  totpassed=[]
77  totfailed=[]
78  def count(collect,result):
79  #pad with zeros
80  for i in range(len(collect),len(result)):
81  collect.append(0)
82  for i,c in enumerate(result):
83  collect[i]+=c
84 
85  for pingle in self.threadList:
86  pingle.join()
87  try:
88  count(totpassed,pingle.npass)
89  count(totfailed,pingle.nfail)
90  report+=pingle.report
91  self.runDirs[pingle.wf.numId]=pingle.wfDir
92  except Exception, e:
93  msg = "ERROR retrieving info from thread: " + str(e)
94  report += msg
95 
96  report+=' '.join(map(str,totpassed))+' tests passed, '+' '.join(map(str,totfailed))+' failed\n'
97  print report
98 
99  runall_report_name='runall-report-step123-.log'
100  runall_report=open(runall_report_name,'w')
101  runall_report.write(report)
102  runall_report.close()
103  os.chdir(startDir)
104 
105  anyFail=sum(totfailed)
106 
107  return anyFail
108 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Member Data Documentation

MatrixRunner.MatrixRunner.maxThreads

Definition at line 17 of file MatrixRunner.py.

Referenced by MatrixRunner.MatrixRunner.runTests(), and addOnTests.StandardTester.runTests().

MatrixRunner.MatrixRunner.runDirs

Definition at line 20 of file MatrixRunner.py.

Referenced by MatrixRunner.MatrixRunner.runTests().

MatrixRunner.MatrixRunner.threadList

Definition at line 16 of file MatrixRunner.py.

Referenced by MatrixRunner.MatrixRunner.activeThreads(), addOnTests.StandardTester.activeThreads(), MatrixRunner.MatrixRunner.runTests(), and addOnTests.StandardTester.runTests().

MatrixRunner.MatrixRunner.workFlows

Definition at line 14 of file MatrixRunner.py.

Referenced by MatrixRunner.MatrixRunner.runTests().