Ejemplo n.º 1
0
 def test_init_shell(self):
     connection_data = {
         "db_alias": "orapro",
         "host": "oracle",
         "schema": "cms_conditions",
         "secrets": secrets_file
     }
     connection = shell.connect(connection_data)
     self.assertTrue(connection != None)
Ejemplo n.º 2
0
def create_single_iov_db(global_tag, run_number, output_db):
    """Create an sqlite file with single-IOV tags for alignment payloads.

    Arguments:
    - `global_tag`: global tag from which to extract the payloads
    - `run_number`: run for which the IOVs are selected
    - `output_db`: name of the output sqlite file
    """

    con = shell.connect()
    tags = con.global_tag_map(global_tag_name=global_tag,
                              record=[
                                  "TrackerAlignmentRcd",
                                  "TrackerSurfaceDeformationRcd",
                                  "TrackerAlignmentErrorExtendedRcd"
                              ])
    con.close_session()

    tags = {
        item["record"]: {
            "name": item["tag_name"]
        }
        for item in tags.as_dicts()
    }

    for record, tag in tags.iteritems():
        iovs = con.tag(name=tag["name"]).iovs().as_dicts()
        run_is_covered = False
        for iov in reversed(iovs):
            if iov["since"] <= run_number:
                tag["since"] = str(iov["since"])
                run_is_covered = True
                break
        if not run_is_covered:
            msg = ("Run number {0:d} is not covered in '{1:s}' ({2:s}) from"
                   " '{3:s}'.".format(run_number, tag["name"], record,
                                      global_tag))
            print msg
            print "Aborting..."
            sys.exit(1)

    result = {}
    if os.path.exists(output_db): os.remove(output_db)
    for record, tag in tags.iteritems():
        result[record] = {
            "connect": "sqlite_file:" + output_db,
            "tag": "_".join([tag["name"], tag["since"]])
        }
        cmd = ("conddb_import", "-f", "frontier://PromptProd/cms_conditions",
               "-c", result[record]["connect"], "-i", tag["name"], "-t",
               result[record]["tag"], "-b", str(run_number), "-e",
               str(run_number))
        run_checked(cmd)
    run_checked(["sqlite3", output_db, "update iov set since=1"])

    return result
Ejemplo n.º 3
0
def create_single_iov_db(global_tag, run_number, output_db):
    """Create an sqlite file with single-IOV tags for alignment payloads.

    Arguments:
    - `global_tag`: global tag from which to extract the payloads
    - `run_number`: run for which the IOVs are selected
    - `output_db`: name of the output sqlite file
    """

    con = shell.connect()
    tags = con.global_tag_map(global_tag_name = global_tag,
                              record = ["TrackerAlignmentRcd",
                                        "TrackerSurfaceDeformationRcd",
                                        "TrackerAlignmentErrorExtendedRcd"])
    con.close_session()

    tags = {item["record"]: {"name": item["tag_name"]}
            for item in tags.as_dicts()}

    for record,tag in tags.iteritems():
        iovs = con.tag(name = tag["name"]).iovs().as_dicts()
        run_is_covered = False
        for iov in reversed(iovs):
            if iov["since"] <= run_number:
                tag["since"] = str(iov["since"])
                run_is_covered = True
                break
        if not run_is_covered:
            msg = ("Run number {0:d} is not covered in '{1:s}' ({2:s}) from"
                   " '{3:s}'.".format(run_number, tag["name"], record,
                                      global_tag))
            print msg
            print "Aborting..."
            sys.exit(1)

    result = {}
    if os.path.exists(output_db): os.remove(output_db)
    for record,tag in tags.iteritems():
        result[record] = {"connect": "sqlite_file:"+output_db,
                          "tag": "_".join([tag["name"], tag["since"]])}
        cmd = ("conddb_import",
               "-f", "frontier://PromptProd/cms_conditions",
               "-c", result[record]["connect"],
               "-i", tag["name"],
               "-t", result[record]["tag"],
               "-b", str(run_number),
               "-e", str(run_number))
        run_checked(cmd)
    run_checked(["sqlite3", output_db, "update iov set since=1"])

    return result
