6 check/update references
11 - check file exists before doing something (dcube)
12 - restrict to used branches
17 t_logs ( rel, cmt, branch, rundate, update date&time , comment, jobsalias_id )
19 t_branches (branch,ref,project) [ 17.X.0-VAL , 17.X.0 ]
20 t_alias (alias, branch) [ 'devval', '17.X.0-VAL']
21 t_tests (testname,pathpiece,project) ['SimCoreTests','Simulation/Tests','simulation']
22 t_jobs (testname, job, file, type) ['SimCoreTests','AtlasG4_muons'
23 t_joblsit (alias, job) -- except 'all' ['dcube','AtlasG4_%']
24 t_user (admins) ['jchapman','aschaeli','z']
27 from exceptions
import Exception
40 print 'please use Python 2.5 or above:'
41 print '> source ~aschaeli/public/setup_python26.sh'
43 raise SimRttUpdateError()
54 self.
cnx = sqlite3.connect(self.
fname)
63 vals=
','.
join((
'%s text ',)*len(args))
64 cmd=(
'create table %s ('+vals+
')')% ( (tname,)+args )
69 vals=
','.
join((
'?',)*len(args))
70 cmd=
"insert into %s values (%s)"%(tname,vals)
77 cmd=
'select count(*) from %s where %s=?'%(tname,column)
79 res=sel.cur.fetchone()
85 cmd=
'select * from %s limit 1'%tname
87 header= [ s[0]
for s
in self.
cur.description ]
88 res=self.
cur.fetchall()
90 values=[ k+
'=?' for k
in header
if k
not in keys ]
91 key_values=tuple([ a
for k,a
in zip(header,args)
if k
in keys])
92 set_values=tuple([ a
for k,a
in zip(header,args)
if k
not in keys])
94 cmd=
"update %s set %s where %s=?"%(tname,vals,keys[0])
97 self.
_execute(cmd, set_values+key_values)
101 cmd=
'drop table %s'%tname
105 print 'SQL Error:',cmd
108 for t
in [
't_logs',
't_branches',
't_alias',
't_tests',
't_jobs',
't_joblist',
't_user']:
110 self.
_createTable(
't_logs',
'branch',
'rel',
'cmt',
'res_date',
'up_date')
113 self.
_execute(
'create table t_branches (branch text, ref text, project text, primary key (branch,project) ) ;')
116 self.
_createTable(
't_tests',
'testname',
'pathpiece',
'project')
117 self.
_createTable(
't_jobs',
'testname',
'job',
'file',
'type')
125 for br
in [
'17.X.0-VAL',
'17.X.0']:
126 self.
_fillTable(
't_branches', br,
'17.X.0',sim)
127 for br
in [
'17.1.X-VAL',
'17.1.X',
'17.1.X.Y-VAL',
'17.1.X.Y',
'17.2.X-VAL',
'17.2.X']:
128 self.
_fillTable(
't_branches', br,
'17.1.X',sim)
129 for br
in [
'16.6.X.Y-VAL',
'16.6.X.Y',
'16.6.X-VAL',
'16.6.X']:
130 self.
_fillTable(
't_branches', br,
'16.6.X',sim)
133 self.
djobs={
'AtlasG4_electrons' : [
'truth.root'],
134 'AtlasG4_muons' : [
'truth.root'],
135 'WriteCalHitsTest' : [
'truth.root'],
136 'AtlasG4_pions' : [
'truth.root'] }
138 self.
jobs={
'AtlasGeom19Sim' : [
'test.HITS.pool.root'],
139 'CavernBg_EVNT2TR' : [
'cavbg.EVNT.pool.root'],
140 'CavernBg_TR2HITS' : [
'cavbg.HITS.pool.root'],
141 'CosmicSim' : [
'testCosmics.HITS.pool.root',
'testCosmics.TR.pool.root'],
142 'CosmicSimTR' : [
'testCosmics.HITS.pool.root'],
143 'HeavyIonSim': [
'test.HITS.pool.root'],
144 'TTbarSim' : [
'test.HITS.pool.root'],
145 'FtfpBertTest': [
'test.HITS.pool.root'],
146 'LucidSimTest': [
'testLucid.HITS.pool.root'],
147 'NeutronCutTest': [
'test.HITS.pool.root'],
148 'QgsBicTest': [
'test.HITS.pool.root'],
149 'QgspBertChipsTest': [
'test.HITS.pool.root'],
150 'SimCheckDBRel': [
'test.HITS.pool.root'],
151 'ALFASimTest' : [
'testALFA.HITS.pool.root'],
152 'ZDCSimTest' : [
'testZDC.HITS.pool.root']}
154 self.
jobs0={
'FrozenShowerFCalOnly': [
'test.HITS.pool.root']}
155 self.
jobs1={
'FrozenShowerTest1': [
'test.HITS.pool.root'],
156 'FrozenShowerTest2': [
'test.HITS.pool.root']}
160 self.
_fillTable(
't_tests',tn,
'Simulation/Tests',
'simulation')
162 self.
_fillTable(
't_tests',tn1,
'Simulation/G4Atlas',
'simulation')
170 self.
_fillTable(
't_joblist',
'diffpool_jobs',j)
176 self.
_fillTable(
't_joblist',
'diffpool_jobs',j)
181 self.
_fillTable(
't_joblist',
'diffpool_jobs',j)
185 tn2=
'SimExoticsTests'
186 self.
_fillTable(
't_tests',tn2,
'Simulation/Tests',
'simulation')
188 tn3=
'SimPerformanceTests'
189 self.
_fillTable(
't_tests',tn3,
'Simulation/Tests',
'simulation')
192 self.
users=[
'aschaeli',
'jchapman',
'fmgaray']
202 header= [ s[0]
for s
in self.
cur.description ]
203 format=
' '.
join([
'%25s' for s
in self.
cur.description])
204 print format%tuple(header)
205 for res
in self.
cur.fetchall():
209 cmd=
'select login from t_user where rights=?'
211 return [res[0]
for res
in self.
cur.fetchall()]
214 cmd=
'select pathpiece,project from t_tests where testname=?'
216 return self.
cur.fetchone()
219 cmd=
'select ref from t_branches where branch=? and project=?'
220 if branch==
'devval' :
225 res=self.
cur.fetchone()
227 print 'ERROR',branch,project,
'not found in t_branches'
234 cmd=
'select job,file from t_jobs where testname=? and type=?'
235 self.
_execute(cmd,(testname,jobtype))
236 res=self.
cur.fetchall()
241 if jobs.has_key(key):
250 for t
in [
't_user',
't_branches',
't_tests',
't_jobs',
't_alias',
't_joblist']:
254 def addUser(self,username='aschaeli',right='a'):
262 def addTest(self,testname='SimCoreTests',path='Simulation/Tests'):
266 def addJob(self,testname='SimCoreTests',jobname='AtlasG4_muons',
267 files=['truth.root'],typeid='dcube'):
269 self.
_fillTable(
't_jobs',testname,jobname,fn,typeid)
273 joblist=['AtlasG4_muons','AtlasG4_electrons','AtlasG4_pions']):
286 import datetime
as dt
287 from argparse
import ArgumentParser
293 usage=
"updates reference files for the Core Simulation Runtime Tests"
297 %prog -n --branch=devval --rel=rel_3 --package=G4AtlasTests
301 update --branch --rel --cmt --jobs --today --rttpath (--suffix)
305 dumpTests [--project]
306 dumpBranches [--project]
307 addUser --user --right
308 addBranch --branch --ref --project
309 addTest --package --testpath --project
310 addJobs --package --jobs --jobfiles --testtype
311 defAlias --jobalias --jobs
314 ArgumentParser.__init__(self,description=usage,epilog=epilog)
316 self.add_argument(
'-n',
'--dryrun', action=
'store_const',
317 const=
True, dest=
'dryrun', default=
False,
318 help=
'dry run - do nothing')
319 group = self.add_mutually_exclusive_group(required=
not admin)
320 group.add_argument(
'--branch', action=
'store', dest=
'branch', default=
'devval',
321 help=
'release to use')
323 group.add_argument(
'--logs',
'-l', action=
'store_true', dest=
'logs',
324 help=
'print logs but do nothing')
327 self.add_argument(
'--package', action=
'store', dest=
'package', default=
'G4AtlasTests',
328 help=
'package containing the tests (default G4AtlasTests)')
330 self.add_argument(
'--rel', action=
'store', dest=
'rel', default=
'rel_X',
331 help=
'rel identifier (default todays rel_X)')
333 self.add_argument(
'--cmt', action=
'store', dest=
'cmt', default=
'x86_64-slc5-gcc43-opt',
334 help=
'cmt identifier (default:x86_64-slc5-gcc43-opt)')
336 self.add_argument(
'--jobs', action=
'store', dest=
'jobs', default=
'',
337 help=
'job names, e.g. CosmicSim,WriteCalHitsTest')
339 self.add_argument(
'--today', action=
'store', dest=
'today', default=
'AUTO',
340 help=
'store results in specified subdir ')
342 self.add_argument(
'--rttpath', action=
'store', dest=
'rttpath', default=
'default',
343 help=
'use path for looking for root files')
345 self.add_argument(
'--suffix', action=
'store', dest=
'sbranch', default=
'',
346 help=
'file suffix to distingish ref files for different releases')
351 group1=self.add_argument_group(
'admin arguments',
'commands for changing the configuration')
353 group1.add_argument(
'--dumpDB', action=
'store_true', dest=
'dumpDB',
354 help=
'print all database entries')
356 group1.add_argument(
'--dumpUsers',action=
'store_true', dest=
'dumpUsers',
357 help=
'print all users authorised to use admin commands')
359 group1.add_argument(
'--dumpTests',action=
'store_true', dest=
'dumpTests',
360 help=
'print all Tests')
362 group1.add_argument(
'--dumpBranches',action=
'store_true', dest=
'dumpBranches',
363 help=
'print all Branches')
365 group1.add_argument(
'--addBranch', action=
'store_true', dest=
'addBranch',
366 help=
'add new branch to configuration file')
368 group1.add_argument(
'--refpath', action=
'store', dest=
'ref', default=
'17.X.0',
369 help=
'assign refpath to given branch')
371 group1.add_argument(
'--project', action=
'store', dest=
'project', default=
'simulation',
372 help=
'assign project e.g. digitization (default: simulation)')
374 group1.add_argument(
'--addTest', action=
'store_true', dest=
'addTest',
375 help=
'add new test to configuraiton file')
377 group1.add_argument(
'--testpath', action=
'store', dest=
'testpath',
378 default=
'Simulation/Tests',
379 help=
'assign path to given test')
381 group1.add_argument(
'--addJobs', action=
'store_true', dest=
'addJobs',
382 help=
'add new job(s) to a given test')
384 group1.add_argument(
'--jobfiles', action=
'store', dest=
'jobfiles',
385 default=
'test.HITS.pool.root',
386 help=
'comma separated list of files to be updated')
388 group1.add_argument(
'--testtype', action=
'store', dest=
'testtype',
390 help=
'currently only dcube or diffpool supported')
392 group1.add_argument(
'--jobalias', action=
'store', dest=
'jobalias', default=
'',
393 help=
'assign alias to joblist (e.g. cavernbg_tests)')
398 return pwd.getpwuid( os.getuid() )[ 0 ]
407 opt.rel=
'rel_%d'% (dt.date.today().isoweekday() % 7)
410 if opt.rttpath ==
'default':
411 opt.rttpath=
'/afs/cern.ch/atlas/project/RTT/prod/Results/rtt/'+opt.rel+
'/'+opt.branch+
'/build/'+opt.cmt+
'/offline/'+opt.package
412 print 'using default rttpath =',opt.rttpath
415 opt.rttcastor=
'/eos/atlas/atlascerngroupdisk/proj-sit/rtt/prod/rtt/'+opt.rel+
'/'+opt.branch+
'/'+opt.cmt+
'/offline/'+opt.package
416 opt.eoscmd=
'/afs/cern.ch/project/eos/installation/0.1.0-22d/bin/eos.select'
417 opt.eosprefix=
'root://eosatlas.cern.ch/'
420 xrdcp root://eosatlas.cern.ch//eos/atlas/atlascerngroupdisk/proj-sit/rtt/prod/rtt/rel_2/17.1.X.Y/i686-slc5-gcc43-opt/offline/DigitizationTests/mc11_ttbar_LVL1_on/mc11_ttbar.RDO.pool.root root://eosatlas.cern.ch//eos/atlas/atlascerngroupdisk/proj-sit/digitization/RTT/ReferenceFiles/MC12/MC11_ttbar_LVL1_ON.RDO.pool.root
423 opt.testpath,opt.project=db.findPackage(opt.package)
424 opt.ref=db.findReference(opt.branch,opt.project)
427 opt.refpath=
'/eos/atlas/atlascerngroupdisk/proj-sit/'+opt.project+
'/validation/RTT/referenceFiles/'
428 opt.dcubepath=
'/afs/cern.ch/atlas/project/RTT/DCubeReference/offline/'+opt.testpath+
'/'+opt.package+
'/'
430 opt.refpath+=opt.ref+
'/'
431 opt.dcubepath+=opt.ref+
'/'
434 self.
djobs=db.findJobs(opt.package,jobtype=
'dcube')
437 self.
jobs=db.findJobs(opt.package,jobtype=
'diffpool')
441 print "selected jobs"
443 joblist=opt.jobs.split(
',')
446 self.
jobs = dict ( [ (k,self.
jobs[k])
for k
in joblist
if self.
jobs.has_key(k) ])
448 self.
djobs = dict ( [ (k,self.
djobs[k])
for k
in joblist
if self.
djobs.has_key(k) ])
457 if self.
opt.today==
'AUTO':
458 self.
opt.today=dt.date.today().strftime(
"%y%m%d")
462 self.
logfile=
'/afs/cern.ch/atlas/groups/Simulation/rtt/rttUpdate.log'
467 os.system(
'ls '+self.
opt.rttpath)
471 print '*** options: ***'
473 if i==
'ensure_value' or i==
'read_file' or i==
'read_module':
475 if i.startswith(
'_'):
477 print '%12s:'%i,getattr(self.
opt,i)
481 for i
in [
'today',
'dryrun',
'user',
'branch',
'rel',
'cmt',
'package',
'jobs',
'comment']:
483 if hasattr(self.
opt,i):
484 val =
str(getattr(self.
opt,i))
500 print "updating dcube xml file"
504 dxml=path+
"dcube-"+tname+
".xml"
511 if l.count(
"Results from")>0:
514 newl=
"Results from "
515 newl+= dt.date.today().strftime(
"%d %B %Y")
516 newl+=
", "+self.
opt.rel+
" "
517 newl+= self.
opt.branch+
" "
519 self.
opt.comment=newl
527 cmd=
"mv "+dxmln+
" "+dxml
529 if not self.
opt.dryrun:
536 if len(self.
djobs)>0:
537 cmd=
'mkdir '+self.
opt.dcubepath+self.
opt.today
539 if not self.
opt.dryrun:
544 epath=self.
opt.rttpath+
'/'+j
545 print '########################################'
547 print 'WARNING, no files given, looking for root files '
548 os.system(
'ls -l '+epath+
'/*.root')
552 if not os.path.exists(src):
553 print src,
'does not exist'
557 dst=self.
opt.dcubepath+sj+
'.'+f
558 s=os.system(
'ls '+dst)
560 print 'destination exists'
563 if not self.
opt.dryrun:
566 cmd=
'cp -v '+src+
' '+self.
opt.dcubepath+self.
opt.today+
'/'+sj+
'.'+f
568 if not self.
opt.dryrun:
570 cmd=
'ln -s '+self.
opt.today+
'/'+sj+
'.'+f+
' '+dst
572 if not self.
opt.dryrun:
583 cmd=self.
opt.eoscmd+
' mkdir '+self.
opt.refpath+self.
opt.today
585 if not self.
opt.dryrun:
589 epath=self.
opt.rttpath+
'/'+j
590 print '########################################'
595 print 'WARNING, no files given, looking for root files '
596 os.system(
'ls -l '+epath+
'/*.root')
600 s=os.system(
'ls -l '+epath+
'/'+f)
603 epath=self.
opt.rttcastor+
'/'+j
606 s=os.system(self.
opt.eoscmd+
' ls '+epath+
'/'+f)
609 epath= self.
opt.eosprefix+epath
616 if len(parts)>1
and parts[1]
in [
'EVNT2TR',
'TR2HITS']:
618 if self.
alias.has_key(sj):
624 pref,suff=f.split(
'.',1)
625 dst=self.
opt.refpath+sj+self.
opt.sbranch+
'.'+suff
627 s=os.system(self.
opt.eoscmd+
' ls '+dst)
630 print 'destination exists'
633 cmd=self.
opt.eoscmd+
" rm "+dst
635 if not self.
opt.dryrun:
637 cmd=
'xrdcp '+src+
' '+self.
opt.eosprefix+dst
639 if not self.
opt.dryrun:
641 dst=self.
opt.refpath+self.
opt.today+
'/'+sj+self.
opt.sbranch+
'.'+suff
642 cmd=
'xrdcp '+src+
' '+self.
opt.eosprefix+dst
644 if not self.
opt.dryrun:
647 print 'source not found!'
650 if __name__==
'__main__':
669 print 'user',user,
'authorised for admin commands'
673 args = optP.parse_args()
679 if args.branch==
'devval' :
681 if args.sbranch==
'dev':
683 print 'branch=',branch
684 print 'refpath=',args.ref
685 print 'proj=',args.project
687 db._fillTable(
't_branches',branch,args.ref,args.project)
689 except sqlite3.IntegrityError:
690 print "key exists, try updating"
691 db._updateTable(
't_branches',[
'branch',
'project'],branch,args.ref,args.project)
698 db._dumpTable(
't_user')
701 db._dumpTable(
't_tests')
703 if args.dumpBranches:
704 db._dumpTable(
't_branches')
710 rttUpdate.printOptions()
712 rttUpdate.printLogFile()
714 rttUpdate.updateDcube()
715 rttUpdate.updateRefs()
716 rttUpdate.writeLogFile()