CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
revisionDML Namespace Reference

Functions

def addEntry
 
def addRevision
 
def addRunToCurrentDataTag
 
def alldataTags
 
def bookNewEntry
 
def bookNewRevision
 
def branchInfoByName
 
def branchType
 
def createBranch
 
def createDataTag
 Data Tagging API. More...
 
def currentDataTag
 
def dataIdsByCurrentTag
 
def dataIdsByTagId
 
def dataIdsByTagName
 
def dataRevisionsOfEntry
 
def dataTagInfo
 
def entryInBranch
 
def getDataTagId
 
def latestDataRevisionOfEntry
 
def revisionsInBranch
 
def revisionsInBranchName
 
def revisionsInTag
 

Variables

tuple databranchinfo = (branchid,'DATA')
 
tuple datainfo = createBranch(schema,'DATA','TRUNK',comment='hold data')
 
tuple entryinfo = (revision_id,entry_id,str(runnum),data_id)
 
tuple hltentryid = entryInBranch(schema,nameDealer.hltdataTableName(),str(runnum),'DATA')
 
tuple latestrevision = latestDataRevisionOfEntry(schema,nameDealer.lumidataTableName(),lumientry_id,revlist)
 
tuple lumientry_id = entryInBranch(schema,nameDealer.lumidataTableName(),'1211','DATA')
 
tuple lumientryid = entryInBranch(schema,nameDealer.lumidataTableName(),str(runnum),'DATA')
 
string myconstr = 'sqlite_file:test.db'
 
tuple norminfo = createBranch(schema,'NORM','TRUNK',comment='hold normalization factor')
 
tuple revisioninfo = bookNewRevision( schema,nameDealer.lumidataTableName() )
 
tuple revlist = revisionsInBranchName(schema,'DATA')
 
tuple schema = session.nominalSchema()
 
tuple session = svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
 
tuple svc = sessionManager.sessionManager(myconstr,debugON=False)
 
tuple tables = lumidbDDL.createTables(schema)
 
tuple trgentryid = entryInBranch(schema,nameDealer.trgdataTableName(),str(runnum),'DATA')
 
tuple trunkinfo = createBranch(schema,'TRUNK',None,comment='main')
 

Function Documentation

def revisionDML.addEntry (   schema,
  datatableName,
  entryinfo,
  branchinfo 
)
input:
    entryinfo (revision_id(0),entry_id(1),entry_name(2),data_id(3))
    branchinfo (branch_id,branch_name)
1.allocate and insert a new revision into the revisions table
2.allocate and insert a new entry into the entry table with the new revision
3.inset into data_rev table with new data_id ,revision)id mapping

insert into revisions(revision_id,branch_id,branch_name,comment,ctime) values()
insert into datatablename_entries (entry_id,revision_id) values()
insert into datatablename_rev(data_id,revision_id) values()

Definition at line 342 of file revisionDML.py.

References nameDealer.entryTableName(), nameDealer.revisionTableName(), and nameDealer.revmapTableName().

Referenced by CalibrationInterface< CategoryT, CalibDataT >.addCategoryDefinition(), dataDML.addCorrToBranch(), TAPD.addEntry(), TMom.addEntry(), SummaryOutputProducer::TriggerSummary.addEntry(), dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), dataDML.addTrgRunDataToBranch(), normDML.createNorm(), EcalMatacqAnalyzer.endJob(), and AlgorithmCalibration< T, CO >.readCategories().

343 def addEntry(schema,datatableName,entryinfo,branchinfo):
344  '''
345  input:
346  entryinfo (revision_id(0),entry_id(1),entry_name(2),data_id(3))
347  branchinfo (branch_id,branch_name)
348  1.allocate and insert a new revision into the revisions table
349  2.allocate and insert a new entry into the entry table with the new revision
350  3.inset into data_rev table with new data_id ,revision)id mapping
351 
352  insert into revisions(revision_id,branch_id,branch_name,comment,ctime) values()
353  insert into datatablename_entries (entry_id,revision_id) values()
354  insert into datatablename_rev(data_id,revision_id) values()
355  '''
356  try:
357  revisiontableName=nameDealer.revisionTableName()
358  entrytableName=nameDealer.entryTableName(datatableName)
359  revtableName=nameDealer.revmapTableName(datatableName)
360 
361  db=dbUtil.dbUtil(schema)
362  tabrowDefDict={}
363  tabrowDefDict['REVISION_ID']='unsigned long long'
364  tabrowDefDict['BRANCH_ID']='unsigned long long'
365  tabrowDefDict['BRANCH_NAME']='string'
366  tabrowDefDict['CTIME']='time stamp'
367  tabrowValueDict={}
368  tabrowValueDict['REVISION_ID']=entryinfo[0]
369  tabrowValueDict['BRANCH_ID']=branchinfo[0]
370  tabrowValueDict['BRANCH_NAME']=branchinfo[1]
371  tabrowValueDict['CTIME']=coral.TimeStamp()
372  db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
373 
374  tabrowDefDict={}
375  tabrowDefDict['REVISION_ID']='unsigned long long'
376  tabrowDefDict['ENTRY_ID']='unsigned long long'
377  tabrowDefDict['NAME']='string'
378 
379  tabrowValueDict={}
380  tabrowValueDict['REVISION_ID']=entryinfo[0]
381  tabrowValueDict['ENTRY_ID']=entryinfo[1]
382  tabrowValueDict['NAME']=entryinfo[2]
383  db.insertOneRow(entrytableName,tabrowDefDict,tabrowValueDict)
384 
385  tabrowDefDict={}
386  tabrowDefDict['REVISION_ID']='unsigned long long'
387  tabrowDefDict['DATA_ID']='unsigned long long'
388  tabrowValueDict={}
389  tabrowValueDict['REVISION_ID']=entryinfo[0]
390  tabrowValueDict['DATA_ID']=entryinfo[3]
391  db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
392  except:
393  raise
def revmapTableName
Definition: nameDealer.py:100
def revisionTableName
Definition: nameDealer.py:11
def entryTableName
Definition: nameDealer.py:103
def revisionDML.addRevision (   schema,
  datatableName,
  revisioninfo,
  branchinfo 
)
1.insert a new revision into the revisions table
2.insert into data_id, revision_id pair to  datatable_revmap
insert into revisions(revision_id,branch_id,branch_name,ctime) values()
insert into datatable_rev(data_id,revision_id) values())
input:
     revisioninfo (revision_id(0),data_id(1))
     branchinfo  (branch_id(0),branch_name(1))

Definition at line 394 of file revisionDML.py.

References nameDealer.revisionTableName(), and nameDealer.revmapTableName().

Referenced by dataDML.addCorrToBranch(), dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), dataDML.addTrgRunDataToBranch(), and normDML.createNorm().

