CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
addOnTests.StandardTester Class Reference
Inheritance diagram for addOnTests.StandardTester:

Public Member Functions

def __init__ (self, nThrMax=4)
 
def activeThreads (self)
 
def dumpTest (self)
 
def file2Path (self, rFile)
 
def prepare (self)
 
def runTests (self, testList=None)
 
def upload (self, tgtDir)
 

Public Attributes

 commands
 
 devPath
 
 maxThreads
 
 relPath
 
 threadList
 

Detailed Description

Definition at line 55 of file addOnTests.py.

Constructor & Destructor Documentation

◆ __init__()

def addOnTests.StandardTester.__init__ (   self,
  nThrMax = 4 
)

Definition at line 57 of file addOnTests.py.

57  def __init__(self, nThrMax=4):
58 
59  self.threadList = []
60  self.maxThreads = nThrMax
61  self.prepare()
62 
63  return
64 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ activeThreads()

def addOnTests.StandardTester.activeThreads (   self)

Definition at line 65 of file addOnTests.py.

References MatrixRunner.MatrixRunner.threadList, and addOnTests.StandardTester.threadList.

Referenced by addOnTests.StandardTester.runTests().

65  def activeThreads(self):
66 
67  nActive = 0
68  for t in self.threadList:
69  if t.is_alive() : nActive += 1
70 
71  return nActive
72 

◆ dumpTest()

def addOnTests.StandardTester.dumpTest (   self)

Definition at line 113 of file addOnTests.py.

References addOnTests.StandardTester.commands, join(), relativeConstraints.keys, and print().

113  def dumpTest(self):
114  print(",".join(self.commands.keys()))
115  return
116 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:21

◆ file2Path()

def addOnTests.StandardTester.file2Path (   self,
  rFile 
)

Definition at line 117 of file addOnTests.py.

References addOnTests.StandardTester.devPath, and addOnTests.StandardTester.relPath.

117  def file2Path(self,rFile):
118 
119  fullPath = self.relPath + rFile
120  if os.path.exists(self.devPath + rFile): fullPath = self.devPath + rFile
121  return fullPath
122 

◆ prepare()

def addOnTests.StandardTester.prepare (   self)

Definition at line 73 of file addOnTests.py.

73  def prepare(self):
74 
75  self.devPath = os.environ['LOCALRT'] + '/src/'
76  self.relPath = self.devPath
77  if 'CMSSW_RELEASE_BASE' in os.environ and (os.environ['CMSSW_RELEASE_BASE'] != ""): self.relPath = os.environ['CMSSW_RELEASE_BASE'] + '/src/'
78 
79  lines = { 'read312RV' : ['cmsRun '+self.file2Path('Utilities/ReleaseScripts/scripts/read312RV_cfg.py')],
80  'fastsim' : ["cmsDriver.py TTbar_8TeV_TuneCUETP8M1_cfi --conditions auto:run1_mc --fast -n 100 --eventcontent AODSIM,DQM --relval 100000,1000 -s GEN,SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot Realistic8TeVCollision"],
81  'fastsim1' : ["cmsDriver.py TTbar_13TeV_TuneCUETP8M1_cfi --conditions auto:run2_mc_l1stage1 --fast -n 100 --eventcontent AODSIM,DQM --relval 100000,1000 -s GEN,SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot NominalCollision2015 --era Run2_25ns"],
82  'fastsim2' : ["cmsDriver.py TTbar_13TeV_TuneCUETP8M1_cfi --conditions auto:run2_mc --fast -n 100 --eventcontent AODSIM,DQM --relval 100000,1000 -s GEN,SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot NominalCollision2015 --era Run2_2016"],
83  'pat1' : ['cmsRun '+self.file2Path('PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py')],
84  }
85 
86  hltTests = {}
87  hltFlag_data = 'realData=True globalTag=@ inputFiles=@'
88  hltFlag_mc = 'realData=False globalTag=@ inputFiles=@'
89  from Configuration.HLT.addOnTestsHLT import addOnTestsHLT
90  hltTestsToAdd = addOnTestsHLT()
91  for key in hltTestsToAdd:
92  if '_data_' in key:
93  hltTests[key] = [hltTestsToAdd[key][0],
94  'cmsRun '+self.file2Path(hltTestsToAdd[key][1])+' '+hltFlag_data,
95  hltTestsToAdd[key][2]]
96  elif '_mc_' in key:
97  hltTests[key] = [hltTestsToAdd[key][0],
98  'cmsRun '+self.file2Path(hltTestsToAdd[key][1])+' '+hltFlag_mc,
99  hltTestsToAdd[key][2]]
100  else:
101  hltTests[key] = [hltTestsToAdd[key][0],
102  'cmsRun '+self.file2Path(hltTestsToAdd[key][1]),
103  hltTestsToAdd[key][2]]
104 
105  self.commands = {}
106  for dirName, command in lines.items():
107  self.commands[dirName] = command
108 
109  for dirName, commandList in hltTests.items():
110  self.commands[dirName] = commandList
111  return
112 