Ejemplo n.º 4
0
def main():            
### MAIN LOOP ###

    if "CMSSW_RELEASE_BASE" in os.environ:
        print "\n"
        print "=================================================="
        print "This script is powered by cmsQueryingMiniFramework"
        print "served to you by",os.getenv('CMSSW_RELEASE_BASE')
        print "==================================================\n"
    else: 
        print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        print "+ This tool needs cmsQueryingMiniFramework (https://gitlab.cern.ch/jdawes/cmsQueryingMiniFramework)"
        print "+ Easiest way to get it is via CMSSW (>800) is"
        print "+ cmsrel CMSSW_8_0_X  #get your favorite"
        print "+ cd CMSSW_8_0_X/src"
        print "+ cmsenv"
        print "+ cd -"
        print "and then you can proceed"
        print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        sys.exit(1)

    desc="""This is a description of %prog."""
    parser = OptionParser(description=desc,version='%prog version 0.1')
    parser.add_option('-r','--run'        ,help='test run number', dest='testRunNumber', action='store', default='251883')
    parser.add_option('-R','--ReferenceGT',help='Reference Global Tag', dest='refGT', action='store', default='GR_H_V58C')
    parser.add_option('-T','--TargetGT'   ,help='Target Global Tag'   , dest='tarGT', action='store', default='74X_dataRun2_HLTValidation_Queue')
    parser.add_option('-L','--last'       ,help='compares the very last IOV' , dest='lastIOV',action='store_true', default=False)
    parser.add_option('-v','--verbose'    ,help='returns more info', dest='isVerbose',action='store_true',default=False)
    (opts, args) = parser.parse_args()

    import CondCore.Utilities.CondDBFW.shell as shell
    con = shell.connect()

    myGTrefInfo = con.global_tag(name=opts.refGT)
    myGTtarInfo = con.global_tag(name=opts.tarGT)

    text_file = open(("diff_%s_vs_%s.twiki") % (opts.refGT,opts.tarGT), "w")

    refSnap = myGTrefInfo.snapshot_time
    tarSnap = myGTtarInfo.snapshot_time

    myGTref = con.global_tag(name=opts.refGT).tags(amount=1000).as_dicts()
    myGTtar = con.global_tag(name=opts.tarGT).tags(amount=1000).as_dicts()

    differentTags = {}

    for element in myGTref:
        RefRecord = element["record"]
        RefLabel  = element["label"]
        RefTag    = element["tag_name"]

        for element2 in myGTtar:
            if (RefRecord == element2["record"] and RefLabel==element2["label"]): 
                if RefTag != element2["tag_name"]:
                    differentTags[(RefRecord,RefLabel)]=(RefTag,element2["tag_name"])

    text_file.write("| *Record* | *"+opts.refGT+"* | *"+opts.tarGT+"* | Remarks | \n")

    t = PrettyTable()

    if(opts.isVerbose):
        t.field_names = ['/','',opts.refGT,opts.tarGT,refSnap,tarSnap]
    else:
        t.field_names = ['/','',opts.refGT,opts.tarGT]

    t.hrules=1
    
    if(opts.isVerbose):
        t.add_row(['Record','label','Reference Tag','Target Tag','hash1:time1:since1','hash2:time2:since2'])
    else:
        t.add_row(['Record','label','Reference Tag','Target Tag'])

    isDifferent=False
 
    for Rcd in sorted(differentTags):

        #print Rcd,differentTags[Rcd][2]," 1:",differentTags[Rcd][0]," 2:",differentTags[Rcd][1]

        refTagIOVs = con.tag(name=differentTags[Rcd][0]).iovs().as_dicts()
        tarTagIOVs = con.tag(name=differentTags[Rcd][1]).iovs().as_dicts()

        if(opts.lastIOV):

            if(sorted(differentTags).index(Rcd)==0):
                print "=== COMPARING ONLY THE LAST IOV ==="

            lastSinceRef=-1
            lastSinceTar=-1

            for i in refTagIOVs:
                if (i["since"]>lastSinceRef):
                    lastSinceRef = i["since"]
                    hash_lastRefTagIOV = i["payload_hash"]
                    time_lastRefTagIOV = str(i["insertion_time"])

            for j in tarTagIOVs:
                if (j["since"]>lastSinceTar):
                    lastSinceTar = j["since"]
                    hash_lastTarTagIOV = j["payload_hash"]
                    time_lastTarTagIOV = str(j["insertion_time"])

            if(hash_lastRefTagIOV!=hash_lastTarTagIOV):
                isDifferent=True
                text_file.write("| ="+Rcd[0]+"= ("+Rcd[1]+") | =="+differentTags[Rcd][0]+"==  | =="+differentTags[Rcd][1]+"== | | \n")
                text_file.write("|^|"+hash_lastRefTagIOV+" <br> ("+time_lastRefTagIOV+") "+ str(lastSinceRef) +" | "+hash_lastTarTagIOV+" <br> ("+time_lastTarTagIOV+") " + str(lastSinceTar)+" | ^| \n")
                
                if(opts.isVerbose):
                    t.add_row([Rcd[0],Rcd[1],differentTags[Rcd][0],differentTags[Rcd][1],str(hash_lastRefTagIOV)+"\n"+str(time_lastRefTagIOV)+"\n"+str(lastSinceRef),str(hash_lastTarTagIOV)+"\n"+str(time_lastTarTagIOV)+"\n"+str(lastSinceTar)])
                else:
                    t.add_row([Rcd[0],Rcd[1],differentTags[Rcd][0]+"\n"+str(hash_lastRefTagIOV),differentTags[Rcd][1]+"\n"+str(hash_lastTarTagIOV)])

        else:    

            theGoodRefIOV=-1
            theGoodTarIOV=-1
            sinceRefTagIOV=0
            sinceTarTagIOV=0
         
            RefIOVtime = datetime.datetime(1970, 1, 1, 0, 0, 0)
            TarIOVtime = datetime.datetime(1970, 1, 1, 0, 0, 0)

            #print RefIOVtime
            #print refSnap

            theRefPayload=""
            theTarPayload=""
            theRefTime=""
            theTarTime=""

            #print "refIOV[]","RefIOVtime","refSnap","refIOV[]>RefIOVtime","refIOV[]<refSnap"
            for refIOV in refTagIOVs:            

                #print "|",refIOV["insertion_time"],"|",RefIOVtime,"|",refSnap,(refIOV["insertion_time"]>RefIOVtime),(refIOV["insertion_time"]<refSnap), (refIOV["since"] < int(opts.testRunNumber)),(refIOV["since"]>=sinceRefTagIOV)
                    
                if ( (refIOV["since"] <= int(opts.testRunNumber)) and (refIOV["since"]>=sinceRefTagIOV) and (refIOV["insertion_time"]>RefIOVtime) and (refIOV["insertion_time"]<refSnap) ):
                    sinceRefTagIOV = refIOV["since"]   
                    RefIOVtime = refIOV["insertion_time"]
                    theGoodRefIOV=sinceRefTagIOV                
                    theRefPayload=refIOV["payload_hash"]
                    theRefTime=str(refIOV["insertion_time"])
          
            for tarIOV in tarTagIOVs:
                if ( (tarIOV["since"] <= int(opts.testRunNumber)) and (tarIOV["since"]>=sinceTarTagIOV) and (tarIOV["insertion_time"]>TarIOVtime) and (tarIOV["insertion_time"]<tarSnap)):
                    sinceTarTagIOV = tarIOV["since"]
                    tarIOVtime = tarIOV["insertion_time"]
                    theGoodTarIOV=sinceTarTagIOV
                    theTarPayload=tarIOV["payload_hash"]
                    theTarTime=str(tarIOV["insertion_time"])
        
            if(theRefPayload!=theTarPayload):
                isDifferent=True
                text_file.write("| ="+Rcd[0]+"= ("+Rcd[1]+") | =="+differentTags[Rcd][0]+"==  | =="+differentTags[Rcd][1]+"== |\n")
                text_file.write("|^|"+theRefPayload+" ("+theRefTime+") | "+theTarPayload+" ("+theTarTime+") |\n")                       

                if(opts.isVerbose):
                    t.add_row([Rcd[0],Rcd[1],differentTags[Rcd][0],differentTags[Rcd][1],str(theRefPayload)+"\n"+str(theRefTime)+"\n"+str(theGoodRefIOV),str(theTarPayload)+"\n"+str(theTarTime)+"\n"+str(theGoodTarIOV)])
                else:
                    t.add_row([Rcd[0],Rcd[1],differentTags[Rcd][0]+"\n"+str(theRefPayload),differentTags[Rcd][1]+"\n"+str(theTarPayload)])
            
    if(not isDifferent):
        if(opts.isVerbose):
            t.add_row(["None","None","None","None","None","None"])
        else:
            t.add_row(["None","None","None"])
    print t
