8 from RecoLuminosity.LumiDB
import nameDealer,idDealer,dbUtil
14 returns all revisions before tag in selected branch
15 select revision_id from revisions where revision_id!=0 and revision_id<tagrevisionid and branch_id=:branchid
19 qHandle=schema.newQuery()
23 qHandle.addToOutputList(
'distinct BRANCH_ID',
'branch_id')
24 qCondition=coral.AttributeList()
25 qCondition.extend(
'branchid',
'unsigned long long')
26 qCondition[
'branchid'].setData(branchid)
27 qResult=coral.AttributeList()
28 qResult.extend(
'branch_id',
'unsigned long long')
29 qHandle.defineOutput(qResult)
30 qHandle.setCondition(
'BRANCH_ID>:branchid',qCondition)
31 cursor=qHandle.execute()
33 nextbranches.append(cursor.currentRow()[
'branch_id'].
data())
36 conditionStr=
'REVISION_ID!=0 and BRANCH_ID=:branchid and REVISION_ID<:tagrevisionid'
37 qHandle=schema.newQuery()
39 qHandle.addToOutputList(
'REVISION_ID',
'revision_id')
40 qCondition=coral.AttributeList()
41 qCondition.extend(
'branchid',
'unsigned long long')
42 qCondition.extend(
'tagrevisionid',
'unsigned long long')
43 qCondition[
'branchid'].setData(branchid)
44 qCondition[
'tagrevisionid'].setData(tagrevisionid)
45 qResult=coral.AttributeList()
46 qResult.extend(
'revision_id',
'unsigned long long')
47 qHandle.defineOutput(qResult)
48 qHandle.setCondition(conditionStr,qCondition)
49 cursor=qHandle.execute()
51 candidates.append(cursor.currentRow()[
'revision_id'].
data())
59 if qHandle:del qHandle
63 returns all revision values in a branch
65 select distinct branch_id from revisions where branch_id>:branchid;
66 select revision_id from revisions where branch_id=:branchid ;
67 if the branchid matches and the revisionid is not in the branchid collection,not 0, then this revision is in the branch
68 require also revisionid>branchid
71 qHandle=schema.newQuery()
75 qHandle.addToOutputList(
'distinct BRANCH_ID',
'branch_id')
76 qCondition=coral.AttributeList()
77 qCondition.extend(
'branchid',
'unsigned long long')
78 qCondition[
'branchid'].setData(branchid)
79 qResult=coral.AttributeList()
80 qResult.extend(
'branch_id',
'unsigned long long')
81 qHandle.defineOutput(qResult)
82 qHandle.setCondition(
'BRANCH_ID>:branchid',qCondition)
83 cursor=qHandle.execute()
85 nextbranches.append(cursor.currentRow()[
'branch_id'].
data())
88 conditionStr=
'BRANCH_ID=:branchid and REVISION_ID!=0'
89 qHandle=schema.newQuery()
91 qHandle.addToOutputList(
'REVISION_ID',
'revision_id')
92 qCondition=coral.AttributeList()
93 qCondition.extend(
'branchid',
'unsigned long long')
94 qCondition[
'branchid'].setData(branchid)
95 qResult=coral.AttributeList()
96 qResult.extend(
'revision_id',
'unsigned long long')
97 qHandle.defineOutput(qResult)
98 qHandle.setCondition(conditionStr,qCondition)
99 cursor=qHandle.execute()
101 candidates.append(cursor.currentRow()[
'revision_id'].
data())
104 if c
in nextbranches:
109 if qHandle: del qHandle
115 the difference between tag and branch: tag is an empty branch
116 select count(revision_id) from revisions where branch_name=:name
117 if >0: is real branch
122 qHandle=schema.newQuery()
124 qHandle.addToOutputList(
'count(REVISION_ID)',
'nchildren')
125 qCondition=coral.AttributeList()
126 qCondition.extend(
'branch_name',
'string')
127 qCondition[
'branch_name'].setData(name)
128 qResult=coral.AttributeList()
129 qResult.extend(
'nchildren',
'unsigned int')
130 qHandle.defineOutput(qResult)
131 conditionStr=
'BRANCH_NAME=:branch_name'
132 qHandle.setCondition(conditionStr,qCondition)
133 cursor=qHandle.execute()
135 if cursor.currentRow()[
'nchildren'].
data()>0:
179 returns all revisions in a branch/tag by name
190 whether an entry(by name) already exists in the given branch
191 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 if isinstance(branch,str):byname
200 if isinstance(branch,str):
202 qHandle=schema.newQuery()
205 qHandle.addToOutputList('e.ENTRY_ID',
'entry_id')
206 qCondition=coral.AttributeList()
207 qCondition.extend(
'entryname',
'string')
208 qCondition[
'entryname'].setData(entryname)
209 qConditionStr=
'r.REVISION_ID=e.REVISION_ID and e.NAME=:entryname and '
211 qCondition.extend(
'branch_name',
'string')
212 qCondition[
'branch_name'].setData(branch)
213 qConditionStr+=
'r.BRANCH_NAME=:branch_name'
215 qCondition.extend(
'branch_id',
'unsigned long long')
216 qCondition[
'branch_id'].setData(branch)
217 qConditionStr+=
'r.BRANCH_ID=:branch_id'
218 qResult=coral.AttributeList()
219 qResult.extend(
'entry_id',
'unsigned long long')
220 qHandle.defineOutput(qResult)
221 qHandle.setCondition(qConditionStr,qCondition)
222 cursor=qHandle.execute()
224 entry_id=cursor.currentRow()[
'entry_id'].
data()
233 all data version of the given entry whose revision falls in branch revision range
234 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
235 input: if isinstance(entry,str): d.entry_name=:entry ; else d.entry_id=:entry
238 qHandle=schema.newQuery()
242 if isinstance(entry,str):
244 qHandle.addToTableList( datatableName,
'd' )
246 qHandle.addToOutputList('d.DATA_ID',
'data_id')
247 qHandle.addToOutputList(
'r.REVISION_ID',
'revision_id')
248 qCondition=coral.AttributeList()
249 qConditionStr=
'd.DATA_ID=r.DATA_ID and '
251 qCondition.extend(
'entry_name',
'string')
252 qCondition[
'entry_name'].setData(entry)
253 qConditionStr+=
'd.ENTRY_NAME=:entry_name'
255 qCondition.extend(
'entry_id',
'unsigned long long')
256 qCondition[
'entry_id'].setData(entry)
257 qConditionStr+=
'd.ENTRY_ID=:entry_id'
258 qResult=coral.AttributeList()
259 qResult.extend(
'data_id',
'unsigned long long')
260 qResult.extend(
'revision_id',
'unsigned long long')
261 qHandle.defineOutput(qResult)
262 qHandle.setCondition(qConditionStr,qCondition)
263 cursor=qHandle.execute()
265 data_id=cursor.currentRow()[
'data_id'].
data()
266 revision_id=cursor.currentRow()[
'revision_id'].
data()
267 if revision_id
in revrange:
268 result.append(data_id)
276 return max(data_id) of all datarevisionofEntry
279 if result
and len(result)!=0:
return max(result)
284 select (revision_id,branch_id) from revisions where name=:branchName
287 qHandle=schema.newQuery()
289 qHandle.addToOutputList(
'REVISION_ID',
'revision_id')
290 qHandle.addToOutputList(
'BRANCH_ID',
'branch_id')
291 qCondition=coral.AttributeList()
292 qCondition.extend(
'name',
'string')
293 qCondition[
'name'].setData(branchName)
294 qResult=coral.AttributeList()
295 qResult.extend(
'revision_id',
'unsigned long long')
296 qResult.extend(
'branch_id',
'unsigned long long')
297 qHandle.defineOutput(qResult)
298 qHandle.setCondition(
'NAME=:name',qCondition)
299 cursor=qHandle.execute()
303 revision_id=cursor.currentRow()[
'revision_id'].
data()
304 branch_id=cursor.currentRow()[
'branch_id'].
data()
306 return (revision_id,branch_id)
307 except Exception
as e :
308 raise RuntimeError(
' revisionDML.branchInfoByName: '+str(e))
318 allocate new revision_id,entry_id,data_id
324 data_id=iddealer.generateNextIDForTable( datatableName)
326 return (revision_id,entry_id,data_id)
332 allocate new revision_id,data_id
337 data_id=iddealer.generateNextIDForTable(datatableName)
338 return (revision_id,data_id)
342 def addEntry(schema,datatableName,entryinfo,branchinfo):
345 entryinfo (revision_id(0),entry_id(1),entry_name(2),data_id(3))
346 branchinfo (branch_id,branch_name)
347 1.allocate and insert a new revision into the revisions table
348 2.allocate and insert a new entry into the entry table with the new revision
349 3.inset into data_rev table with new data_id ,revision)id mapping
351 insert into revisions(revision_id,branch_id,branch_name,comment,ctime) values()
352 insert into datatablename_entries (entry_id,revision_id) values()
353 insert into datatablename_rev(data_id,revision_id) values()
362 tabrowDefDict[
'REVISION_ID']=
'unsigned long long'
363 tabrowDefDict[
'BRANCH_ID']=
'unsigned long long'
364 tabrowDefDict[
'BRANCH_NAME']=
'string'
365 tabrowDefDict[
'CTIME']=
'time stamp'
367 tabrowValueDict[
'REVISION_ID']=entryinfo[0]
368 tabrowValueDict[
'BRANCH_ID']=branchinfo[0]
369 tabrowValueDict[
'BRANCH_NAME']=branchinfo[1]
370 tabrowValueDict[
'CTIME']=coral.TimeStamp()
371 db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
374 tabrowDefDict[
'REVISION_ID']=
'unsigned long long'
375 tabrowDefDict[
'ENTRY_ID']=
'unsigned long long'
376 tabrowDefDict[
'NAME']=
'string'
379 tabrowValueDict[
'REVISION_ID']=entryinfo[0]
380 tabrowValueDict[
'ENTRY_ID']=entryinfo[1]
381 tabrowValueDict[
'NAME']=entryinfo[2]
382 db.insertOneRow(entrytableName,tabrowDefDict,tabrowValueDict)
385 tabrowDefDict[
'REVISION_ID']=
'unsigned long long'
386 tabrowDefDict[
'DATA_ID']=
'unsigned long long'
388 tabrowValueDict[
'REVISION_ID']=entryinfo[0]
389 tabrowValueDict[
'DATA_ID']=entryinfo[3]
390 db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
396 1.insert a new revision into the revisions table
397 2.insert into data_id, revision_id pair to datatable_revmap
398 insert into revisions(revision_id,branch_id,branch_name,ctime) values()
399 insert into datatable_rev(data_id,revision_id) values())
401 revisioninfo (revision_id(0),data_id(1))
402 branchinfo (branch_id(0),branch_name(1))
410 tabrowDefDict[
'REVISION_ID']=
'unsigned long long'
411 tabrowDefDict[
'BRANCH_ID']=
'unsigned long long'
412 tabrowDefDict[
'BRANCH_NAME']=
'string'
413 tabrowDefDict[
'CTIME']=
'time stamp'
416 tabrowValueDict[
'REVISION_ID']=revisioninfo[0]
417 tabrowValueDict[
'BRANCH_ID']=branchinfo[0]
418 tabrowValueDict[
'BRANCH_NAME']=branchinfo[1]
419 tabrowValueDict[
'CTIME']=coral.TimeStamp()
421 db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
424 tabrowDefDict[
'REVISION_ID']=
'unsigned long long'
425 tabrowDefDict[
'DATA_ID']=
'unsigned long long'
427 tabrowValueDict[
'REVISION_ID']=revisioninfo[0]
428 tabrowValueDict[
'DATA_ID']=revisioninfo[1]
429 db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
434 create a new branch/tag under given parentnode
435 insert into revisions(revision_id,branch_id,branch_name,name,comment,ctime) values()
436 return (revisionid,parentid,parentname)
441 if not parentname
is None:
442 qHandle=schema.newQuery()
444 qHandle.addToOutputList(
'REVISION_ID',
'revision_id' )
445 qCondition=coral.AttributeList()
446 qCondition.extend(
'parentname',
'string')
447 qCondition[
'parentname'].setData(parentname)
448 qResult=coral.AttributeList()
449 qResult.extend(
'revision_id',
'unsigned long long')
450 qHandle.defineOutput(qResult)
451 qHandle.setCondition(
'NAME=:parentname',qCondition)
452 cursor=qHandle.execute()
454 parentid=cursor.currentRow()[
'revision_id'].
data()
462 tabrowDefDict[
'REVISION_ID']=
'unsigned long long'
463 tabrowDefDict[
'BRANCH_ID']=
'unsigned long long'
464 tabrowDefDict[
'BRANCH_NAME']=
'string'
465 tabrowDefDict[
'NAME']=
'string'
466 tabrowDefDict[
'COMMENT']=
'string'
467 tabrowDefDict[
'CTIME']=
'time stamp'
469 tabrowValueDict[
'REVISION_ID']=revisionid
470 tabrowValueDict[
'BRANCH_ID']=parentid
471 tabrowValueDict[
'BRANCH_NAME']=parentname
472 tabrowValueDict[
'NAME']=name
473 tabrowValueDict[
'COMMENT']=comment
474 tabrowValueDict[
'CTIME']=coral.TimeStamp()
476 return (revisionid,parentid,parentname)
485 insert into tags(tagname,tagid,creationtime) values()
487 tagname,tagid,creationtime
489 if lumitype
not in [
'HF',
'PIXEL']:
490 raise ValueError(
'unknown lumitype '+lumitype)
497 tagid=iddealer.generateNextIDForTable( tagstablename )
500 tabrowDefDict[
'TAGNAME']=
'string'
501 tabrowDefDict[
'TAGID']=
'unsigned long long'
502 tabrowDefDict[
'CREATIONTIME']=
'time stamp'
504 tabrowValueDict[
'TAGNAME']=tagname
505 tabrowValueDict[
'TAGID']=tagid
506 creationtime=coral.TimeStamp()
507 tabrowValueDict[
'CREATIONTIME']=creationtime
508 db.insertOneRow(tagstablename,tabrowDefDict, tabrowValueDict )
509 return (tagname,tagid,creationtime)
515 select tagid,tagname from tags
516 output:(tagid,tagname)
518 if lumitype
not in [
'HF',
'PIXEL']:
519 raise ValueError(
'unknown lumitype '+lumitype)
526 qHandle=schema.newQuery()
527 qHandle.addToTableList( tagstablename )
528 qHandle.addToOutputList(
'TAGID')
529 qHandle.addToOutputList(
'TAGNAME')
530 qResult=coral.AttributeList()
531 qResult.extend(
'TAGID',
'unsigned long long')
532 qResult.extend(
'TAGNAME',
'string')
533 qHandle.defineOutput(qResult)
534 cursor=qHandle.execute()
537 tagid=cursor.currentRow()[
'TAGID'].
data()
538 tagname=cursor.currentRow()[
'TAGNAME'].
data()
539 tagmap[tagid]=tagname
542 currenttagid=
max(tagmap.keys())
544 raise 'currentDataTag: no tag available'
545 return (currenttagid,tagmap[currenttagid])
551 select tagid from tags
552 insert into tagruns(tagid,runnum,lumidataid,trgdataid,hltdataid,creationtime,comment) values(tagid,runnum,lumiid,trgid,hltid,creationtime,comment)
554 if lumitype
not in [
'HF',
'PIXEL']:
555 raise ValueError(
'unknown lumitype '+lumitype)
564 tabrowDefDict[
'TAGID']=
'unsigned long long'
565 tabrowDefDict[
'RUNNUM']=
'unsigned int'
566 tabrowDefDict[
'LUMIDATAID']=
'unsigned long long'
567 tabrowDefDict[
'TRGDATAID']=
'unsigned long long'
568 tabrowDefDict[
'HLTDATAID']=
'unsigned long long'
569 tabrowDefDict[
'CREATIONTIME']=
'time stamp'
570 tabrowDefDict[
'COMMENT']=
'string'
572 tabrowValueDict[
'TAGID']=currenttagid
573 tabrowValueDict[
'RUNNUM']=runnum
574 tabrowValueDict[
'LUMIDATAID']=lumiid
575 tabrowValueDict[
'TRGDATAID']=trgid
576 tabrowValueDict[
'HLTDATAID']=hltid
577 tabrowValueDict[
'CREATIONTIME']=coral.TimeStamp()
578 tabrowValueDict[
'COMMENT']=comment
579 db.insertOneRow( tagrunstablename,tabrowDefDict, tabrowValueDict )
585 select tagname,tagid from tags,tagruns
586 if number of tags==1->open tag
587 if tagid is max ->open tag
589 max run=max(runnum) where tagid=:tagid
591 select min(runnum) from tagruns where tagid<=:tagid
595 select min(runnum) from tagruns where tagid<=:tagid
597 {tagid:(name,minrun,maxrun,creationtime)}
599 if lumitype
not in [
'HF',
'PIXEL']:
600 raise ValueError(
'unknown lumitype '+lumitype)
609 qHandle=schema.newQuery()
610 qHandle.addToTableList( tagstablename )
611 qCondition=coral.AttributeList()
612 qHandle.addToOutputList(
'TAGNAME')
613 qHandle.addToOutputList(
'TAGID')
614 qHandle.addToOutputList(
"TO_CHAR(CREATIONTIME,\'MM/DD/YY HH24:MI:SS\')",
'creationtime')
615 qResult=coral.AttributeList()
616 qResult.extend(
'TAGNAME',
'string')
617 qResult.extend(
'TAGID',
'unsigned long long')
618 qResult.extend(
'creationtime',
'string')
619 qHandle.defineOutput(qResult)
620 cursor=qHandle.execute()
622 tagname=cursor.currentRow()[
'TAGNAME'].
data()
623 tagid=cursor.currentRow()[
'TAGID'].
data()
624 creationtime=cursor.currentRow()[
'creationtime'].
data()
625 tagmap[tagid]=[tagname,0,0,creationtime]
631 qConditionStr=
'TAGID<=:tagid'
632 qCondition=coral.AttributeList()
633 qCondition.extend(
'tagid',
'unsigned long long')
634 qCondition[
'tagid'].setData(tagid)
635 qHandle=schema.newQuery()
636 qHandle.addToTableList( tagrunstablename )
637 qResult=coral.AttributeList()
638 qResult.extend(
'RUNNUM',
'unsigned int')
639 qHandle.defineOutput(qResult)
640 qHandle.setCondition(qConditionStr,qCondition)
641 qHandle.addToOutputList(
'RUNNUM')
642 cursor=qHandle.execute()
644 rnum=cursor.currentRow()[
'RUNNUM'].
data()
651 tagmap[tagid][1]=minrun
652 if len(tagmap)>1
and tagid!=
max(tagids):
653 tagmap[tagid][2]=maxrun
660 select tagid from tags where tagname=:tagname
662 if lumitype
not in [
'HF',
'PIXEL']:
663 raise ValueError(
'unknown lumitype '+lumitype)
670 qHandle=schema.newQuery()
671 qHandle.addToTableList( tagstablename )
672 qConditionStr=
'TAGNAME=:tagname'
673 qCondition=coral.AttributeList()
674 qCondition.extend(
'tagname',
'string')
675 qCondition[
'tagname'].setData(tagname)
676 qHandle.addToOutputList(
'TAGID')
677 qResult=coral.AttributeList()
678 qResult.extend(
'TAGID',
'unsigned long long')
679 qHandle.defineOutput(qResult)
680 qHandle.setCondition(qConditionStr,qCondition)
681 cursor=qHandle.execute()
683 if not cursor.currentRow()[
'TAGID'].isNull():
684 tagid=cursor.currentRow()[
'TAGID'].
data()
691 select tagid from tags where tagname=:tagname
693 runlist: select run list, if None, all
695 {run:(lumidataid,trgdataid,hltdataid,(creationtime,comment)}
697 if lumitype
not in [
'HF',
'PIXEL']:
698 raise ValueError(
'unknown lumitype '+lumitype)
705 qHandle=schema.newQuery()
706 qHandle.addToTableList( tagstablename )
707 qConditionStr=
'TAGNAME=:tagname'
708 qCondition=coral.AttributeList()
709 qCondition.extend(
'tagname',
'string')
710 qCondition[
'tagname'].setData(tagname)
711 qHandle.addToOutputList(
'TAGID')
712 qResult=coral.AttributeList()
713 qResult.extend(
'TAGID',
'unsigned long long')
714 qHandle.defineOutput(qResult)
715 qHandle.setCondition(qConditionStr,qCondition)
716 cursor=qHandle.execute()
718 if not cursor.currentRow()[
'TAGID'].isNull():
719 tagid=cursor.currentRow()[
'TAGID'].
data()
725 return dataIdsByTagId(schema,tagid,runlist=runlist,withcomment=withcomment,lumitype=lumitype)
730 select tagid from tags where tagname=:tagname
731 select runnum,comment from tagruns where tagid<=:tagid
733 runlist: select run list, if None, all
735 {tagid:(name,minrun,maxrun,creationtime)}
737 if lumitype
not in [
'HF',
'PIXEL']:
738 raise ValueError(
'unknown lumitype '+lumitype)
747 qHandle=schema.newQuery()
748 qHandle.addToTableList( tagstablename )
749 qCondition=coral.AttributeList()
750 qHandle.addToOutputList(
'TAGNAME')
751 qHandle.addToOutputList(
'TAGID')
752 qHandle.addToOutputList(
"TO_CHAR(CREATIONTIME,\'MM/DD/YY HH24:MI:SS\')",
'creationtime')
753 qResult=coral.AttributeList()
754 qResult.extend(
'TAGNAME',
'string')
755 qResult.extend(
'TAGID',
'unsigned long long')
756 qResult.extend(
'creationtime',
'string')
757 qHandle.defineOutput(qResult)
758 cursor=qHandle.execute()
760 tagname=cursor.currentRow()[
'TAGNAME'].
data()
761 tagid=cursor.currentRow()[
'TAGID'].
data()
762 creationtime=cursor.currentRow()[
'creationtime'].
data()
763 tagmap[tagid]=[tagname,0,0,creationtime]
769 qConditionStr=
'TAGID<=:tagid'
770 qCondition=coral.AttributeList()
771 qCondition.extend(
'tagid',
'unsigned long long')
772 qCondition[
'tagid'].setData(tagid)
773 qHandle=schema.newQuery()
774 qHandle.addToTableList(tagrunstablename)
775 qResult=coral.AttributeList()
776 qResult.extend(
'RUNNUM',
'unsigned int')
777 qHandle.defineOutput(qResult)
778 qHandle.setCondition(qConditionStr,qCondition)
779 qHandle.addToOutputList(
'RUNNUM')
780 cursor=qHandle.execute()
782 rnum=cursor.currentRow()[
'RUNNUM'].
data()
783 if runlist
is not None and rnum
not in runlist:
791 tagmap[tagid][1]=minrun
792 if len(tagmap)>1
and tagid!=
max(tagids):
793 tagmap[tagid][2]=maxrun
800 select runnum,lumidataid,trgdataid,hltdataid,comment from tagruns where TAGID<=:tagid;
802 runlist: select run list, if None, all
804 {run:(lumidataid,trgdataid,hltdataid,(creationtime,comment))}
806 if lumitype
not in [
'HF',
'PIXEL']:
807 raise ValueError(
'unknown lumitype '+lumitype)
815 qHandle=schema.newQuery()
816 qHandle.addToTableList(tagrunstablename)
817 qConditionStr=
'TAGID<=:tagid'
818 qCondition=coral.AttributeList()
819 qCondition.extend(
'tagid',
'unsigned long long')
820 qCondition[
'tagid'].setData(tagid)
821 qResult=coral.AttributeList()
822 qResult.extend(
'RUNNUM',
'unsigned int')
823 qResult.extend(
'LUMIDATAID',
'unsigned long long')
824 qResult.extend(
'TRGDATAID',
'unsigned long long')
825 qResult.extend(
'HLTDATAID',
'unsigned long long')
827 qResult.extend(
'COMMENT',
'string')
828 qResult.extend(
'creationtime',
'string')
829 qHandle.defineOutput(qResult)
830 qHandle.setCondition(qConditionStr,qCondition)
831 qHandle.addToOutputList(
'RUNNUM')
832 qHandle.addToOutputList(
'LUMIDATAID')
833 qHandle.addToOutputList(
'TRGDATAID')
834 qHandle.addToOutputList(
'HLTDATAID')
836 qHandle.addToOutputList(
'COMMENT')
837 qHandle.addToOutputList(
"TO_CHAR(CREATIONTIME,\'MM/DD/YY HH24:MI:SS\')",
'creationtime')
838 cursor=qHandle.execute()
840 runnum=cursor.currentRow()[
'RUNNUM'].
data()
841 if runlist
is not None and runnum
not in runlist:
844 if not cursor.currentRow()[
'LUMIDATAID'].isNull():
845 lumidataid=cursor.currentRow()[
'LUMIDATAID'].
data()
847 if not cursor.currentRow()[
'TRGDATAID'].isNull():
848 trgdataid=cursor.currentRow()[
'TRGDATAID'].
data()
850 if not cursor.currentRow()[
'HLTDATAID'].isNull():
851 hltdataid=cursor.currentRow()[
'HLTDATAID'].
data()
852 if runnum
not in result:
853 result[runnum]=[0,0,0]
854 if lumidataid>result[runnum][0]:
855 result[runnum][0]=lumidataid
856 if trgdataid>result[runnum][1]:
857 result[runnum][1]=trgdataid
858 if hltdataid>result[runnum][2]:
859 result[runnum][2]=hltdataid
863 if not cursor.currentRow()[
'creationtime'].isNull():
864 creationtime=cursor.currentRow()[
'creationtime'].
data()
865 if not cursor.currentRow()[
'COMMENT'].isNull():
866 comment=cursor.currentRow()[
'COMMENT'].
data()
867 commentdict[(lumidataid,trgdataid,hltdataid)]=(creationtime,comment)
870 for run,resultentry
in result.items():
871 lumiid=resultentry[0]
874 if (lumiid,trgid,hltid)
in commentdict:
875 resultentry.append(commentdict[(lumiid,trgid,hltid)])
876 elif (lumiid,0,0)
in commentdict:
877 resultentry.append(commentdict[(lumiid,0,0)])
878 elif commentdict.has_ley((0,trgid,0)):
879 resultentry.append(commentdict[(0,trgid,0)])
880 elif commentdict.has_ley((0,0,hltid)):
881 resultentry.append(commentdict[(0,0,hltid)])
883 resultentry.append(())
891 dataIdsByTagId(schema,currenttagid,runlist)
893 (currenttagname,{run:(lumidataid,trgdataid,hltdataid)})
896 result=
dataIdsByTagId(schema,currenttagid,runlist=runlist,withcomment=
False,lumitype=lumitype)
897 return (currenttagname,result)
899 if __name__ ==
"__main__":
900 import sessionManager
904 myconstr=
'sqlite_file:test.db'
906 session=svc.openSession(isReadOnly=
False,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
907 schema=session.nominalSchema()
908 session.transaction().
start(
False)
914 norminfo=
createBranch(schema,
'NORM',
'TRUNK',comment=
'hold normalization factor')
917 databranchinfo=(branchid,
'DATA')
919 for runnum
in [1200,1211,1222,1233,1345,1222,1200]:
923 if lumientryid
is None:
925 entryinfo=(revision_id,entry_id,str(runnum),data_id)
932 if trgentryid
is None:
934 entryinfo=(revision_id,entry_id,str(runnum),data_id)
941 if hltentryid
is None:
943 entryinfo=(revision_id,entry_id,str(runnum),data_id)
951 session.transaction().commit()
953 session.transaction().
start(
True)
956 print 'DATA revlist ',revlist
960 print 'latest data_id for run 1211 ',latestrevision
961 session.transaction().commit()
def revisionsInBranchName
def pixeltagRunsTableName
def addRunToCurrentDataTag
char data[epos_bytes_allocation]
def createDataTag
Data Tagging API.
def latestDataRevisionOfEntry