395 def addRevision(schema,datatableName,revisioninfo,branchinfo):
396  '''
397  1.insert a new revision into the revisions table
398  2.insert into data_id, revision_id pair to datatable_revmap
399  insert into revisions(revision_id,branch_id,branch_name,ctime) values()
400  insert into datatable_rev(data_id,revision_id) values())
401  input:
402  revisioninfo (revision_id(0),data_id(1))
403  branchinfo (branch_id(0),branch_name(1))
404  '''
405  try:
406  revisiontableName=nameDealer.revisionTableName()
407  revtableName=nameDealer.revmapTableName(datatableName)
408 
409  db=dbUtil.dbUtil(schema)
410  tabrowDefDict={}
411  tabrowDefDict['REVISION_ID']='unsigned long long'
412  tabrowDefDict['BRANCH_ID']='unsigned long long'
413  tabrowDefDict['BRANCH_NAME']='string'
414  tabrowDefDict['CTIME']='time stamp'
415 
416  tabrowValueDict={}
417  tabrowValueDict['REVISION_ID']=revisioninfo[0]
418  tabrowValueDict['BRANCH_ID']=branchinfo[0]
419  tabrowValueDict['BRANCH_NAME']=branchinfo[1]
420  tabrowValueDict['CTIME']=coral.TimeStamp()
421 
422  db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
423 
424  tabrowDefDict={}
425  tabrowDefDict['REVISION_ID']='unsigned long long'
426  tabrowDefDict['DATA_ID']='unsigned long long'
427  tabrowValueDict={}
428  tabrowValueDict['REVISION_ID']=revisioninfo[0]
429  tabrowValueDict['DATA_ID']=revisioninfo[1]
430  db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
431  except:
raise
def revmapTableName
Definition: nameDealer.py:100
def revisionTableName
Definition: nameDealer.py:11
def revisionDML.addRunToCurrentDataTag (   schema,
  runnum,
  lumiid,
  trgid,
  hltid,
  lumitype = 'HF',
  comment = '' 
)
select tagid from tags
insert into tagruns(tagid,runnum,lumidataid,trgdataid,hltdataid,creationtime,comment) values(tagid,runnum,lumiid,trgid,hltid,creationtime,comment)

Definition at line 549 of file revisionDML.py.

References currentDataTag(), nameDealer.pixeltagRunsTableName(), and nameDealer.tagRunsTableName().

550 def addRunToCurrentDataTag(schema,runnum,lumiid,trgid,hltid,lumitype='HF',comment=''):
551  '''
552  select tagid from tags
553  insert into tagruns(tagid,runnum,lumidataid,trgdataid,hltdataid,creationtime,comment) values(tagid,runnum,lumiid,trgid,hltid,creationtime,comment)
554  '''
555  if lumitype not in ['HF','PIXEL']:
556  raise ValueError('unknown lumitype '+lumitype)
557  if lumitype=='HF':
558  tagrunstablename=nameDealer.tagRunsTableName()
559  else:
560  tagrunstablename=nameDealer.pixeltagRunsTableName()
561  currenttagid=currentDataTag(schema,lumitype=lumitype)[0]
562  try:
563  db=dbUtil.dbUtil(schema)
564  tabrowDefDict={}
565  tabrowDefDict['TAGID']='unsigned long long'
566  tabrowDefDict['RUNNUM']='unsigned int'
567  tabrowDefDict['LUMIDATAID']='unsigned long long'
568  tabrowDefDict['TRGDATAID']='unsigned long long'
569  tabrowDefDict['HLTDATAID']='unsigned long long'
570  tabrowDefDict['CREATIONTIME']='time stamp'
571  tabrowDefDict['COMMENT']='string'
572  tabrowValueDict={}
573  tabrowValueDict['TAGID']=currenttagid
574  tabrowValueDict['RUNNUM']=runnum
575  tabrowValueDict['LUMIDATAID']=lumiid
576  tabrowValueDict['TRGDATAID']=trgid
577  tabrowValueDict['HLTDATAID']=hltid
578  tabrowValueDict['CREATIONTIME']=coral.TimeStamp()
579  tabrowValueDict['COMMENT']=comment
580  db.insertOneRow( tagrunstablename,tabrowDefDict, tabrowValueDict )
581  except:
582  raise
def tagRunsTableName
Definition: nameDealer.py:64
def pixeltagRunsTableName
Definition: nameDealer.py:70
def addRunToCurrentDataTag
Definition: revisionDML.py:549
def currentDataTag
Definition: revisionDML.py:513
def revisionDML.alldataTags (   schema,
  lumitype = 'HF' 
)
select tagname,tagid from tags,tagruns  
    if number of tags==1->open tag
    if tagid is max ->open tag
    for closed tag:
       max run=max(runnum) where tagid=:tagid
       min run
          select min(runnum) from tagruns where tagid<=:tagid
    for open tag:
       max run=None
       min run
          select min(runnum) from tagruns where tagid<=:tagid
output:
   {tagid:(name,minrun,maxrun,creationtime)}

Definition at line 583 of file revisionDML.py.

References data, bookConverter.max, min(), GetRecoTauVFromDQM_MC_cff.next, nameDealer.pixeltagRunsTableName(), nameDealer.pixeltagsTableName(), nameDealer.tagRunsTableName(), and nameDealer.tagsTableName().

584 def alldataTags(schema,lumitype='HF'):
585  '''
586  select tagname,tagid from tags,tagruns
587  if number of tags==1->open tag
588  if tagid is max ->open tag
589  for closed tag:
590  max run=max(runnum) where tagid=:tagid
591  min run
592  select min(runnum) from tagruns where tagid<=:tagid
593  for open tag:
594  max run=None
595  min run
596  select min(runnum) from tagruns where tagid<=:tagid
597  output:
598  {tagid:(name,minrun,maxrun,creationtime)}
599  '''
600  if lumitype not in ['HF','PIXEL']:
601  raise ValueError('unknown lumitype '+lumitype)
602  if lumitype=='HF':
603  tagstablename=nameDealer.tagsTableName()
604  tagrunstablename=nameDealer.tagRunsTableName()
605  else:
606  tagstablename=nameDealer.pixeltagsTableName()
607  tagrunstablename=nameDealer.pixeltagRunsTableName()
608  tagmap={}#{tagid:[tagname,minrun,maxrun,creationtime]}
609  try:
610  qHandle=schema.newQuery()
611  qHandle.addToTableList( tagstablename )
612  qCondition=coral.AttributeList()
613  qHandle.addToOutputList('TAGNAME')
614  qHandle.addToOutputList('TAGID')
615  qHandle.addToOutputList("TO_CHAR(CREATIONTIME,\'MM/DD/YY HH24:MI:SS\')",'creationtime')
616  qResult=coral.AttributeList()
617  qResult.extend('TAGNAME','string')
618  qResult.extend('TAGID','unsigned long long')
619  qResult.extend('creationtime','string')
620  qHandle.defineOutput(qResult)
621  cursor=qHandle.execute()
622  while next(cursor):
623  tagname=cursor.currentRow()['TAGNAME'].data()
624  tagid=cursor.currentRow()['TAGID'].data()
625  creationtime=cursor.currentRow()['creationtime'].data()
626  tagmap[tagid]=[tagname,0,0,creationtime]
627  del qHandle
628 
629  tagids=tagmap.keys()
630  allruns=set()
631  for tagid in tagids:
632  qConditionStr='TAGID<=:tagid'
633  qCondition=coral.AttributeList()
634  qCondition.extend('tagid','unsigned long long')
635  qCondition['tagid'].setData(tagid)
636  qHandle=schema.newQuery()
637  qHandle.addToTableList( tagrunstablename )
638  qResult=coral.AttributeList()
639  qResult.extend('RUNNUM','unsigned int')
640  qHandle.defineOutput(qResult)
641  qHandle.setCondition(qConditionStr,qCondition)
642  qHandle.addToOutputList('RUNNUM')
643  cursor=qHandle.execute()
644  while next(cursor):
645  rnum=cursor.currentRow()['RUNNUM'].data()
646  allruns.add(rnum)
647  minrun=0
648  maxrun=0
649  if len(allruns)!=0:
650  minrun=min(allruns)
651  maxrun=max(allruns)
652  tagmap[tagid][1]=minrun
653  if len(tagmap)>1 and tagid!=max(tagids):
654  tagmap[tagid][2]=maxrun
655  except:
656  raise
657  return tagmap
def tagsTableName
Definition: nameDealer.py:67
def tagRunsTableName
Definition: nameDealer.py:64
def pixeltagRunsTableName
Definition: nameDealer.py:70
T min(T a, T b)
Definition: MathUtil.h:58
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def pixeltagsTableName
Definition: nameDealer.py:73
def revisionDML.bookNewEntry (   schema,
  datatableName 
)
allocate new revision_id,entry_id,data_id