Ejemplo n.º 5
0
def main():
    ### MAIN LOOP ###

    if "CMSSW_RELEASE_BASE" in os.environ:
        print "\n"
        print "=================================================="
        print "This script is powered by cmsQueryingMiniFramework"
        print "served to you by", os.getenv('CMSSW_RELEASE_BASE')
        print "==================================================\n"
    else:
        print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        print "+ This tool needs cmsQueryingMiniFramework (https://gitlab.cern.ch/jdawes/cmsQueryingMiniFramework)"
        print "+ Easiest way to get it is via CMSSW (>800) is"
        print "+ cmsrel CMSSW_8_0_X  #get your favorite"
        print "+ cd CMSSW_8_0_X/src"
        print "+ cmsenv"
        print "+ cd -"
        print "and then you can proceed"
        print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        sys.exit(1)

    desc = """This is a description of %prog."""
    parser = OptionParser(description=desc, version='%prog version 0.1')
    parser.add_option('-r',
                      '--run',
                      help='test run number',
                      dest='testRunNumber',
                      action='store',
                      default='251883')
    parser.add_option('-R',
                      '--ReferenceGT',
                      help='Reference Global Tag',
                      dest='refGT',
                      action='store',
                      default='GR_H_V58C')
    parser.add_option('-T',
                      '--TargetGT',
                      help='Target Global Tag',
                      dest='tarGT',
                      action='store',
                      default='74X_dataRun2_HLTValidation_Queue')
    parser.add_option('-L',
                      '--last',
                      help='compares the very last IOV',
                      dest='lastIOV',
                      action='store_true',
                      default=False)
    parser.add_option('-v',
                      '--verbose',
                      help='returns more info',
                      dest='isVerbose',
                      action='store_true',
                      default=False)
    (opts, args) = parser.parse_args()

    import CondCore.Utilities.CondDBFW.shell as shell
    con = shell.connect()

    myGTrefInfo = con.global_tag(name=opts.refGT)
    myGTtarInfo = con.global_tag(name=opts.tarGT)

    text_file = open(("diff_%s_vs_%s.twiki") % (opts.refGT, opts.tarGT), "w")

    refSnap = myGTrefInfo.snapshot_time
    tarSnap = myGTtarInfo.snapshot_time

    myGTref = con.global_tag(name=opts.refGT).tags(amount=1000).as_dicts()
    myGTtar = con.global_tag(name=opts.tarGT).tags(amount=1000).as_dicts()

    differentTags = {}

    for element in myGTref:
        RefRecord = element["record"]
        RefLabel = element["label"]
        RefTag = element["tag_name"]

        for element2 in myGTtar:
            if (RefRecord == element2["record"]
                    and RefLabel == element2["label"]):
                if RefTag != element2["tag_name"]:
                    differentTags[(RefRecord,
                                   RefLabel)] = (RefTag, element2["tag_name"])

    text_file.write("| *Record* | *" + opts.refGT + "* | *" + opts.tarGT +
                    "* | Remarks | \n")

    t = PrettyTable()

    if (opts.isVerbose):
        t.field_names = ['/', '', opts.refGT, opts.tarGT, refSnap, tarSnap]
    else:
        t.field_names = ['/', '', opts.refGT, opts.tarGT]

    t.hrules = 1

    if (opts.isVerbose):
        t.add_row([
            'Record', 'label', 'Reference Tag', 'Target Tag',
            'hash1:time1:since1', 'hash2:time2:since2'
        ])
    else:
        t.add_row(['Record', 'label', 'Reference Tag', 'Target Tag'])

    isDifferent = False

    for Rcd in sorted(differentTags):

        #print Rcd,differentTags[Rcd][2]," 1:",differentTags[Rcd][0]," 2:",differentTags[Rcd][1]

        refTagIOVs = con.tag(name=differentTags[Rcd][0]).iovs().as_dicts()
        tarTagIOVs = con.tag(name=differentTags[Rcd][1]).iovs().as_dicts()

        if (opts.lastIOV):

            if (sorted(differentTags).index(Rcd) == 0):
                print "=== COMPARING ONLY THE LAST IOV ==="

            lastSinceRef = -1
            lastSinceTar = -1

            for i in refTagIOVs:
                if (i["since"] > lastSinceRef):
                    lastSinceRef = i["since"]
                    hash_lastRefTagIOV = i["payload_hash"]
                    time_lastRefTagIOV = str(i["insertion_time"])

            for j in tarTagIOVs:
                if (j["since"] > lastSinceTar):
                    lastSinceTar = j["since"]
                    hash_lastTarTagIOV = j["payload_hash"]
                    time_lastTarTagIOV = str(j["insertion_time"])

            if (hash_lastRefTagIOV != hash_lastTarTagIOV):
                isDifferent = True
                text_file.write("| =" + Rcd[0] + "= (" + Rcd[1] + ") | ==" +
                                differentTags[Rcd][0] + "==  | ==" +
                                differentTags[Rcd][1] + "== | | \n")
                text_file.write("|^|" + hash_lastRefTagIOV + " <br> (" +
                                time_lastRefTagIOV + ") " + str(lastSinceRef) +
                                " | " + hash_lastTarTagIOV + " <br> (" +
                                time_lastTarTagIOV + ") " + str(lastSinceTar) +
                                " | ^| \n")

                if (opts.isVerbose):
                    t.add_row([
                        Rcd[0], Rcd[1], differentTags[Rcd][0],
                        differentTags[Rcd][1],
                        str(hash_lastRefTagIOV) + "\n" +
                        str(time_lastRefTagIOV) + "\n" + str(lastSinceRef),
                        str(hash_lastTarTagIOV) + "\n" +
                        str(time_lastTarTagIOV) + "\n" + str(lastSinceTar)
                    ])
                else:
                    t.add_row([
                        Rcd[0], Rcd[1],
                        differentTags[Rcd][0] + "\n" + str(hash_lastRefTagIOV),
                        differentTags[Rcd][1] + "\n" + str(hash_lastTarTagIOV)
                    ])

        else:

            theGoodRefIOV = -1
            theGoodTarIOV = -1
            sinceRefTagIOV = 0
            sinceTarTagIOV = 0

            RefIOVtime = datetime.datetime(1970, 1, 1, 0, 0, 0)
            TarIOVtime = datetime.datetime(1970, 1, 1, 0, 0, 0)

            #print RefIOVtime
            #print refSnap

            theRefPayload = ""
            theTarPayload = ""
            theRefTime = ""
            theTarTime = ""

            #print "refIOV[]","RefIOVtime","refSnap","refIOV[]>RefIOVtime","refIOV[]<refSnap"
            for refIOV in refTagIOVs:

                #print "|",refIOV["insertion_time"],"|",RefIOVtime,"|",refSnap,(refIOV["insertion_time"]>RefIOVtime),(refIOV["insertion_time"]<refSnap), (refIOV["since"] < int(opts.testRunNumber)),(refIOV["since"]>=sinceRefTagIOV)

                if ((refIOV["since"] <= int(opts.testRunNumber))
                        and (refIOV["since"] >= sinceRefTagIOV)
                        and (refIOV["insertion_time"] > RefIOVtime)
                        and (refIOV["insertion_time"] < refSnap)):
                    sinceRefTagIOV = refIOV["since"]
                    RefIOVtime = refIOV["insertion_time"]
                    theGoodRefIOV = sinceRefTagIOV
                    theRefPayload = refIOV["payload_hash"]
                    theRefTime = str(refIOV["insertion_time"])

            for tarIOV in tarTagIOVs:
                if ((tarIOV["since"] <= int(opts.testRunNumber))
                        and (tarIOV["since"] >= sinceTarTagIOV)
                        and (tarIOV["insertion_time"] > TarIOVtime)
                        and (tarIOV["insertion_time"] < tarSnap)):
                    sinceTarTagIOV = tarIOV["since"]
                    tarIOVtime = tarIOV["insertion_time"]
                    theGoodTarIOV = sinceTarTagIOV
                    theTarPayload = tarIOV["payload_hash"]
                    theTarTime = str(tarIOV["insertion_time"])

            if (theRefPayload != theTarPayload):
                isDifferent = True
                text_file.write("| =" + Rcd[0] + "= (" + Rcd[1] + ") | ==" +
                                differentTags[Rcd][0] + "==  | ==" +
                                differentTags[Rcd][1] + "== |\n")
                text_file.write("|^|" + theRefPayload + " (" + theRefTime +
                                ") | " + theTarPayload + " (" + theTarTime +
                                ") |\n")

                if (opts.isVerbose):
                    t.add_row([
                        Rcd[0], Rcd[1], differentTags[Rcd][0],
                        differentTags[Rcd][1],
                        str(theRefPayload) + "\n" + str(theRefTime) + "\n" +
                        str(theGoodRefIOV),
                        str(theTarPayload) + "\n" + str(theTarTime) + "\n" +
                        str(theGoodTarIOV)
                    ])
                else:
                    t.add_row([
                        Rcd[0], Rcd[1],
                        differentTags[Rcd][0] + "\n" + str(theRefPayload),
                        differentTags[Rcd][1] + "\n" + str(theTarPayload)
                    ])

    if (not isDifferent):
        if (opts.isVerbose):
            t.add_row(["None", "None", "None", "None", "None", "None"])
        else:
            t.add_row(["None", "None", "None"])
    print t
