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 66 of file addOnTests.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 68 of file addOnTests.py.

68  def __init__(self, nThrMax=4):
69 
70  self.threadList = []
71  self.maxThreads = nThrMax
72  self.prepare()
73 
74  return
75 
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 76 of file addOnTests.py.

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

Referenced by addOnTests.StandardTester.runTests().

76  def activeThreads(self):
77 
78  nActive = 0
79  for t in self.threadList:
80  if t.is_alive() : nActive += 1
81 
82  return nActive
83 

◆ dumpTest()

def addOnTests.StandardTester.dumpTest (   self)

Definition at line 124 of file addOnTests.py.

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

124  def dumpTest(self):
125  print(",".join(self.commands.keys()))
126  return
127 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

◆ file2Path()

def addOnTests.StandardTester.file2Path (   self,
  rFile 
)

Definition at line 128 of file addOnTests.py.

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

128  def file2Path(self,rFile):
129 
130  fullPath = self.relPath + rFile
131  if os.path.exists(self.devPath + rFile): fullPath = self.devPath + rFile
132  return fullPath
133 

◆ prepare()

def addOnTests.StandardTester.prepare (   self)

Definition at line 84 of file addOnTests.py.

84  def prepare(self):
85 
86  self.devPath = os.environ['LOCALRT'] + '/src/'
87  self.relPath = self.devPath
88  if 'CMSSW_RELEASE_BASE' in os.environ and (os.environ['CMSSW_RELEASE_BASE'] != ""): self.relPath = os.environ['CMSSW_RELEASE_BASE'] + '/src/'
89 
90  lines = { 'read312RV' : ['cmsRun '+self.file2Path('Utilities/ReleaseScripts/scripts/read312RV_cfg.py')],
91  '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"],
92  '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"],
93  '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"],
94  'pat1' : ['cmsRun '+self.file2Path('PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py')],
95  }
96 
97  hltTests = {}
98  hltFlag_data = ' realData=True globalTag=@ inputFiles=@ '
99  hltFlag_mc = ' realData=False globalTag=@ inputFiles=@ '
100  from Configuration.HLT.addOnTestsHLT import addOnTestsHLT
101  hltTestsToAdd = addOnTestsHLT()
102  for key in hltTestsToAdd:
103  if '_data_' in key:
104  hltTests[key] = [hltTestsToAdd[key][0],
105  'cmsRun '+self.file2Path(hltTestsToAdd[key][1])+hltFlag_data,
106  hltTestsToAdd[key][2]]
107  elif '_mc_' in key:
108  hltTests[key] = [hltTestsToAdd[key][0],
109  'cmsRun '+self.file2Path(hltTestsToAdd[key][1])+hltFlag_mc,
110  hltTestsToAdd[key][2]]
111  else:
112  hltTests[key] = [hltTestsToAdd[key][0],
113  'cmsRun '+self.file2Path(hltTestsToAdd[key][1]),
114  hltTestsToAdd[key][2]]
115 
116  self.commands={}
117  for dirName, command in lines.items():
118  self.commands[dirName] = command
119 
120  for dirName, commandList in hltTests.items():
121  self.commands[dirName] = commandList
122  return
123 

◆ runTests()

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

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

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

References print(), and str.

201  def upload(self, tgtDir):
202 
203  print("in ", os.getcwd())
204 
205  if not os.path.exists(tgtDir):
206  os.makedirs(tgtDir)
207 
208  cmd = 'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+' ; tar xf - ) '
209  try:
210  print('executing: ',cmd)
211  ret = os.system(cmd)
212  if ret != 0:
213  print("ERROR uploading logs:", ret, cmd)
214  except Exception as e:
215  print("EXCEPTION while uploading addOnTest-logs : ", str(e))
216 
217  return
218 
219 
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 86 of file addOnTests.py.

Referenced by addOnTests.StandardTester.file2Path().

◆ maxThreads

addOnTests.StandardTester.maxThreads

Definition at line 71 of file addOnTests.py.

Referenced by addOnTests.StandardTester.runTests().

◆ relPath

addOnTests.StandardTester.relPath

Definition at line 87 of file addOnTests.py.

Referenced by addOnTests.StandardTester.file2Path().

◆ threadList

addOnTests.StandardTester.threadList