Definition at line 316 of file revisionDML.py.

References nameDealer.entryTableName(), and nameDealer.revisionTableName().

Referenced by dataDML.addCorrToBranch(), dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), dataDML.addTrgRunDataToBranch(), and normDML.createNorm().

317 def bookNewEntry(schema,datatableName):
318  '''
319  allocate new revision_id,entry_id,data_id
320  '''
321  try:
322  entrytableName=nameDealer.entryTableName(datatableName)
323  iddealer=idDealer.idDealer(schema)
324  revision_id=iddealer.generateNextIDForTable( nameDealer.revisionTableName() )
325  data_id=iddealer.generateNextIDForTable( datatableName)
326  entry_id=iddealer.generateNextIDForTable( nameDealer.entryTableName(datatableName) )
327  return (revision_id,entry_id,data_id)
328  except:
329  raise
def revisionTableName
Definition: nameDealer.py:11
def entryTableName
Definition: nameDealer.py:103
def bookNewEntry
Definition: revisionDML.py:316
def revisionDML.bookNewRevision (   schema,
  datatableName 
)
allocate new revision_id,data_id

Definition at line 330 of file revisionDML.py.

References nameDealer.revisionTableName().

Referenced by dataDML.addCorrToBranch(), dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), dataDML.addTrgRunDataToBranch(), and normDML.createNorm().

331 def bookNewRevision(schema,datatableName):
332  '''
333  allocate new revision_id,data_id
334  '''
335  try:
336  iddealer=idDealer.idDealer(schema)
337  revision_id=iddealer.generateNextIDForTable( nameDealer.revisionTableName() )
338  data_id=iddealer.generateNextIDForTable(datatableName)
339  return (revision_id,data_id)
340  except:
341  raise
def revisionTableName
Definition: nameDealer.py:11
def bookNewRevision
Definition: revisionDML.py:330
def revisionDML.branchInfoByName (   schema,
  branchName 
)
select (revision_id,branch_id) from revisions where name=:branchName

Definition at line 282 of file revisionDML.py.

References data, GetRecoTauVFromDQM_MC_cff.next, and nameDealer.revisionTableName().

Referenced by revisionsInBranchName().

283 def branchInfoByName(schema,branchName):
284  '''
285  select (revision_id,branch_id) from revisions where name=:branchName
286  '''
287  try:
288  qHandle=schema.newQuery()
289  qHandle.addToTableList( nameDealer.revisionTableName() )
290  qHandle.addToOutputList('REVISION_ID','revision_id')
291  qHandle.addToOutputList('BRANCH_ID','branch_id')
292  qCondition=coral.AttributeList()
293  qCondition.extend('name','string')
294  qCondition['name'].setData(branchName)
295  qResult=coral.AttributeList()
296  qResult.extend('revision_id','unsigned long long')
297  qResult.extend('branch_id','unsigned long long')
298  qHandle.defineOutput(qResult)
299  qHandle.setCondition('NAME=:name',qCondition)
300  cursor=qHandle.execute()
301  revision_id=None
302  branch_id=None
303  while next(cursor):
304  revision_id=cursor.currentRow()['revision_id'].data()
305  branch_id=cursor.currentRow()['branch_id'].data()
306  del qHandle
307  return (revision_id,branch_id)
308  except Exception as e :
309  raise RuntimeError(' revisionDML.branchInfoByName: '+str(e))
310 
311 
312 #=======================================================
313 #
314 # INSERT requires in update transaction
315 #
#=======================================================
def branchInfoByName
Definition: revisionDML.py:282
def revisionTableName
Definition: nameDealer.py:11
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def revisionDML.branchType (   schema,
  name 
)
output: tag,branch
the difference between tag and branch: tag is an empty branch
select count(revision_id) from revisions where branch_name=:name
if >0: is real branch
else: is tag

Definition at line 112 of file revisionDML.py.

References data, GetRecoTauVFromDQM_MC_cff.next, and nameDealer.revisionTableName().

Referenced by edm::RootOutputFile.fillBranches(), edm::PoolOutputModule.fillSelectedItemList(), edm::RootOutputFile.finishEndFile(), edm::ProductRegistry.productProduced(), edm::PoolOutputModule.respondToOpenInputFile(), edm::RootOutputFile.RootOutputFile(), edm::ProductRegistry.setProductProduced(), and edm::InputTag.tryToCacheIndex().

113 def branchType(schema,name):
114  '''
115  output: tag,branch
116  the difference between tag and branch: tag is an empty branch
117  select count(revision_id) from revisions where branch_name=:name
118  if >0: is real branch
119  else: is tag
120  '''
121  result='tag'
122  try:
123  qHandle=schema.newQuery()
124  qHandle.addToTableList( nameDealer.revisionTableName() )
125  qHandle.addToOutputList('count(REVISION_ID)','nchildren')
126  qCondition=coral.AttributeList()
127  qCondition.extend('branch_name','string')
128  qCondition['branch_name'].setData(name)
129  qResult=coral.AttributeList()
130  qResult.extend('nchildren','unsigned int')
131  qHandle.defineOutput(qResult)
132  conditionStr='BRANCH_NAME=:branch_name'
133  qHandle.setCondition(conditionStr,qCondition)
134  cursor=qHandle.execute()
135  while next(cursor):
136  if cursor.currentRow()['nchildren'].data()>0:
137  result='branch'
138  del qHandle
139  return result
140  except :
141  raise
142 #def revisionsInBranch(schema,branchid):
143 # '''
144 # returns all revision values in a branch/tag
145 # result=[revision_id]
146 # select r.revision_id from revisions r where r.branch_id=:branchid and r.revision_id not in (select distinct a.branch_id from revisions a where a.branch_id>:branchid)
147 # '''
148 # result=[]
149 # try:
150 # qHandle=schema.newQuery()
151 # subquery=qHandle.defineSubQuery('B')
152 # subquery.addToTableList( nameDealer.revisionTableName(),'a' )
153 # subquery.addToOutputList('distinct a.BRANCH_ID')
154 # subqueryCondition=coral.AttributeList()
155 # subqueryCondition.extend('branchid','unsigned long long')
156 # subqueryCondition['branchid'].setData(branchid)
157 # subquery.setCondition('a.BRANCH_ID>:branchid',subqueryCondition)
158 #
159 # qHandle.addToTableList( nameDealer.revisionTableName(),'r' )
160 # qHandle.addToTableList( 'B')
161 # qHandle.addToOutputList('r.REVISION_ID','revision_id')
162 # qCondition=coral.AttributeList()
163 # qCondition.extend('branchid','unsigned long long')
164 # qCondition['branchid'].setData(branchid)
165 # qResult=coral.AttributeList()
166 # qResult.extend('revision_id','unsigned long long')
167 # qHandle.defineOutput(qResult)
168 # conditionStr='r.BRANCH_ID=:branchid AND r.REVISION_ID NOT IN B'
169 # qHandle.setCondition(conditionStr,qCondition)
170 # cursor=qHandle.execute()
171 # while cursor.next():
172 # result.append(cursor.currentRow()['revision_id'].data())
173 # del qHandle
174 # return result
175 # except :
176 # raise
def revisionTableName
Definition: nameDealer.py:11
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def revisionDML.createBranch (   schema,
  name,
  parentname,
  comment = '' 
)
create a new branch/tag under given parentnode
insert into revisions(revision_id,branch_id,branch_name,name,comment,ctime) values()
return (revisionid,parentid,parentname)