Ejemplo n.º 6
0
def main():
    ### MAIN LOOP ###

    if "CMSSW_RELEASE_BASE" in os.environ:
        print "\n"
        print "=================================================="
        print "This script is powered by cmsQueryingMiniFramework"
        print "served to you by", os.getenv('CMSSW_RELEASE_BASE')
        print "==================================================\n"
    else:
        print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        print "+ This tool needs cmsQueryingMiniFramework (https://gitlab.cern.ch/jdawes/cmsQueryingMiniFramework)"
        print "+ Easiest way to get it is via CMSSW (>800) is"
        print "+ cmsrel CMSSW_8_0_4"
        print "+ cd CMSSW_8_0_4/src"
        print "+ cmsenv"
        print "+ cd -"
        print "and then you can proceed"
        print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        sys.exit(1)

    desc = """This is a description of %prog."""
    parser = OptionParser(description=desc, version='%prog version 0.1')
    parser.add_option('-r',
                      '--run',
                      help='test run number',
                      dest='testRunNumber',
                      action='store',
                      default='251883')
    parser.add_option('-R',
                      '--ReferenceGT',
                      help='Reference Global Tag',
                      dest='refGT',
                      action='store',
                      default='GR_H_V58C')
    parser.add_option('-T',
                      '--TargetGT',
                      help='Target Global Tag',
                      dest='tarGT',
                      action='store',
                      default='74X_dataRun2_HLTValidation_Queue')
    parser.add_option('-L',
                      '--last',
                      help='compares the very last IOV',
                      dest='lastIOV',
                      action='store_true',
                      default=False)
    (opts, args) = parser.parse_args()

    import CondCore.Utilities.CondDBFW.shell as shell
    con = shell.connect()

    myGTref = con.global_tag(name=opts.refGT).tags(amount=1000).as_dicts()
    myGTtar = con.global_tag(name=opts.tarGT).tags(amount=1000).as_dicts()

    differentTags = {}

    for element in myGTref:
        RefRecord = element["record"]
        RefLabel = element["label"]
        RefTag = element["tag_name"]

        for element2 in myGTtar:
            if (RefRecord == element2["record"]
                    and RefLabel == element2["label"]):
                if RefTag != element2["tag_name"]:
                    differentTags[(RefRecord,
                                   RefLabel)] = (RefTag, element2["tag_name"])

    print "| *Record* | *" + opts.refGT + "* | *" + opts.tarGT + "* | Remarks |"

    for Rcd in sorted(differentTags):

        #print Rcd,differentTags[Rcd][2]," 1:",differentTags[Rcd][0]," 2:",differentTags[Rcd][1]

        refTagIOVs = con.tag(name=differentTags[Rcd][0]).iovs().as_dicts()
        tarTagIOVs = con.tag(name=differentTags[Rcd][1]).iovs().as_dicts()

        if (opts.lastIOV):

            #print "COMPARING the LAST IOV"

            lastSinceRef = -1
            lastSinceTar = -1

            for i in refTagIOVs:
                if (i["since"] > lastSinceRef):
                    lastSinceRef = i["since"]
                    hash_lastRefTagIOV = i["payload_hash"]
                    time_lastRefTagIOV = str(i["insertion_time"])

            for i in tarTagIOVs:
                if (i["since"] > lastSinceTar):
                    lastSinceTar = i["since"]
                    hash_lastTarTagIOV = i["payload_hash"]
                    time_lastTarTagIOV = str(i["insertion_time"])

            if (hash_lastRefTagIOV != hash_lastTarTagIOV):
                print "| =" + Rcd[0] + "= (" + Rcd[
                    1] + ") | ==" + differentTags[Rcd][
                        0] + "==  | ==" + differentTags[Rcd][1] + "== | | "
                print "|^|" + hash_lastRefTagIOV + " <br> (" + time_lastRefTagIOV + ") " + str(
                    lastSinceRef
                ) + " | " + hash_lastTarTagIOV + " <br> (" + time_lastTarTagIOV + ") " + str(
                    lastSinceTar) + " | ^|"

        else:

            theGoodRefIOV = -1
            theGoodTarIOV = -1
            theRefPayload = ""
            theTarPayload = ""
            theRefTime = ""
            theTarTime = ""

            for IOV in refTagIOVs:
                sinceRefTagIOV = IOV["since"]
                if (sinceRefTagIOV < int(opts.testRunNumber)):
                    theGoodRefIOV = sinceRefTagIOV
                    theRefPayload = IOV["payload_hash"]
                    theRefTime = str(IOV["insertion_time"])

            for IOV in tarTagIOVs:
                sinceTarTagIOV = IOV["since"]
                if (sinceTarTagIOV < int(opts.testRunNumber)):
                    theGoodTarIOV = sinceTarTagIOV
                    theTarPayload = IOV["payload_hash"]
                    theTarTime = str(IOV["insertion_time"])

                    if (theRefPayload != theTarPayload):
                        print "| =" + Rcd[0] + "= (" + Rcd[
                            1] + ") | ==" + differentTags[Rcd][
                                0] + "==  | ==" + differentTags[Rcd][1] + "== |"
                        print "|^|" + theRefPayload + " (" + theRefTime + ") | " + theTarPayload + " (" + theTarTime + ") |"