◆ runTests()

def addOnTests.StandardTester.runTests (   self,
  testList = None 
)

Definition at line 123 of file addOnTests.py.

References MatrixRunner.MatrixRunner.activeThreads(), addOnTests.StandardTester.activeThreads(), mps_setup.append, addOnTests.StandardTester.commands, mps_monitormerge.items, MatrixRunner.MatrixRunner.maxThreads, addOnTests.StandardTester.maxThreads, print(), str, MatrixRunner.MatrixRunner.threadList, and addOnTests.StandardTester.threadList.

123  def runTests(self, testList = None):
124 
125  actDir = os.getcwd()
126 
127  if not os.path.exists('addOnTests'):
128  os.makedirs('addOnTests')
129  os.chdir('addOnTests')
130 
131  nfail=0
132  npass=0
133  report=''
134 
135  print('Running in %s thread(s)' % self.maxThreads)
136 
137  if testList:
138  self.commands = {d:c for d,c in self.commands.items() if d in testList}
139  for dirName, command in self.commands.items():
140 
141  # make sure we don't run more than the allowed number of threads:
142  while self.activeThreads() >= self.maxThreads:
143  time.sleep(10)
144  continue
145 
146  print('Preparing to run %s' % str(command))
147  current = testit(dirName, command)
148  self.threadList.append(current)
149  current.start()
150  time.sleep(random.randint(1,5)) # try to avoid race cond by sleeping random amount of time [1,5] sec
151 
152  # wait until all threads are finished
153  while self.activeThreads() > 0:
154  time.sleep(5)
155 
156  # all threads are done now, check status ...
157  for pingle in self.threadList:
158  pingle.join()
159  for f in pingle.nfail: nfail += f
160  for p in pingle.npass: npass += p
161  report += pingle.report
162  print(pingle.report)
163  sys.stdout.flush()
164 
165  reportSumm = '\n %s tests passed, %s failed \n' %(npass,nfail)
166  print(reportSumm)
167 
168  runall_report_name='runall-report.log'
169  runall_report=open(runall_report_name,'w')
170  runall_report.write(report+reportSumm)
171  runall_report.close()
172 
173  # get the logs to the logs dir:
174  print('==> in :', os.getcwd())
175  print(' going to copy log files to logs dir ...')
176  if not os.path.exists('logs'):
177  os.makedirs('logs')
178  for dirName in self.commands:
179  cmd = "for L in `ls "+dirName+"/*.log`; do cp $L logs/cmsDriver-`dirname $L`_`basename $L` ; done"
180  print("going to ",cmd)
181  os.system(cmd)
182 
183  import pickle
184  pickle.dump(self.commands, open('logs/addOnTests.pkl', 'wb'), protocol=2)
185 
186  os.chdir(actDir)
187 
188  return
189 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)

◆ upload()

def addOnTests.StandardTester.upload (   self,
  tgtDir 
)

Definition at line 190 of file addOnTests.py.

References print(), and str.

190  def upload(self, tgtDir):
191 
192  print("in ", os.getcwd())
193 
194  if not os.path.exists(tgtDir):
195  os.makedirs(tgtDir)
196 
197  cmd = 'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+' ; tar xf - ) '
198  try:
199  print('executing: ',cmd)
200  ret = os.system(cmd)
201  if ret != 0:
202  print("ERROR uploading logs:", ret, cmd)
203  except Exception as e:
204  print("EXCEPTION while uploading addOnTest-logs : ", str(e))
205 
206  return
207 
208 
def upload(url, args, files)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)

Member Data Documentation

◆ commands

addOnTests.StandardTester.commands

◆ devPath

addOnTests.StandardTester.devPath

Definition at line 75 of file addOnTests.py.

Referenced by addOnTests.StandardTester.file2Path().

◆ maxThreads

addOnTests.StandardTester.maxThreads

Definition at line 60 of file addOnTests.py.

Referenced by addOnTests.StandardTester.runTests().

◆ relPath

addOnTests.StandardTester.relPath

Definition at line 76 of file addOnTests.py.

Referenced by addOnTests.StandardTester.file2Path().

◆ threadList

addOnTests.StandardTester.threadList