Definition at line 432 of file revisionDML.py.

References data, GetRecoTauVFromDQM_MC_cff.next, and nameDealer.revisionTableName().

Referenced by lumidb2Schema.createBranch().

433 def createBranch(schema,name,parentname,comment=''):
434  '''
435  create a new branch/tag under given parentnode
436  insert into revisions(revision_id,branch_id,branch_name,name,comment,ctime) values()
437  return (revisionid,parentid,parentname)
438  '''
439  try:
440  parentid=None
441  revisionid=0
442  if not parentname is None:
443  qHandle=schema.newQuery()
444  qHandle.addToTableList( nameDealer.revisionTableName() )
445  qHandle.addToOutputList( 'REVISION_ID','revision_id' )
446  qCondition=coral.AttributeList()
447  qCondition.extend('parentname','string')
448  qCondition['parentname'].setData(parentname)
449  qResult=coral.AttributeList()
450  qResult.extend('revision_id','unsigned long long')
451  qHandle.defineOutput(qResult)
452  qHandle.setCondition('NAME=:parentname',qCondition)
453  cursor=qHandle.execute()
454  while next(cursor):
455  parentid=cursor.currentRow()['revision_id'].data()
456  del qHandle
457  else:
458  parentname='ROOT'
459  iddealer=idDealer.idDealer(schema)
460  revisionid=iddealer.generateNextIDForTable( nameDealer.revisionTableName() )
461  db=dbUtil.dbUtil(schema)
462  tabrowDefDict={}
463  tabrowDefDict['REVISION_ID']='unsigned long long'
464  tabrowDefDict['BRANCH_ID']='unsigned long long'
465  tabrowDefDict['BRANCH_NAME']='string'
466  tabrowDefDict['NAME']='string'
467  tabrowDefDict['COMMENT']='string'
468  tabrowDefDict['CTIME']='time stamp'
469  tabrowValueDict={}
470  tabrowValueDict['REVISION_ID']=revisionid
471  tabrowValueDict['BRANCH_ID']=parentid
472  tabrowValueDict['BRANCH_NAME']=parentname
473  tabrowValueDict['NAME']=name
474  tabrowValueDict['COMMENT']=comment
475  tabrowValueDict['CTIME']=coral.TimeStamp()
476  db.insertOneRow(nameDealer.revisionTableName(),tabrowDefDict, tabrowValueDict )
477  return (revisionid,parentid,parentname)
478  except:
479  raise
def revisionTableName
Definition: nameDealer.py:11
def createBranch
Definition: revisionDML.py:432
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def revisionDML.createDataTag (   schema,
  tagname,
  lumitype = 'HF' 
)

Data Tagging API.

insert into tags(tagname,tagid,creationtime) values()
output:
    tagname,tagid,creationtime

Definition at line 483 of file revisionDML.py.

References nameDealer.pixeltagsTableName(), and nameDealer.tagsTableName().

484 def createDataTag(schema,tagname,lumitype='HF'):
485  '''
486  insert into tags(tagname,tagid,creationtime) values()
487  output:
488  tagname,tagid,creationtime
489  '''
490  if lumitype not in ['HF','PIXEL']:
491  raise ValueError('unknown lumitype '+lumitype)
492  if lumitype=='HF':
493  tagstablename=nameDealer.tagsTableName()
494  else:
495  tagstablename=nameDealer.pixeltagsTableName()
496  try:
497  iddealer=idDealer.idDealer(schema)
498  tagid=iddealer.generateNextIDForTable( tagstablename )
499  db=dbUtil.dbUtil(schema)
500  tabrowDefDict={}
501  tabrowDefDict['TAGNAME']='string'
502  tabrowDefDict['TAGID']='unsigned long long'
503  tabrowDefDict['CREATIONTIME']='time stamp'
504  tabrowValueDict={}
505  tabrowValueDict['TAGNAME']=tagname
506  tabrowValueDict['TAGID']=tagid
507  creationtime=coral.TimeStamp()
508  tabrowValueDict['CREATIONTIME']=creationtime
509  db.insertOneRow(tagstablename,tabrowDefDict, tabrowValueDict )
510  return (tagname,tagid,creationtime)
511  except:
512  raise
def tagsTableName
Definition: nameDealer.py:67
def createDataTag
Data Tagging API.
Definition: revisionDML.py:483
def pixeltagsTableName
Definition: nameDealer.py:73
def revisionDML.currentDataTag (   schema,
  lumitype = 'HF' 
)
select tagid,tagname from tags
output:(tagid,tagname)

Definition at line 513 of file revisionDML.py.

References data, bookConverter.max, GetRecoTauVFromDQM_MC_cff.next, nameDealer.pixeltagsTableName(), and nameDealer.tagsTableName().

Referenced by addRunToCurrentDataTag(), and dataIdsByCurrentTag().

514 def currentDataTag(schema,lumitype='HF'):
515  '''
516  select tagid,tagname from tags
517  output:(tagid,tagname)
518  '''
519  if lumitype not in ['HF','PIXEL']:
520  raise ValueError('unknown lumitype '+lumitype)
521  if lumitype=='HF':
522  tagstablename=nameDealer.tagsTableName()
523  else:
524  tagstablename=nameDealer.pixeltagsTableName()
525  tagmap={}
526  try:
527  qHandle=schema.newQuery()
528  qHandle.addToTableList( tagstablename )
529  qHandle.addToOutputList('TAGID')
530  qHandle.addToOutputList('TAGNAME')
531  qResult=coral.AttributeList()
532  qResult.extend('TAGID','unsigned long long')
533  qResult.extend('TAGNAME','string')
534  qHandle.defineOutput(qResult)
535  cursor=qHandle.execute()
536  currenttagid=0
537  while next(cursor):
538  tagid=cursor.currentRow()['TAGID'].data()
539  tagname=cursor.currentRow()['TAGNAME'].data()
540  tagmap[tagid]=tagname
541  del qHandle
542  if len(tagmap)!=0:
543  currenttagid=max(tagmap.keys())
544  if currenttagid==0:
545  raise 'currentDataTag: no tag available'
546  return (currenttagid,tagmap[currenttagid])
547  except:
548  raise
def tagsTableName
Definition: nameDealer.py:67
def currentDataTag
Definition: revisionDML.py:513
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def pixeltagsTableName
Definition: nameDealer.py:73
def revisionDML.dataIdsByCurrentTag (   schema,
  runlist = None,
  lumitype = 'HF' 
)
dataIdsByTagId(schema,currenttagid,runlist)
output:
   (currenttagname,{run:(lumidataid,trgdataid,hltdataid)})

