예제 #1
0
def query_by_evt_type(eventType):
    bk = RPCClient('Bookkeeping/BookkeepingManager')
    # get productions for given event type
    res = bk.getProductionSummaryFromView({
        'EventType': eventType,
        'Visible': True
    })
    if not res['OK']:
        print("i am here")
        print res['Message']
        DIRAC.exit(1)
    prods = res['Value']

    # get production-IDs
    bkClient = BookkeepingClient()
    prodIDs = [prod['Production'] for prod in prods]
    prodIDs.sort()

    pr = RPCClient('ProductionManagement/ProductionRequest')
    prClient = ProductionClient()

    # loop over all productions
    rv = list()
    for prodID in prodIDs:

        res = bkClient.getProductionInformations(prodID)
        if not res['OK']:
            continue

        val = res['Value']
        info = val['Production informations']
        if not info:
            continue

        steps = val['Steps']
        if isinstance(steps, str):
            continue

        dddb = None
        conddb = None

        for step in reversed(steps):
            if step[4] and 'frompreviousstep' != step[4].lower() and not dddb:
                dddb = step[4]
            if step[5] and 'frompreviousstep' != step[5].lower(
            ) and not conddb:
                conddb = step[5]

        if not (dddb and conddb):

            # print "# Can't get tags (%s/%s) from BookeepingManager, try with ProductionRequest" \
            #       % ( dddb , conddb )
            ##
            if not dddb:
                res = prClient.getParameters(prodID, 'DDDBTag')
                if res['OK']:
                    dddb = res['Value']
            ##
            if not conddb:
                res = prClient.getParameters(prodID, 'CondDBTag')
                if res['OK']:
                    conddb = res['Value']

            # print '# got ', dddb, conddb

        if not (dddb and conddb):
            res = prClient.getParameters(prodID, 'BKInputQuery')
            simProdID = None
            if res['OK']:
                simProdID = eval(res['Value']).get('ProductionID', 0)
            else:
                res = prClient.getParameters(prodID, 'RequestID')
                if res['OK']:
                    res = pr.getProductionList(int(res['Value']))
                    if res['OK']:
                        simProdID = res['Value'][0]

            if simProdID and not dddb:
                res = prClient.getParameters(simProdID, 'DDDBTag')
                if res['OK']:
                    dddb = res['Value']
            if simProdID and not conddb:
                res = prClient.getParameters(simProdID, 'CondDBTag')
                if res['OK']:
                    conddb = res['Value']

            if simProdID and not (dddb and conddb):
                res = prClient.getParameters(simProdID, 'BKProcessingPass')
                if res['OK']:
                    step0 = eval(res['Value'])['Step0']
                    if not dddb:
                        dddb = step0['DDDb']
                    if not conddb:
                        conddb = step0['CondDb']

        files = val["Number of files"]
        events = val["Number of events"]
        path = val["Path"]

        evts = 0
        ftype = None
        for i in events:
            if i[0] in ['GAUSSHIST', 'LOG', 'SIM', 'DIGI']:
                continue
            evts += i[1]
            if not ftype:
                ftype = i[0]

        nfiles = 0
        for f in files:
            if f[1] in ['GAUSSHIST', 'LOG', 'SIM', 'DIGI']:
                continue
            if f[1] != ftype:
                continue
            nfiles += f[0]

        p0, n, p1 = path.partition('\n')
        if n:
            path = p1

        rv.append({
            'path': path,
            'dddb': dddb,
            'conddb': conddb,
            'bfiles': nfiles,
            'evts': evts,
            'prodID': prodID
        })
        print(path, dddb, conddb, nfiles, evts, prodID)
    return rv
    'Visible': True
})
if not res['OK']:
    gLogger.error(
        'Could not retrieve production summary for event %s' % eventType,
        res['Message'])
    DIRAC.exit(1)
prods = res['Value']

# # get production-IDs
prodIDs = [p['Production'] for p in prods]

# # loop over all productions
for prodID in sorted(prodIDs):

    res = bkClient.getProductionInformations(prodID)
    if not res['OK']:
        gLogger.error(
            'Could not retrieve production infos for production %s' % prodID,
            res['Message'])
        continue
    prodInfo = res['Value']
    steps = prodInfo['Steps']
    if isinstance(steps, str):
        continue
    files = prodInfo["Number of files"]
    events = prodInfo["Number of events"]
    path = prodInfo["Path"]

    dddb = None
    conddb = None
예제 #3
0
    '  ProdID:   Production ID'
]))
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()
import types

if len(args) < 1:
    Script.showHelp()

exitCode = 0

from LHCbDIRAC.BookkeepingSystem.Client.BookkeepingClient import BookkeepingClient
bk = BookkeepingClient()
prod = long(args[0])

res = bk.getProductionInformations(prod)

if res['OK']:
    val = res['Value']
    print "Production Info: "

    infs = val["Production informations"]
    if infs != None:
        for inf in infs:
            if inf[2] != None:
                print '    Configuration Name:', inf[0]
                print '    Configuration Version:', inf[1]
                print '    Event type:', inf[2]

    steps = val['Steps']