Ejemplo n.º 7
0
def main():            
### MAIN LOOP ###

    if "CMSSW_RELEASE_BASE" in os.environ:
        print "\n"
        print "=================================================="
        print "This script is powered by cmsQueryingMiniFramework"
        print "served to you by",os.getenv('CMSSW_RELEASE_BASE')
        print "==================================================\n"
    else: 
        print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        print "+ This tool needs cmsQueryingMiniFramework (https://gitlab.cern.ch/jdawes/cmsQueryingMiniFramework)"
        print "+ Easiest way to get it is via CMSSW (>800) is"
        print "+ cmsrel CMSSW_8_0_4"
        print "+ cd CMSSW_8_0_4/src"
        print "+ cmsenv"
        print "+ cd -"
        print "and then you can proceed"
        print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        sys.exit(1)

    desc="""This is a description of %prog."""
    parser = OptionParser(description=desc,version='%prog version 0.1')
    parser.add_option('-r','--run', help='test run number', dest='testRunNumber', action='store', default='251883')
    parser.add_option('-R','--ReferenceGT',help='Reference Global Tag', dest='refGT', action='store', default='GR_H_V58C')
    parser.add_option('-T','--TargetGT'   ,help='Target Global Tag'   , dest='tarGT', action='store', default='74X_dataRun2_HLTValidation_Queue')
    parser.add_option('-L','--last',help='compares the very last IOV' , dest='lastIOV',action='store_true', default=False)
    (opts, args) = parser.parse_args()

    import CondCore.Utilities.CondDBFW.shell as shell
    con = shell.connect()

    myGTref = con.global_tag(name=opts.refGT).tags(amount=1000).as_dicts()
    myGTtar = con.global_tag(name=opts.tarGT).tags(amount=1000).as_dicts()

    differentTags = {}

    for element in myGTref:
        RefRecord = element["record"]
        RefLabel  = element["label"]
        RefTag    = element["tag_name"]

        for element2 in myGTtar:
            if (RefRecord == element2["record"] and RefLabel==element2["label"]): 
                if RefTag != element2["tag_name"]:
                    differentTags[(RefRecord,RefLabel)]=(RefTag,element2["tag_name"])

    print "| *Record* | *"+opts.refGT+"* | *"+opts.tarGT+"* | Remarks |"
       
    for Rcd in sorted(differentTags):

        #print Rcd,differentTags[Rcd][2]," 1:",differentTags[Rcd][0]," 2:",differentTags[Rcd][1]

        refTagIOVs = con.tag(name=differentTags[Rcd][0]).iovs().as_dicts()
        tarTagIOVs = con.tag(name=differentTags[Rcd][1]).iovs().as_dicts()

        if(opts.lastIOV):

            #print "COMPARING the LAST IOV"

            lastSinceRef=-1
            lastSinceTar=-1

            for i in refTagIOVs:
                if (i["since"]>lastSinceRef):
                    lastSinceRef = i["since"]
                    hash_lastRefTagIOV = i["payload_hash"]
                    time_lastRefTagIOV = str(i["insertion_time"])

            for i in tarTagIOVs:
                if (i["since"]>lastSinceTar):
                    lastSinceTar = i["since"]
                    hash_lastTarTagIOV = i["payload_hash"]
                    time_lastTarTagIOV = str(i["insertion_time"])

            if(hash_lastRefTagIOV!=hash_lastTarTagIOV):
                print "| ="+Rcd[0]+"= ("+Rcd[1]+") | =="+differentTags[Rcd][0]+"==  | =="+differentTags[Rcd][1]+"== | | "
                print "|^|"+hash_lastRefTagIOV+" <br> ("+time_lastRefTagIOV+") "+ str(lastSinceRef) +" | "+hash_lastTarTagIOV+" <br> ("+time_lastTarTagIOV+") " + str(lastSinceTar)+" | ^|"

        else:    

            theGoodRefIOV=-1
            theGoodTarIOV=-1
            theRefPayload=""
            theTarPayload=""
            theRefTime=""
            theTarTime=""

            for IOV in refTagIOVs:
                sinceRefTagIOV = IOV["since"]
                if (sinceRefTagIOV < int(opts.testRunNumber)):
                    theGoodRefIOV=sinceRefTagIOV
                    theRefPayload=IOV["payload_hash"]
                    theRefTime=str(IOV["insertion_time"])
          
            for IOV in tarTagIOVs:
                sinceTarTagIOV = IOV["since"]
                if (sinceTarTagIOV < int(opts.testRunNumber)):
                    theGoodTarIOV=sinceTarTagIOV
                    theTarPayload=IOV["payload_hash"]
                    theTarTime=str(IOV["insertion_time"])
        
                    if(theRefPayload!=theTarPayload):
                        print "| ="+Rcd[0]+"= ("+Rcd[1]+") | =="+differentTags[Rcd][0]+"==  | =="+differentTags[Rcd][1]+"== |"
                        print "|^|"+theRefPayload+" ("+theRefTime+") | "+theTarPayload+" ("+theTarTime+") |"
Ejemplo n.º 8
0
	def test_init_shell(self):
		connection = shell.connect(prod_connection_string, secrets=secrets_source)
		self.assertTrue(connection != None)
Ejemplo n.º 9
0
	def test_init_shell(self):
		connection_data = {"db_alias" : "orapro", "host" : "oracle", "schema" : "cms_conditions", "secrets" : secrets_file}
		connection = shell.connect(connection_data)
		self.assertTrue(connection != None)
Ejemplo n.º 10
0
 def test_init_shell(self):
     connection = shell.connect(prod_connection_string,
                                secrets=secrets_source)
     self.assertTrue(connection != None)