Definition at line 889 of file revisionDML.py.

References currentDataTag(), and dataIdsByTagId().

890 def dataIdsByCurrentTag(schema,runlist=None,lumitype='HF'):
891  '''
892  dataIdsByTagId(schema,currenttagid,runlist)
893  output:
894  (currenttagname,{run:(lumidataid,trgdataid,hltdataid)})
895  '''
896  (currenttagid,currenttagname)=currentDataTag(schema)
897  result=dataIdsByTagId(schema,currenttagid,runlist=runlist,withcomment=False,lumitype=lumitype)
898  return (currenttagname,result)
def dataIdsByTagId
Definition: revisionDML.py:798
def currentDataTag
Definition: revisionDML.py:513
def dataIdsByCurrentTag
Definition: revisionDML.py:889
def revisionDML.dataIdsByTagId (   schema,
  tagid,
  runlist = None,
  withcomment = False,
  lumitype = 'HF' 
)
select runnum,lumidataid,trgdataid,hltdataid,comment from tagruns where TAGID<=:tagid;
input:
    runlist: select run list, if None, all
output:
    {run:(lumidataid,trgdataid,hltdataid,(creationtime,comment))}

Definition at line 798 of file revisionDML.py.

References data, GetRecoTauVFromDQM_MC_cff.next, nameDealer.pixeltagRunsTableName(), and nameDealer.tagRunsTableName().

Referenced by dataIdsByCurrentTag(), and dataIdsByTagName().

799 def dataIdsByTagId(schema,tagid,runlist=None,withcomment=False,lumitype='HF'):
800  '''
801  select runnum,lumidataid,trgdataid,hltdataid,comment from tagruns where TAGID<=:tagid;
802  input:
803  runlist: select run list, if None, all
804  output:
805  {run:(lumidataid,trgdataid,hltdataid,(creationtime,comment))}
806  '''
807  if lumitype not in ['HF','PIXEL']:
808  raise ValueError('unknown lumitype '+lumitype)
809  if lumitype=='HF':
810  tagrunstablename=nameDealer.tagRunsTableName()
811  else:
812  tagrunstablename=nameDealer.pixeltagRunsTableName()
813  result={}#{run:[lumiid,trgid,hltid,comment(optional)]}
814  commentdict={}#{(lumiid,trgid,hltid):[ctimestr,comment]}
815  try:
816  qHandle=schema.newQuery()
817  qHandle.addToTableList(tagrunstablename)
818  qConditionStr='TAGID<=:tagid'
819  qCondition=coral.AttributeList()
820  qCondition.extend('tagid','unsigned long long')
821  qCondition['tagid'].setData(tagid)
822  qResult=coral.AttributeList()
823  qResult.extend('RUNNUM','unsigned int')
824  qResult.extend('LUMIDATAID','unsigned long long')
825  qResult.extend('TRGDATAID','unsigned long long')
826  qResult.extend('HLTDATAID','unsigned long long')
827  if withcomment:
828  qResult.extend('COMMENT','string')
829  qResult.extend('creationtime','string')
830  qHandle.defineOutput(qResult)
831  qHandle.setCondition(qConditionStr,qCondition)
832  qHandle.addToOutputList('RUNNUM')
833  qHandle.addToOutputList('LUMIDATAID')
834  qHandle.addToOutputList('TRGDATAID')
835  qHandle.addToOutputList('HLTDATAID')
836  if withcomment:
837  qHandle.addToOutputList('COMMENT')
838  qHandle.addToOutputList("TO_CHAR(CREATIONTIME,\'MM/DD/YY HH24:MI:SS\')",'creationtime')
839  cursor=qHandle.execute()
840  while next(cursor):
841  runnum=cursor.currentRow()['RUNNUM'].data()
842  if runlist is not None and runnum not in runlist:
843  continue
844  lumidataid=0
845  if not cursor.currentRow()['LUMIDATAID'].isNull():
846  lumidataid=cursor.currentRow()['LUMIDATAID'].data()
847  trgdataid=0
848  if not cursor.currentRow()['TRGDATAID'].isNull():
849  trgdataid=cursor.currentRow()['TRGDATAID'].data()
850  hltdataid=0
851  if not cursor.currentRow()['HLTDATAID'].isNull():
852  hltdataid=cursor.currentRow()['HLTDATAID'].data()
853  if runnum not in result:
854  result[runnum]=[0,0,0]
855  if lumidataid>result[runnum][0]:
856  result[runnum][0]=lumidataid
857  if trgdataid>result[runnum][1]:
858  result[runnum][1]=trgdataid
859  if hltdataid>result[runnum][2]:
860  result[runnum][2]=hltdataid
861  if withcomment:
862  comment=''
863  creationtime=''
864  if not cursor.currentRow()['creationtime'].isNull():
865  creationtime=cursor.currentRow()['creationtime'].data()
866  if not cursor.currentRow()['COMMENT'].isNull():
867  comment=cursor.currentRow()['COMMENT'].data()
868  commentdict[(lumidataid,trgdataid,hltdataid)]=(creationtime,comment)
869  del qHandle
870  if withcomment:
871  for run,resultentry in result.items():
872  lumiid=resultentry[0]
873  trgid=resultentry[1]
874  hltid=resultentry[2]
875  if (lumiid,trgid,hltid) in commentdict:
876  resultentry.append(commentdict[(lumiid,trgid,hltid)])
877  elif (lumiid,0,0) in commentdict:
878  resultentry.append(commentdict[(lumiid,0,0)])
879  elif commentdict.has_ley((0,trgid,0)):
880  resultentry.append(commentdict[(0,trgid,0)])
881  elif commentdict.has_ley((0,0,hltid)):
882  resultentry.append(commentdict[(0,0,hltid)])
883  else:
884  resultentry.append(())
885 
886  except:
887  raise
888  return result
def tagRunsTableName
Definition: nameDealer.py:64
def pixeltagRunsTableName
Definition: nameDealer.py:70
def dataIdsByTagId
Definition: revisionDML.py:798
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def revisionDML.dataIdsByTagName (   schema,
  tagname,
  runlist = None,
  withcomment = False,
  lumitype = 'HF' 
)
select tagid from tags where tagname=:tagname
input:
    runlist: select run list, if None, all
