3 from __future__
import print_function
4 from builtins
import range
10 from threading
import Thread
12 scriptPath = os.path.dirname( os.path.abspath(sys.argv[0]) )
13 if scriptPath
not in sys.path:
14 sys.path.append(scriptPath)
32 with open(self.
dirName+
'/cmdLog',
'w')
as clf:
33 clf.write(f
'# {self.dirName}\n')
36 clf.write(f
'\n{command}\n')
38 time_start = time.time()
39 exitcode = os.system(f
'cd {self.dirName} && {command} > step{cmdIdx+1}.log 2>&1')
40 time_elapsed_sec = round(time.time() - time_start)
42 timelog = f
'elapsed time: {time_elapsed_sec} sec (ended on {time.asctime()})' 43 logline = f
'[{self.dirName}:{cmdIdx+1}] {command} : ' 52 logline += f
' - {timelog} - exit: {exitcode}' 53 self.
report += logline+
'\n\n' 69 if t.is_alive() : nActive += 1
75 self.
devPath = os.environ[
'LOCALRT'] +
'/src/' 77 if 'CMSSW_RELEASE_BASE' in os.environ
and (os.environ[
'CMSSW_RELEASE_BASE'] !=
""): self.
relPath = os.environ[
'CMSSW_RELEASE_BASE'] +
'/src/' 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')],
87 hltFlag_data =
'realData=True globalTag=@ inputFiles=@' 88 hltFlag_mc =
'realData=False globalTag=@ inputFiles=@' 89 from Configuration.HLT.addOnTestsHLT
import addOnTestsHLT
91 for key
in hltTestsToAdd:
93 hltTests[key] = [hltTestsToAdd[key][0],
94 'cmsRun '+self.
file2Path(hltTestsToAdd[key][1])+
' '+hltFlag_data,
95 hltTestsToAdd[key][2]]
97 hltTests[key] = [hltTestsToAdd[key][0],
98 'cmsRun '+self.
file2Path(hltTestsToAdd[key][1])+
' '+hltFlag_mc,
99 hltTestsToAdd[key][2]]
101 hltTests[key] = [hltTestsToAdd[key][0],
102 'cmsRun '+self.
file2Path(hltTestsToAdd[key][1]),
103 hltTestsToAdd[key][2]]
106 for dirName, command
in lines.items():
109 for dirName, commandList
in hltTests.items():
110 self.
commands[dirName] = commandList
119 fullPath = self.
relPath + rFile
120 if os.path.exists(self.
devPath + rFile): fullPath = self.
devPath + rFile
127 if not os.path.exists(
'addOnTests'):
128 os.makedirs(
'addOnTests')
129 os.chdir(
'addOnTests')
146 print(
'Preparing to run %s' %
str(command))
147 current =
testit(dirName, command)
150 time.sleep(random.randint(1,5))
159 for f
in pingle.nfail: nfail += f
160 for p
in pingle.npass: npass += p
161 report += pingle.report
165 reportSumm =
'\n %s tests passed, %s failed \n' %(npass,nfail)
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()
174 print(
'==> in :', os.getcwd())
175 print(
' going to copy log files to logs dir ...')
176 if not os.path.exists(
'logs'):
179 cmd =
"for L in `ls "+dirName+
"/*.log`; do cp $L logs/cmsDriver-`dirname $L`_`basename $L` ; done" 180 print(
"going to ",cmd)
184 pickle.dump(self.
commands, open(
'logs/addOnTests.pkl',
'wb'), protocol=2)
192 print(
"in ", os.getcwd())
194 if not os.path.exists(tgtDir):
197 cmd =
'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+
' ; tar xf - ) ' 199 print(
'executing: ',cmd)
202 print(
"ERROR uploading logs:", ret, cmd)
203 except Exception
as e:
204 print(
"EXCEPTION while uploading addOnTest-logs : ",
str(e))
214 opts, args = getopt.getopt(argv,
"dj:t:", [
"nproc=",
'uploadDir=',
'tests=',
'noRun',
'dump'])
215 except getopt.GetoptError
as e:
224 for opt, arg
in opts :
225 if opt
in (
'-j',
"--nproc" ):
227 if opt
in (
"--uploadDir", ):
229 if opt
in (
'--noRun', ):
231 if opt
in (
'-d',
'--dump', ):
233 if opt
in (
'-t',
'--tests', ):
234 testList = arg.split(
",")
241 tester.runTests(testList)
243 tester.upload(uploadDir)
246 if __name__ ==
'__main__' :
def file2Path(self, rFile)
def __init__(self, dirName, commandList)
def __init__(self, nThrMax=4)
def runTests(self, testList=None)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)