1 from __future__
import print_function
2 from __future__
import absolute_import
10 from RecoLuminosity.LumiDB
import nameDealer,idDealer,dbUtil
16 returns all revisions before tag in selected branch 17 select revision_id from revisions where revision_id!=0 and revision_id<tagrevisionid and branch_id=:branchid 21 qHandle=schema.newQuery()
25 qHandle.addToOutputList(
'distinct BRANCH_ID',
'branch_id')
26 qCondition=coral.AttributeList()
27 qCondition.extend(
'branchid',
'unsigned long long')
28 qCondition[
'branchid'].setData(branchid)
29 qResult=coral.AttributeList()
30 qResult.extend(
'branch_id',
'unsigned long long')
31 qHandle.defineOutput(qResult)
32 qHandle.setCondition(
'BRANCH_ID>:branchid',qCondition)
33 cursor=qHandle.execute()
35 nextbranches.append(cursor.currentRow()[
'branch_id'].
data())
38 conditionStr=
'REVISION_ID!=0 and BRANCH_ID=:branchid and REVISION_ID<:tagrevisionid' 39 qHandle=schema.newQuery()
41 qHandle.addToOutputList(
'REVISION_ID',
'revision_id')
42 qCondition=coral.AttributeList()
43 qCondition.extend(
'branchid',
'unsigned long long')
44 qCondition.extend(
'tagrevisionid',
'unsigned long long')
45 qCondition[
'branchid'].setData(branchid)
46 qCondition[
'tagrevisionid'].setData(tagrevisionid)
47 qResult=coral.AttributeList()
48 qResult.extend(
'revision_id',
'unsigned long long')
49 qHandle.defineOutput(qResult)
50 qHandle.setCondition(conditionStr,qCondition)
51 cursor=qHandle.execute()
53 candidates.append(cursor.currentRow()[
'revision_id'].
data())
61 if qHandle:del qHandle
65 returns all revision values in a branch 67 select distinct branch_id from revisions where branch_id>:branchid; 68 select revision_id from revisions where branch_id=:branchid ; 69 if the branchid matches and the revisionid is not in the branchid collection,not 0, then this revision is in the branch 70 require also revisionid>branchid 73 qHandle=schema.newQuery()
77 qHandle.addToOutputList(
'distinct BRANCH_ID',
'branch_id')
78 qCondition=coral.AttributeList()
79 qCondition.extend(
'branchid',
'unsigned long long')
80 qCondition[
'branchid'].setData(branchid)
81 qResult=coral.AttributeList()
82 qResult.extend(
'branch_id',
'unsigned long long')
83 qHandle.defineOutput(qResult)
84 qHandle.setCondition(
'BRANCH_ID>:branchid',qCondition)
85 cursor=qHandle.execute()
87 nextbranches.append(cursor.currentRow()[
'branch_id'].
data())
90 conditionStr=
'BRANCH_ID=:branchid and REVISION_ID!=0' 91 qHandle=schema.newQuery()
93 qHandle.addToOutputList(
'REVISION_ID',
'revision_id')
94 qCondition=coral.AttributeList()
95 qCondition.extend(
'branchid',
'unsigned long long')
96 qCondition[
'branchid'].setData(branchid)
97 qResult=coral.AttributeList()
98 qResult.extend(
'revision_id',
'unsigned long long')
99 qHandle.defineOutput(qResult)
100 qHandle.setCondition(conditionStr,qCondition)
101 cursor=qHandle.execute()
103 candidates.append(cursor.currentRow()[
'revision_id'].
data())
106 if c
in nextbranches:
111 if qHandle: del qHandle
117 the difference between tag and branch: tag is an empty branch 118 select count(revision_id) from revisions where branch_name=:name 119 if >0: is real branch 124 qHandle=schema.newQuery()
126 qHandle.addToOutputList(
'count(REVISION_ID)',
'nchildren')
127 qCondition=coral.AttributeList()
128 qCondition.extend(
'branch_name',
'string')
129 qCondition[
'branch_name'].setData(name)
130 qResult=coral.AttributeList()
131 qResult.extend(
'nchildren',
'unsigned int')
132 qHandle.defineOutput(qResult)
133 conditionStr=
'BRANCH_NAME=:branch_name' 134 qHandle.setCondition(conditionStr,qCondition)
135 cursor=qHandle.execute()
137 if cursor.currentRow()[
'nchildren'].
data()>0:
181 returns all revisions in a branch/tag by name 192 whether an entry(by name) already exists in the given branch 193 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 195 if isinstance(branch,str):byname 202 if isinstance(branch,str):
204 qHandle=schema.newQuery()
207 qHandle.addToOutputList('e.ENTRY_ID',
'entry_id')
208 qCondition=coral.AttributeList()
209 qCondition.extend(
'entryname',
'string')
210 qCondition[
'entryname'].setData(entryname)
211 qConditionStr=
'r.REVISION_ID=e.REVISION_ID and e.NAME=:entryname and ' 213 qCondition.extend(
'branch_name',
'string')
214 qCondition[
'branch_name'].setData(branch)
215 qConditionStr+=
'r.BRANCH_NAME=:branch_name' 217 qCondition.extend(
'branch_id',
'unsigned long long')
218 qCondition[
'branch_id'].setData(branch)
219 qConditionStr+=
'r.BRANCH_ID=:branch_id' 220 qResult=coral.AttributeList()
221 qResult.extend(
'entry_id',
'unsigned long long')
222 qHandle.defineOutput(qResult)
223 qHandle.setCondition(qConditionStr,qCondition)
224 cursor=qHandle.execute()
226 entry_id=cursor.currentRow()[
'entry_id'].
data()
235 all data version of the given entry whose revision falls in branch revision range 236 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 237 input: if isinstance(entry,str): d.entry_name=:entry ; else d.entry_id=:entry 240 qHandle=schema.newQuery()
244 if isinstance(entry,str):
246 qHandle.addToTableList( datatableName,
'd' )
248 qHandle.addToOutputList('d.DATA_ID',
'data_id')
249 qHandle.addToOutputList(
'r.REVISION_ID',
'revision_id')
250 qCondition=coral.AttributeList()
251 qConditionStr=
'd.DATA_ID=r.DATA_ID and ' 253 qCondition.extend(
'entry_name',
'string')
254 qCondition[
'entry_name'].setData(entry)
255 qConditionStr+=
'd.ENTRY_NAME=:entry_name' 257 qCondition.extend(
'entry_id',
'unsigned long long')
258 qCondition[
'entry_id'].setData(entry)
259 qConditionStr+=
'd.ENTRY_ID=:entry_id' 260 qResult=coral.AttributeList()
261 qResult.extend(
'data_id',
'unsigned long long')
262 qResult.extend(
'revision_id',
'unsigned long long')
263 qHandle.defineOutput(qResult)
264 qHandle.setCondition(qConditionStr,qCondition)
265 cursor=qHandle.execute()
267 data_id=cursor.currentRow()[
'data_id'].
data()
268 revision_id=cursor.currentRow()[
'revision_id'].
data()
269 if revision_id
in revrange:
270 result.append(data_id)
278 return max(data_id) of all datarevisionofEntry 281 if result
and len(result)!=0:
return max(result)
286 select (revision_id,branch_id) from revisions where name=:branchName 289 qHandle=schema.newQuery()
291 qHandle.addToOutputList(
'REVISION_ID',
'revision_id')
292 qHandle.addToOutputList(
'BRANCH_ID',
'branch_id')
293 qCondition=coral.AttributeList()
294 qCondition.extend(
'name',
'string')
295 qCondition[
'name'].setData(branchName)
296 qResult=coral.AttributeList()
297 qResult.extend(
'revision_id',
'unsigned long long')
298 qResult.extend(
'branch_id',
'unsigned long long')
299 qHandle.defineOutput(qResult)
300 qHandle.setCondition(
'NAME=:name',qCondition)
301 cursor=qHandle.execute()
305 revision_id=cursor.currentRow()[
'revision_id'].
data()
306 branch_id=cursor.currentRow()[
'branch_id'].
data()
308 return (revision_id,branch_id)
309 except Exception
as e :
310 raise RuntimeError(
' revisionDML.branchInfoByName: '+
str(e))
320 allocate new revision_id,entry_id,data_id 326 data_id=iddealer.generateNextIDForTable( datatableName)
328 return (revision_id,entry_id,data_id)
334 allocate new revision_id,data_id 339 data_id=iddealer.generateNextIDForTable(datatableName)
340 return (revision_id,data_id)
344 def addEntry(schema,datatableName,entryinfo,branchinfo):
347 entryinfo (revision_id(0),entry_id(1),entry_name(2),data_id(3)) 348 branchinfo (branch_id,branch_name) 349 1.allocate and insert a new revision into the revisions table 350 2.allocate and insert a new entry into the entry table with the new revision 351 3.inset into data_rev table with new data_id ,revision)id mapping 353 insert into revisions(revision_id,branch_id,branch_name,comment,ctime) values() 354 insert into datatablename_entries (entry_id,revision_id) values() 355 insert into datatablename_rev(data_id,revision_id) values() 364 tabrowDefDict[
'REVISION_ID']=
'unsigned long long' 365 tabrowDefDict[
'BRANCH_ID']=
'unsigned long long' 366 tabrowDefDict[
'BRANCH_NAME']=
'string' 367 tabrowDefDict[
'CTIME']=
'time stamp' 369 tabrowValueDict[
'REVISION_ID']=entryinfo[0]
370 tabrowValueDict[
'BRANCH_ID']=branchinfo[0]
371 tabrowValueDict[
'BRANCH_NAME']=branchinfo[1]
372 tabrowValueDict[
'CTIME']=coral.TimeStamp()
373 db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
376 tabrowDefDict[
'REVISION_ID']=
'unsigned long long' 377 tabrowDefDict[
'ENTRY_ID']=
'unsigned long long' 378 tabrowDefDict[
'NAME']=
'string' 381 tabrowValueDict[
'REVISION_ID']=entryinfo[0]
382 tabrowValueDict[
'ENTRY_ID']=entryinfo[1]
383 tabrowValueDict[
'NAME']=entryinfo[2]
384 db.insertOneRow(entrytableName,tabrowDefDict,tabrowValueDict)
387 tabrowDefDict[
'REVISION_ID']=
'unsigned long long' 388 tabrowDefDict[
'DATA_ID']=
'unsigned long long' 390 tabrowValueDict[
'REVISION_ID']=entryinfo[0]
391 tabrowValueDict[
'DATA_ID']=entryinfo[3]
392 db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
398 1.insert a new revision into the revisions table 399 2.insert into data_id, revision_id pair to datatable_revmap 400 insert into revisions(revision_id,branch_id,branch_name,ctime) values() 401 insert into datatable_rev(data_id,revision_id) values()) 403 revisioninfo (revision_id(0),data_id(1)) 404 branchinfo (branch_id(0),branch_name(1)) 412 tabrowDefDict[
'REVISION_ID']=
'unsigned long long' 413 tabrowDefDict[
'BRANCH_ID']=
'unsigned long long' 414 tabrowDefDict[
'BRANCH_NAME']=
'string' 415 tabrowDefDict[
'CTIME']=
'time stamp' 418 tabrowValueDict[
'REVISION_ID']=revisioninfo[0]
419 tabrowValueDict[
'BRANCH_ID']=branchinfo[0]
420 tabrowValueDict[
'BRANCH_NAME']=branchinfo[1]
421 tabrowValueDict[
'CTIME']=coral.TimeStamp()
423 db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
426 tabrowDefDict[
'REVISION_ID']=
'unsigned long long' 427 tabrowDefDict[
'DATA_ID']=
'unsigned long long' 429 tabrowValueDict[
'REVISION_ID']=revisioninfo[0]
430 tabrowValueDict[
'DATA_ID']=revisioninfo[1]
431 db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
436 create a new branch/tag under given parentnode 437 insert into revisions(revision_id,branch_id,branch_name,name,comment,ctime) values() 438 return (revisionid,parentid,parentname) 443 if not parentname
is None:
444 qHandle=schema.newQuery()
446 qHandle.addToOutputList(
'REVISION_ID',
'revision_id' )
447 qCondition=coral.AttributeList()
448 qCondition.extend(
'parentname',
'string')
449 qCondition[
'parentname'].setData(parentname)
450 qResult=coral.AttributeList()
451 qResult.extend(
'revision_id',
'unsigned long long')
452 qHandle.defineOutput(qResult)
453 qHandle.setCondition(
'NAME=:parentname',qCondition)
454 cursor=qHandle.execute()
456 parentid=cursor.currentRow()[
'revision_id'].
data()
464 tabrowDefDict[
'REVISION_ID']=
'unsigned long long' 465 tabrowDefDict[
'BRANCH_ID']=
'unsigned long long' 466 tabrowDefDict[
'BRANCH_NAME']=
'string' 467 tabrowDefDict[
'NAME']=
'string' 468 tabrowDefDict[
'COMMENT']=
'string' 469 tabrowDefDict[
'CTIME']=
'time stamp' 471 tabrowValueDict[
'REVISION_ID']=revisionid
472 tabrowValueDict[
'BRANCH_ID']=parentid
473 tabrowValueDict[
'BRANCH_NAME']=parentname
474 tabrowValueDict[
'NAME']=name
475 tabrowValueDict[
'COMMENT']=comment
476 tabrowValueDict[
'CTIME']=coral.TimeStamp()
478 return (revisionid,parentid,parentname)
487 insert into tags(tagname,tagid,creationtime) values() 489 tagname,tagid,creationtime 491 if lumitype
not in [
'HF',
'PIXEL']:
492 raise ValueError(
'unknown lumitype '+lumitype)
499 tagid=iddealer.generateNextIDForTable( tagstablename )
502 tabrowDefDict[
'TAGNAME']=
'string' 503 tabrowDefDict[
'TAGID']=
'unsigned long long' 504 tabrowDefDict[
'CREATIONTIME']=
'time stamp' 506 tabrowValueDict[
'TAGNAME']=tagname
507 tabrowValueDict[
'TAGID']=tagid
508 creationtime=coral.TimeStamp()
509 tabrowValueDict[
'CREATIONTIME']=creationtime
510 db.insertOneRow(tagstablename,tabrowDefDict, tabrowValueDict )
511 return (tagname,tagid,creationtime)
517 select tagid,tagname from tags 518 output:(tagid,tagname) 520 if lumitype
not in [
'HF',
'PIXEL']:
521 raise ValueError(
'unknown lumitype '+lumitype)
528 qHandle=schema.newQuery()
529 qHandle.addToTableList( tagstablename )
530 qHandle.addToOutputList(
'TAGID')
531 qHandle.addToOutputList(
'TAGNAME')
532 qResult=coral.AttributeList()
533 qResult.extend(
'TAGID',
'unsigned long long')
534 qResult.extend(
'TAGNAME',
'string')
535 qHandle.defineOutput(qResult)
536 cursor=qHandle.execute()
539 tagid=cursor.currentRow()[
'TAGID'].
data()
540 tagname=cursor.currentRow()[
'TAGNAME'].
data()
541 tagmap[tagid]=tagname
544 currenttagid=
max(tagmap.keys())
546 raise 'currentDataTag: no tag available' 547 return (currenttagid,tagmap[currenttagid])
553 select tagid from tags 554 insert into tagruns(tagid,runnum,lumidataid,trgdataid,hltdataid,creationtime,comment) values(tagid,runnum,lumiid,trgid,hltid,creationtime,comment) 556 if lumitype
not in [
'HF',
'PIXEL']:
557 raise ValueError(
'unknown lumitype '+lumitype)
566 tabrowDefDict[
'TAGID']=
'unsigned long long' 567 tabrowDefDict[
'RUNNUM']=
'unsigned int' 568 tabrowDefDict[
'LUMIDATAID']=
'unsigned long long' 569 tabrowDefDict[
'TRGDATAID']=
'unsigned long long' 570 tabrowDefDict[
'HLTDATAID']=
'unsigned long long' 571 tabrowDefDict[
'CREATIONTIME']=
'time stamp' 572 tabrowDefDict[
'COMMENT']=
'string' 574 tabrowValueDict[
'TAGID']=currenttagid
575 tabrowValueDict[
'RUNNUM']=runnum
576 tabrowValueDict[
'LUMIDATAID']=lumiid
577 tabrowValueDict[
'TRGDATAID']=trgid
578 tabrowValueDict[
'HLTDATAID']=hltid
579 tabrowValueDict[
'CREATIONTIME']=coral.TimeStamp()
580 tabrowValueDict[
'COMMENT']=comment
581 db.insertOneRow( tagrunstablename,tabrowDefDict, tabrowValueDict )
587 select tagname,tagid from tags,tagruns 588 if number of tags==1->open tag 589 if tagid is max ->open tag 591 max run=max(runnum) where tagid=:tagid 593 select min(runnum) from tagruns where tagid<=:tagid 597 select min(runnum) from tagruns where tagid<=:tagid 599 {tagid:(name,minrun,maxrun,creationtime)} 601 if lumitype
not in [
'HF',
'PIXEL']:
602 raise ValueError(
'unknown lumitype '+lumitype)
611 qHandle=schema.newQuery()
612 qHandle.addToTableList( tagstablename )
613 qCondition=coral.AttributeList()
614 qHandle.addToOutputList(
'TAGNAME')
615 qHandle.addToOutputList(
'TAGID')
616 qHandle.addToOutputList(
"TO_CHAR(CREATIONTIME,\'MM/DD/YY HH24:MI:SS\')",
'creationtime')
617 qResult=coral.AttributeList()
618 qResult.extend(
'TAGNAME',
'string')
619 qResult.extend(
'TAGID',
'unsigned long long')
620 qResult.extend(
'creationtime',
'string')
621 qHandle.defineOutput(qResult)
622 cursor=qHandle.execute()
624 tagname=cursor.currentRow()[
'TAGNAME'].
data()
625 tagid=cursor.currentRow()[
'TAGID'].
data()
626 creationtime=cursor.currentRow()[
'creationtime'].
data()
627 tagmap[tagid]=[tagname,0,0,creationtime]
633 qConditionStr=
'TAGID<=:tagid' 634 qCondition=coral.AttributeList()
635 qCondition.extend(
'tagid',
'unsigned long long')
636 qCondition[
'tagid'].setData(tagid)
637 qHandle=schema.newQuery()
638 qHandle.addToTableList( tagrunstablename )
639 qResult=coral.AttributeList()
640 qResult.extend(
'RUNNUM',
'unsigned int')
641 qHandle.defineOutput(qResult)
642 qHandle.setCondition(qConditionStr,qCondition)
643 qHandle.addToOutputList(
'RUNNUM')
644 cursor=qHandle.execute()
646 rnum=cursor.currentRow()[
'RUNNUM'].
data()
653 tagmap[tagid][1]=minrun
654 if len(tagmap)>1
and tagid!=
max(tagids):
655 tagmap[tagid][2]=maxrun
662 select tagid from tags where tagname=:tagname 664 if lumitype
not in [
'HF',
'PIXEL']:
665 raise ValueError(
'unknown lumitype '+lumitype)
672 qHandle=schema.newQuery()
673 qHandle.addToTableList( tagstablename )
674 qConditionStr=
'TAGNAME=:tagname' 675 qCondition=coral.AttributeList()
676 qCondition.extend(
'tagname',
'string')
677 qCondition[
'tagname'].setData(tagname)
678 qHandle.addToOutputList(
'TAGID')
679 qResult=coral.AttributeList()
680 qResult.extend(
'TAGID',
'unsigned long long')
681 qHandle.defineOutput(qResult)
682 qHandle.setCondition(qConditionStr,qCondition)
683 cursor=qHandle.execute()
685 if not cursor.currentRow()[
'TAGID'].isNull():
686 tagid=cursor.currentRow()[
'TAGID'].
data()
693 select tagid from tags where tagname=:tagname 695 runlist: select run list, if None, all 697 {run:(lumidataid,trgdataid,hltdataid,(creationtime,comment)} 699 if lumitype
not in [
'HF',
'PIXEL']:
700 raise ValueError(
'unknown lumitype '+lumitype)
707 qHandle=schema.newQuery()
708 qHandle.addToTableList( tagstablename )
709 qConditionStr=
'TAGNAME=:tagname' 710 qCondition=coral.AttributeList()
711 qCondition.extend(
'tagname',
'string')
712 qCondition[
'tagname'].setData(tagname)
713 qHandle.addToOutputList(
'TAGID')
714 qResult=coral.AttributeList()
715 qResult.extend(
'TAGID',
'unsigned long long')
716 qHandle.defineOutput(qResult)
717 qHandle.setCondition(qConditionStr,qCondition)
718 cursor=qHandle.execute()
720 if not cursor.currentRow()[
'TAGID'].isNull():
721 tagid=cursor.currentRow()[
'TAGID'].
data()
727 return dataIdsByTagId(schema,tagid,runlist=runlist,withcomment=withcomment,lumitype=lumitype)
732 select tagid from tags where tagname=:tagname 733 select runnum,comment from tagruns where tagid<=:tagid 735 runlist: select run list, if None, all 737 {tagid:(name,minrun,maxrun,creationtime)} 739 if lumitype
not in [
'HF',
'PIXEL']:
740 raise ValueError(
'unknown lumitype '+lumitype)
749 qHandle=schema.newQuery()
750 qHandle.addToTableList( tagstablename )
751 qCondition=coral.AttributeList()
752 qHandle.addToOutputList(
'TAGNAME')
753 qHandle.addToOutputList(
'TAGID')
754 qHandle.addToOutputList(
"TO_CHAR(CREATIONTIME,\'MM/DD/YY HH24:MI:SS\')",
'creationtime')
755 qResult=coral.AttributeList()
756 qResult.extend(
'TAGNAME',
'string')
757 qResult.extend(
'TAGID',
'unsigned long long')
758 qResult.extend(
'creationtime',
'string')
759 qHandle.defineOutput(qResult)
760 cursor=qHandle.execute()
762 tagname=cursor.currentRow()[
'TAGNAME'].
data()
763 tagid=cursor.currentRow()[
'TAGID'].
data()
764 creationtime=cursor.currentRow()[
'creationtime'].
data()
765 tagmap[tagid]=[tagname,0,0,creationtime]
771 qConditionStr=
'TAGID<=:tagid' 772 qCondition=coral.AttributeList()
773 qCondition.extend(
'tagid',
'unsigned long long')
774 qCondition[
'tagid'].setData(tagid)
775 qHandle=schema.newQuery()
776 qHandle.addToTableList(tagrunstablename)
777 qResult=coral.AttributeList()
778 qResult.extend(
'RUNNUM',
'unsigned int')
779 qHandle.defineOutput(qResult)
780 qHandle.setCondition(qConditionStr,qCondition)
781 qHandle.addToOutputList(
'RUNNUM')
782 cursor=qHandle.execute()
784 rnum=cursor.currentRow()[
'RUNNUM'].
data()
785 if runlist
is not None and rnum
not in runlist:
793 tagmap[tagid][1]=minrun
794 if len(tagmap)>1
and tagid!=
max(tagids):
795 tagmap[tagid][2]=maxrun
802 select runnum,lumidataid,trgdataid,hltdataid,comment from tagruns where TAGID<=:tagid; 804 runlist: select run list, if None, all 806 {run:(lumidataid,trgdataid,hltdataid,(creationtime,comment))} 808 if lumitype
not in [
'HF',
'PIXEL']:
809 raise ValueError(
'unknown lumitype '+lumitype)
817 qHandle=schema.newQuery()
818 qHandle.addToTableList(tagrunstablename)
819 qConditionStr=
'TAGID<=:tagid' 820 qCondition=coral.AttributeList()
821 qCondition.extend(
'tagid',
'unsigned long long')
822 qCondition[
'tagid'].setData(tagid)
823 qResult=coral.AttributeList()
824 qResult.extend(
'RUNNUM',
'unsigned int')
825 qResult.extend(
'LUMIDATAID',
'unsigned long long')
826 qResult.extend(
'TRGDATAID',
'unsigned long long')
827 qResult.extend(
'HLTDATAID',
'unsigned long long')
829 qResult.extend(
'COMMENT',
'string')
830 qResult.extend(
'creationtime',
'string')
831 qHandle.defineOutput(qResult)
832 qHandle.setCondition(qConditionStr,qCondition)
833 qHandle.addToOutputList(
'RUNNUM')
834 qHandle.addToOutputList(
'LUMIDATAID')
835 qHandle.addToOutputList(
'TRGDATAID')
836 qHandle.addToOutputList(
'HLTDATAID')
838 qHandle.addToOutputList(
'COMMENT')
839 qHandle.addToOutputList(
"TO_CHAR(CREATIONTIME,\'MM/DD/YY HH24:MI:SS\')",
'creationtime')
840 cursor=qHandle.execute()
842 runnum=cursor.currentRow()[
'RUNNUM'].
data()
843 if runlist
is not None and runnum
not in runlist:
846 if not cursor.currentRow()[
'LUMIDATAID'].isNull():
847 lumidataid=cursor.currentRow()[
'LUMIDATAID'].
data()
849 if not cursor.currentRow()[
'TRGDATAID'].isNull():
850 trgdataid=cursor.currentRow()[
'TRGDATAID'].
data()
852 if not cursor.currentRow()[
'HLTDATAID'].isNull():
853 hltdataid=cursor.currentRow()[
'HLTDATAID'].
data()
854 if runnum
not in result:
855 result[runnum]=[0,0,0]
856 if lumidataid>result[runnum][0]:
857 result[runnum][0]=lumidataid
858 if trgdataid>result[runnum][1]:
859 result[runnum][1]=trgdataid
860 if hltdataid>result[runnum][2]:
861 result[runnum][2]=hltdataid
865 if not cursor.currentRow()[
'creationtime'].isNull():
866 creationtime=cursor.currentRow()[
'creationtime'].
data()
867 if not cursor.currentRow()[
'COMMENT'].isNull():
868 comment=cursor.currentRow()[
'COMMENT'].
data()
869 commentdict[(lumidataid,trgdataid,hltdataid)]=(creationtime,comment)
872 for run,resultentry
in result.items():
873 lumiid=resultentry[0]
876 if (lumiid,trgid,hltid)
in commentdict:
877 resultentry.append(commentdict[(lumiid,trgid,hltid)])
878 elif (lumiid,0,0)
in commentdict:
879 resultentry.append(commentdict[(lumiid,0,0)])
880 elif commentdict.has_ley((0,trgid,0)):
881 resultentry.append(commentdict[(0,trgid,0)])
882 elif commentdict.has_ley((0,0,hltid)):
883 resultentry.append(commentdict[(0,0,hltid)])
885 resultentry.append(())
893 dataIdsByTagId(schema,currenttagid,runlist) 895 (currenttagname,{run:(lumidataid,trgdataid,hltdataid)}) 898 result=
dataIdsByTagId(schema,currenttagid,runlist=runlist,withcomment=
False,lumitype=lumitype)
899 return (currenttagname,result)
901 if __name__ ==
"__main__":
902 from .
import sessionManager
903 from .
import lumidbDDL
906 myconstr=
'sqlite_file:test.db' 908 session=svc.openSession(isReadOnly=
False,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
909 schema=session.nominalSchema()
910 session.transaction().
start(
False)
916 norminfo=
createBranch(schema,
'NORM',
'TRUNK',comment=
'hold normalization factor')
919 databranchinfo=(branchid,
'DATA')
920 print(databranchinfo)
921 for runnum
in [1200,1211,1222,1233,1345,1222,1200]:
925 if lumientryid
is None:
927 entryinfo=(revision_id,entry_id,
str(runnum),data_id)
934 if trgentryid
is None:
936 entryinfo=(revision_id,entry_id,
str(runnum),data_id)
943 if hltentryid
is None:
945 entryinfo=(revision_id,entry_id,
str(runnum),data_id)
953 session.transaction().commit()
954 print(
'test reading')
955 session.transaction().
start(
True)
958 print(
'DATA revlist ',revlist)
962 print(
'latest data_id for run 1211 ',latestrevision)
963 session.transaction().commit()
def revisionsInBranchName(schema, branchname)
def addRunToCurrentDataTag(schema, runnum, lumiid, trgid, hltid, lumitype='HF', comment='')
def dataIdsByCurrentTag(schema, runlist=None, lumitype='HF')
def dataIdsByTagName(schema, tagname, runlist=None, withcomment=False, lumitype='HF')
def dataRevisionsOfEntry(schema, datatableName, entry, revrange)
def revisionsInBranch(schema, branchid)
def revisionsInTag(schema, tagrevisionid, branchid)
def currentDataTag(schema, lumitype='HF')
def createDataTag(schema, tagname, lumitype='HF')
Data Tagging API.
def pixeltagRunsTableName()
S & print(S &os, JobReport::InputFile const &f)
def addEntry(schema, datatableName, entryinfo, branchinfo)
def entryTableName(dataTableName)
def entryInBranch(schema, datatableName, entryname, branch)
def bookNewRevision(schema, datatableName)
def alldataTags(schema, lumitype='HF')
def revmapTableName(dataTableName)
def bookNewEntry(schema, datatableName)
def addRevision(schema, datatableName, revisioninfo, branchinfo)
def branchInfoByName(schema, branchName)
char data[epos_bytes_allocation]
def dataTagInfo(schema, tagname, runlist=None, lumitype='HF')
def dataIdsByTagId(schema, tagid, runlist=None, withcomment=False, lumitype='HF')
def createBranch(schema, name, parentname, comment='')
def branchType(schema, name)
def getDataTagId(schema, tagname, lumitype='HF')
def latestDataRevisionOfEntry(schema, datatableName, entry, revrange)