output:
    {run:(lumidataid,trgdataid,hltdataid,(creationtime,comment)}

Definition at line 689 of file revisionDML.py.

References data, dataIdsByTagId(), GetRecoTauVFromDQM_MC_cff.next, nameDealer.pixeltagsTableName(), and nameDealer.tagsTableName().

690 def dataIdsByTagName(schema,tagname,runlist=None,withcomment=False,lumitype='HF'):
691  '''
692  select tagid from tags where tagname=:tagname
693  input:
694  runlist: select run list, if None, all
695  output:
696  {run:(lumidataid,trgdataid,hltdataid,(creationtime,comment)}
697  '''
698  if lumitype not in ['HF','PIXEL']:
699  raise ValueError('unknown lumitype '+lumitype)
700  if lumitype=='HF':
701  tagstablename=nameDealer.tagsTableName()
702  else:
703  tagstablename=nameDealer.pixeltagsTableName()
704  tagid=None
705  try:
706  qHandle=schema.newQuery()
707  qHandle.addToTableList( tagstablename )
708  qConditionStr='TAGNAME=:tagname'
709  qCondition=coral.AttributeList()
710  qCondition.extend('tagname','string')
711  qCondition['tagname'].setData(tagname)
712  qHandle.addToOutputList('TAGID')
713  qResult=coral.AttributeList()
714  qResult.extend('TAGID','unsigned long long')
715  qHandle.defineOutput(qResult)
716  qHandle.setCondition(qConditionStr,qCondition)
717  cursor=qHandle.execute()
718  while next(cursor):
719  if not cursor.currentRow()['TAGID'].isNull():
720  tagid=cursor.currentRow()['TAGID'].data()
721  del qHandle
722  except:
723  raise
724  if tagid is None:
725  return {}
726  return dataIdsByTagId(schema,tagid,runlist=runlist,withcomment=withcomment,lumitype=lumitype)
727 
def tagsTableName
Definition: nameDealer.py:67
def dataIdsByTagId
Definition: revisionDML.py:798
def dataIdsByTagName
Definition: revisionDML.py:689
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def pixeltagsTableName
Definition: nameDealer.py:73
def revisionDML.dataRevisionsOfEntry (   schema,
  datatableName,
  entry,
  revrange 
)
all data version of the given entry whose revision falls in branch revision range
select d.data_id,r.revision_id from datatable d, datarevmaptable r where d.entry_id(or name )=:entry and d.data_id=r.data_id
input: if isinstance(entry,str): d.entry_name=:entry ; else d.entry_id=:entry
output: [data_id]

Definition at line 231 of file revisionDML.py.

References data, GetRecoTauVFromDQM_MC_cff.next, and nameDealer.revmapTableName().

Referenced by latestDataRevisionOfEntry().

232 def dataRevisionsOfEntry(schema,datatableName,entry,revrange):
233  '''
234  all data version of the given entry whose revision falls in branch revision range
235  select d.data_id,r.revision_id from datatable d, datarevmaptable r where d.entry_id(or name )=:entry and d.data_id=r.data_id
236  input: if isinstance(entry,str): d.entry_name=:entry ; else d.entry_id=:entry
237  output: [data_id]
238  '''
239  qHandle=schema.newQuery()
240  try:
241  result=[]
242  byname=False
243  if isinstance(entry,str):
244  byname=True
245  qHandle.addToTableList( datatableName,'d' )
246  qHandle.addToTableList( nameDealer.revmapTableName(datatableName), 'r')
247  qHandle.addToOutputList('d.DATA_ID','data_id')
248  qHandle.addToOutputList('r.REVISION_ID','revision_id')
249  qCondition=coral.AttributeList()
250  qConditionStr='d.DATA_ID=r.DATA_ID and '
251  if byname:
252  qCondition.extend('entry_name','string')
253  qCondition['entry_name'].setData(entry)
254  qConditionStr+='d.ENTRY_NAME=:entry_name'
255  else:
256  qCondition.extend('entry_id','unsigned long long')
257  qCondition['entry_id'].setData(entry)
258  qConditionStr+='d.ENTRY_ID=:entry_id'
259  qResult=coral.AttributeList()
260  qResult.extend('data_id','unsigned long long')
261  qResult.extend('revision_id','unsigned long long')
262  qHandle.defineOutput(qResult)
263  qHandle.setCondition(qConditionStr,qCondition)
264  cursor=qHandle.execute()
265  while next(cursor):
266  data_id=cursor.currentRow()['data_id'].data()
267  revision_id=cursor.currentRow()['revision_id'].data()
268  if revision_id in revrange:
269  result.append(data_id)
270  return result
271  except :
272  del qHandle
273  raise
def revmapTableName
Definition: nameDealer.py:100
def dataRevisionsOfEntry
Definition: revisionDML.py:231
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def revisionDML.dataTagInfo (   schema,
  tagname,
  runlist = None,
  lumitype = 'HF' 
)
select tagid from tags where tagname=:tagname
select runnum,comment from tagruns where tagid<=:tagid
input:
    runlist: select run list, if None, all
output:
   {tagid:(name,minrun,maxrun,creationtime)}

Definition at line 728 of file revisionDML.py.

References data, bookConverter.max, min(), GetRecoTauVFromDQM_MC_cff.next, nameDealer.pixeltagRunsTableName(), nameDealer.pixeltagsTableName(), nameDealer.tagRunsTableName(), and nameDealer.tagsTableName().

729 def dataTagInfo(schema,tagname,runlist=None,lumitype='HF'):
730  '''
731  select tagid from tags where tagname=:tagname
732  select runnum,comment from tagruns where tagid<=:tagid
733  input:
734  runlist: select run list, if None, all
735  output:
736  {tagid:(name,minrun,maxrun,creationtime)}
737  '''
738  if lumitype not in ['HF','PIXEL']:
739  raise ValueError('unknown lumitype '+lumitype)
740  if lumitype=='HF':
741  tagstablename=nameDealer.tagsTableName()
742  tagrunstablename=nameDealer.tagRunsTableName()
743  else:
744  tagstablename=nameDealer.pixeltagsTableName()
745  tagrunstablename=nameDealer.pixeltagRunsTableName()
746  tagmap={}#{tagid:[tagname,minrun,maxrun,creationtime]}
747  try:
748  qHandle=schema.newQuery()
749  qHandle.addToTableList( tagstablename )
750  qCondition=coral.AttributeList()
751  qHandle.addToOutputList('TAGNAME')
752  qHandle.addToOutputList('TAGID')
753  qHandle.addToOutputList("TO_CHAR(CREATIONTIME,\'MM/DD/YY HH24:MI:SS\')",'creationtime')
754  qResult=coral.AttributeList()
755  qResult.extend('TAGNAME','string')
756  qResult.extend('TAGID','unsigned long long')
757  qResult.extend('creationtime','string')
758  qHandle.defineOutput(qResult)
759  cursor=qHandle.execute()
760  while next(cursor):
761  tagname=cursor.currentRow()['TAGNAME'].data()
762  tagid=cursor.currentRow()['TAGID'].data()
763  creationtime=cursor.currentRow()['creationtime'].data()
764  tagmap[tagid]=[tagname,0,0,creationtime]
765  del qHandle
766 
767  tagids=tagmap.keys()
768  allruns=set()
769  for tagid in tagids:
770  qConditionStr='TAGID<=:tagid'
771  qCondition=coral.AttributeList()
772  qCondition.extend('tagid','unsigned long long')
773  qCondition['tagid'].setData(tagid)
774  qHandle=schema.newQuery()
775  qHandle.addToTableList(tagrunstablename)
776  qResult=coral.AttributeList()
777  qResult.extend('RUNNUM','unsigned int')
778  qHandle.defineOutput(qResult)
779  qHandle.setCondition(qConditionStr,qCondition)
780  qHandle.addToOutputList('RUNNUM')
781  cursor=qHandle.execute()
782  while next(cursor):
783  rnum=cursor.currentRow()['RUNNUM'].data()
784  if runlist is not None and rnum not in runlist:
785  continue
786  allruns.add(rnum)
787  minrun=0
788  maxrun=0
789  if len(allruns)!=0:
790  minrun=min(allruns)
791  maxrun=max(allruns)
792  tagmap[tagid][1]=minrun
793  if len(tagmap)>1 and tagid!=max(tagids):
794  tagmap[tagid][2]=maxrun
795  except:
796  raise
797  return tagmap
def tagsTableName
Definition: nameDealer.py:67
def tagRunsTableName
Definition: nameDealer.py:64
def pixeltagRunsTableName
Definition: nameDealer.py:70
T min(T a, T b)
Definition: MathUtil.h:58
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def pixeltagsTableName
Definition: nameDealer.py:73
def revisionDML.entryInBranch (   schema,
  datatableName,
  entryname,
  branch 
)
whether an entry(by name) already exists in the given branch
select e.entry_id from entrytable e,revisiontable r where r.revision_id=e.revision_id and e.name=:entryname and r.branch_name=branchname/branch_id
input:
    if isinstance(branch,str):byname
    else: byid
output:entry_id/None

Definition at line 188 of file revisionDML.py.

References data, nameDealer.entryTableName(), GetRecoTauVFromDQM_MC_cff.next, and nameDealer.revisionTableName().

Referenced by dataDML.addCorrToBranch(), dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), dataDML.addTrgRunDataToBranch(), normDML.createNorm(), dataDML.guessHltDataIdByRunInBranch(), dataDML.guessLumiDataIdByRunInBranch(), and dataDML.guessTrgDataIdByRunInBranch().

