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
 
 nThreads
 
 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,
  nThreads = 1 
)

Definition at line 12 of file MatrixRunner.py.

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

Member Function Documentation

def MatrixRunner.MatrixRunner.activeThreads (   self)

Definition at line 23 of file MatrixRunner.py.

References MatrixRunner.MatrixRunner.threadList.

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

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

Definition at line 32 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.

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

Definition at line 18 of file MatrixRunner.py.

MatrixRunner.MatrixRunner.runDirs

Definition at line 21 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().