189 def entryInBranch(schema,datatableName,entryname,branch):
190  '''
191  whether an entry(by name) already exists in the given branch
192  select e.entry_id from entrytable e,revisiontable r where r.revision_id=e.revision_id and e.name=:entryname and r.branch_name=branchname/branch_id
193  input:
194  if isinstance(branch,str):byname
195  else: byid
196  output:entry_id/None
197  '''
198  try:
199  result=None
200  byname=False
201  if isinstance(branch,str):
202  byname=True
203  qHandle=schema.newQuery()
204  qHandle.addToTableList( nameDealer.entryTableName(datatableName),'e' )
205  qHandle.addToTableList( nameDealer.revisionTableName(),'r' )
206  qHandle.addToOutputList('e.ENTRY_ID','entry_id')
207  qCondition=coral.AttributeList()
208  qCondition.extend('entryname','string')
209  qCondition['entryname'].setData(entryname)
210  qConditionStr='r.REVISION_ID=e.REVISION_ID and e.NAME=:entryname and '
211  if byname:
212  qCondition.extend('branch_name','string')
213  qCondition['branch_name'].setData(branch)
214  qConditionStr+='r.BRANCH_NAME=:branch_name'
215  else:
216  qCondition.extend('branch_id','unsigned long long')
217  qCondition['branch_id'].setData(branch)
218  qConditionStr+='r.BRANCH_ID=:branch_id'
219  qResult=coral.AttributeList()
220  qResult.extend('entry_id','unsigned long long')
221  qHandle.defineOutput(qResult)
222  qHandle.setCondition(qConditionStr,qCondition)
223  cursor=qHandle.execute()
224  while next(cursor):
225  entry_id=cursor.currentRow()['entry_id'].data()
226  result=entry_id
227  del qHandle
228  return result
229  except :
230  raise
def revisionTableName
Definition: nameDealer.py:11
def entryTableName
Definition: nameDealer.py:103
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def entryInBranch
Definition: revisionDML.py:188
def revisionDML.getDataTagId (   schema,
  tagname,
  lumitype = 'HF' 
)
select tagid from tags where tagname=:tagname

Definition at line 658 of file revisionDML.py.

References data, GetRecoTauVFromDQM_MC_cff.next, nameDealer.pixeltagsTableName(), and nameDealer.tagsTableName().

659 def getDataTagId(schema,tagname,lumitype='HF'):
660  '''
661  select tagid from tags where tagname=:tagname
662  '''
663  if lumitype not in ['HF','PIXEL']:
664  raise ValueError('unknown lumitype '+lumitype)
665  if lumitype=='HF':
666  tagstablename=nameDealer.tagsTableName()
667  else:
668  tagstablename=nameDealer.pixeltagsTableName()
669  tagid=None
670  try:
671  qHandle=schema.newQuery()
672  qHandle.addToTableList( tagstablename )
673  qConditionStr='TAGNAME=:tagname'
674  qCondition=coral.AttributeList()
675  qCondition.extend('tagname','string')
676  qCondition['tagname'].setData(tagname)
677  qHandle.addToOutputList('TAGID')
678  qResult=coral.AttributeList()
679  qResult.extend('TAGID','unsigned long long')
680  qHandle.defineOutput(qResult)
681  qHandle.setCondition(qConditionStr,qCondition)
682  cursor=qHandle.execute()
683  while next(cursor):
684  if not cursor.currentRow()['TAGID'].isNull():
685  tagid=cursor.currentRow()['TAGID'].data()
686  del qHandle
687  except:
688  raise
return tagid
def tagsTableName
Definition: nameDealer.py:67
def getDataTagId
Definition: revisionDML.py:658
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def pixeltagsTableName
Definition: nameDealer.py:73
def revisionDML.latestDataRevisionOfEntry (   schema,
  datatableName,
  entry,
  revrange 
)
return max(data_id) of all datarevisionofEntry

Definition at line 274 of file revisionDML.py.

References dataRevisionsOfEntry(), and bookConverter.max.

Referenced by dataDML.guessHltDataIdByRunInBranch(), dataDML.guessLumiDataIdByRunInBranch(), and dataDML.guessTrgDataIdByRunInBranch().

275 def latestDataRevisionOfEntry(schema,datatableName,entry,revrange):
276  '''
277  return max(data_id) of all datarevisionofEntry
278  '''
279  result=dataRevisionsOfEntry(schema,datatableName,entry,revrange)
280  if result and len(result)!=0: return max(result)
281  return None
def dataRevisionsOfEntry
Definition: revisionDML.py:231
def latestDataRevisionOfEntry
Definition: revisionDML.py:274
def revisionDML.revisionsInBranch (   schema,
  branchid 
)
returns all revision values in a branch
result=[revision_id]
select distinct branch_id from revisions where branch_id>:branchid;
select revision_id from revisions where branch_id=:branchid ;
if the branchid matches and the revisionid is not in the branchid collection,not 0, then this revision is in the branch
require also revisionid>branchid

Definition at line 61 of file revisionDML.py.

References data, GetRecoTauVFromDQM_MC_cff.next, and nameDealer.revisionTableName().

Referenced by revisionsInBranchName().

61 
62 def revisionsInBranch(schema,branchid):
63  '''
64  returns all revision values in a branch
65  result=[revision_id]
66  select distinct branch_id from revisions where branch_id>:branchid;
67  select revision_id from revisions where branch_id=:branchid ;
68  if the branchid matches and the revisionid is not in the branchid collection,not 0, then this revision is in the branch
69  require also revisionid>branchid
70  '''
71  result=[]
72  qHandle=schema.newQuery()
73  try:
74  nextbranches=[]
75  qHandle.addToTableList( nameDealer.revisionTableName() )
76  qHandle.addToOutputList('distinct BRANCH_ID','branch_id')
77  qCondition=coral.AttributeList()
78  qCondition.extend('branchid','unsigned long long')
79  qCondition['branchid'].setData(branchid)
80  qResult=coral.AttributeList()
81  qResult.extend('branch_id','unsigned long long')
82  qHandle.defineOutput(qResult)
83  qHandle.setCondition('BRANCH_ID>:branchid',qCondition)
84  cursor=qHandle.execute()
85  while next(cursor):
86  nextbranches.append(cursor.currentRow()['branch_id'].data())
87  del qHandle
88  candidates=[]
89  conditionStr='BRANCH_ID=:branchid and REVISION_ID!=0'
90  qHandle=schema.newQuery()
91  qHandle.addToTableList( nameDealer.revisionTableName() )
92  qHandle.addToOutputList('REVISION_ID','revision_id')
93  qCondition=coral.AttributeList()
94  qCondition.extend('branchid','unsigned long long')
95  qCondition['branchid'].setData(branchid)
96  qResult=coral.AttributeList()
97  qResult.extend('revision_id','unsigned long long')
98  qHandle.defineOutput(qResult)
99  qHandle.setCondition(conditionStr,qCondition)
100  cursor=qHandle.execute()
101  while next(cursor):
102  candidates.append(cursor.currentRow()['revision_id'].data())
103  del qHandle
104  for c in candidates:
105  if c in nextbranches:
106  continue
107  result.append(c)
108  return result
109  except:
110  if qHandle: del qHandle
111  raise
def revisionTableName
Definition: nameDealer.py:11
def revisionsInBranch
Definition: revisionDML.py:61
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def revisionDML.revisionsInBranchName (   schema,
  branchname 
)
returns all revisions in a branch/tag by name

Definition at line 177 of file revisionDML.py.

References branchInfoByName(), and revisionsInBranch().

Referenced by dataDML.guessHltDataIdByRunInBranch(), dataDML.guessLumiDataIdByRunInBranch(), and dataDML.guessTrgDataIdByRunInBranch().

178 def revisionsInBranchName(schema,branchname):
179  '''
180  returns all revisions in a branch/tag by name
181  '''
182  result=[]
183  try:
184  (revision_id,branch_id)=branchInfoByName(schema,branchname)
185  result=revisionsInBranch(schema,revision_id)
186  return result
187  except :
raise
def branchInfoByName
Definition: revisionDML.py:282
def revisionsInBranchName
Definition: revisionDML.py:177
def revisionsInBranch
Definition: revisionDML.py:61
def revisionDML.revisionsInTag (   schema,
  tagrevisionid,
  branchid 
)
returns all revisions before tag in selected branch
select revision_id from revisions where revision_id!=0 and revision_id<tagrevisionid and branch_id=:branchid
result=[revision_id]

Definition at line 12 of file revisionDML.py.

References data, GetRecoTauVFromDQM_MC_cff.next, and nameDealer.revisionTableName().

12 
13 def revisionsInTag(schema,tagrevisionid,branchid):
14  '''
15  returns all revisions before tag in selected branch
16  select revision_id from revisions where revision_id!=0 and revision_id<tagrevisionid and branch_id=:branchid
17  result=[revision_id]
18  '''
19  result=[]
20  qHandle=schema.newQuery()
21  try:
22  nextbranches=[]
23  qHandle.addToTableList( nameDealer.revisionTableName() )
24  qHandle.addToOutputList('distinct BRANCH_ID','branch_id')
25  qCondition=coral.AttributeList()
26  qCondition.extend('branchid','unsigned long long')
27  qCondition['branchid'].setData(branchid)
28  qResult=coral.AttributeList()
29  qResult.extend('branch_id','unsigned long long')
30  qHandle.defineOutput(qResult)
31  qHandle.setCondition('BRANCH_ID>:branchid',qCondition)
32  cursor=qHandle.execute()
33  while next(cursor):
34  nextbranches.append(cursor.currentRow()['branch_id'].data())
35  del qHandle
36  candidates=[]
37  conditionStr='REVISION_ID!=0 and BRANCH_ID=:branchid and REVISION_ID<:tagrevisionid'
38  qHandle=schema.newQuery()
39  qHandle.addToTableList( nameDealer.revisionTableName() )
40  qHandle.addToOutputList('REVISION_ID','revision_id')
41  qCondition=coral.AttributeList()
42  qCondition.extend('branchid','unsigned long long')
43  qCondition.extend('tagrevisionid','unsigned long long')
44  qCondition['branchid'].setData(branchid)
45  qCondition['tagrevisionid'].setData(tagrevisionid)
46  qResult=coral.AttributeList()
47  qResult.extend('revision_id','unsigned long long')
48  qHandle.defineOutput(qResult)
49  qHandle.setCondition(conditionStr,qCondition)
50  cursor=qHandle.execute()
51  while next(cursor):
52  candidates.append(cursor.currentRow()['revision_id'].data())
53  del qHandle
54  for c in candidates:
55  if c in nextbranches:
56  continue
57  result.append(c)
58  return result
59  except:
60  if qHandle:del qHandle
raise
def revisionTableName
Definition: nameDealer.py:11
def revisionsInTag
Definition: revisionDML.py:12
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Variable Documentation

tuple revisionDML.databranchinfo = (branchid,'DATA')

Definition at line 917 of file revisionDML.py.

tuple revisionDML.datainfo = createBranch(schema,'DATA','TRUNK',comment='hold data')

Definition at line 912 of file revisionDML.py.

tuple revisionDML.entryinfo = (revision_id,entry_id,str(runnum),data_id)

Definition at line 925 of file revisionDML.py.

tuple revisionDML.hltentryid = entryInBranch(schema,nameDealer.hltdataTableName(),str(runnum),'DATA')

Definition at line 922 of file revisionDML.py.

tuple revisionDML.latestrevision = latestDataRevisionOfEntry(schema,nameDealer.lumidataTableName(),lumientry_id,revlist)

Definition at line 959 of file revisionDML.py.

tuple revisionDML.lumientry_id = entryInBranch(schema,nameDealer.lumidataTableName(),'1211','DATA')

Definition at line 957 of file revisionDML.py.

tuple revisionDML.lumientryid = entryInBranch(schema,nameDealer.lumidataTableName(),str(runnum),'DATA')

Definition at line 920 of file revisionDML.py.

string revisionDML.myconstr = 'sqlite_file:test.db'

Definition at line 904 of file revisionDML.py.

tuple revisionDML.norminfo = createBranch(schema,'NORM','TRUNK',comment='hold normalization factor')

Definition at line 914 of file revisionDML.py.

tuple revisionDML.revisioninfo = bookNewRevision( schema,nameDealer.lumidataTableName() )

Definition at line 929 of file revisionDML.py.

tuple revisionDML.revlist = revisionsInBranchName(schema,'DATA')

Definition at line 955 of file revisionDML.py.

tuple revisionDML.schema = session.nominalSchema()

Definition at line 907 of file revisionDML.py.

tuple revisionDML.session = svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])

Definition at line 906 of file revisionDML.py.

tuple revisionDML.svc = sessionManager.sessionManager(myconstr,debugON=False)

Definition at line 905 of file revisionDML.py.

tuple revisionDML.tables = lumidbDDL.createTables(schema)

Definition at line 909 of file revisionDML.py.

tuple revisionDML.trgentryid = entryInBranch(schema,nameDealer.trgdataTableName(),str(runnum),'DATA')

Definition at line 921 of file revisionDML.py.

tuple revisionDML.trunkinfo = createBranch(schema,'TRUNK',None,comment='main')

Definition at line 910 of file revisionDML.py.