def getOutputLumis(url, workflow, dataset, skipInvalid=False):
    """
    Gets the output lumis depending on the type
    of the request
    """
    # request = getWorkflowInfo(url, workflow)
    return dbs3.getLumiCountDataSet(dataset, skipInvalid)
def getOutputLumis(url, workflow, dataset, skipInvalid=False):
    """
    Gets the output lumis depending on the type
    of the request
    """
    # request = getWorkflowInfo(url, workflow)
    return dbs3.getLumiCountDataSet(dataset, skipInvalid)
 def getOutputLumis(self, ds, skipInvalid=False):
     """
     Gets the numer of lumis in an output dataset
     """
     #We store the events to avoid checking them twice
     if ds not in self.outLumis:
         lumis = dbs3.getLumiCountDataSet(ds, skipInvalid)
         self.outLumis[ds] = lumis
     else:
         lumis = self.outLumis[ds]
     return lumis
 def getOutputLumis(self, ds, skipInvalid=False):
     """
     Gets the numer of lumis in an output dataset
     """
     #We store the events to avoid checking them twice
     if ds not in self.outLumis:
         lumis = dbs3.getLumiCountDataSet(ds, skipInvalid)
         self.outLumis[ds] = lumis
     else:
         lumis = self.outLumis[ds]
     return lumis
def checkCorrectLumisEventGEN(dataset):
    """
    Checks that the dataset has more than 300 events per lumi
    """
    numlumis = dbs3Client.getLumiCountDataSet(dataset)
    numEvents = dbs3Client.getEventCountDataSet(dataset)
    # numEvents / numLumis >= 300
    if numlumis >= numEvents / 300.0:
        return True
    else:
        return False
 def getInputLumis(self, checkList = False, checkInput=False):
     """
     Checks against lumi list
     """
     if not checkList and not checkInput:
         return Workflow.getInputLumis(self)
     if checkInput:
         #retrieve lumis of the inpu dataset
         return dbs3.getLumiCountDataSet(self.inputDataset)
     if checkList:
         runLumis = self.info['LumiList']
         if runLumis:
             total = 0
             for run, lumiList in runLumis.items():
                 total += sum(l2 - l1 + 1 for l1, l2 in lumiList)
             return total
         return 0
 def getInputLumis(self, checkList=False, checkInput=False):
     """
     Checks against lumi list
     """
     if not checkList and not checkInput:
         return Workflow.getInputLumis(self)
     if checkInput:
         #retrieve lumis of the inpu dataset
         return dbs3.getLumiCountDataSet(self.inputDataset)
     if checkList:
         runLumis = self.info['LumiList']
         if runLumis:
             total = 0
             for run, lumiList in runLumis.items():
                 total += sum(l2 - l1 + 1 for l1, l2 in lumiList)
             return total
         return 0
def getInputLumis(url, workflow):
    """
    Gets the input lumis of a given workflow
    depending of the kind of workflow
    TODO this can be replaced by getting it from the workload cache
    """
    request = getWorkflowInfo(url,workflow)
    requestType=request['RequestType']
    #if request is montecarlo or Step0, the numer of
    #input events is by the requsted events
    if requestType == 'MonteCarlo' or requestType == 'LHEStepZero':
        raise Exception("This request has no input dataset")
    if requestType == 'TaskChain':
        return Exception("Not implemented yet")

    #if request is not montecarlo, then we need to check the size
    #of input datasets
    #This loops fixes the white and blacklists in the workflow
    #information,
    for listitem in ["RunWhitelist", "RunBlacklist",
                    "BlockWhitelist", "BlockBlacklist"]:
        if listitem in request:
            #if empty
            if request[listitem]=='[]' or request[listitem]=='':
                request[listitem]=[]
            #if there is not a list but some elements it creates a list
            if type(request[listitem]) is not list:
                # if doesn't contain "[" is a single block
                if '[' not in request[listitem]:
                    #wrap in a list
                    request[listitem] = [request[listitem]]
                #else parse a list
                else:
                    request[listitem]= eval(request[listitem])
        #if not, an empty list will do        
        else:
            request[listitem]=[]

    inputDataSet=request['InputDataset']
    totalLumis = dbs3.getLumiCountDataSet(inputDataSet)
    #it the request is rereco, we valiate white/black lists
    if requestType=='ReReco':
        # if there is block whte list, count only the selected block
        if request['BlockWhitelist']:
            lumis = dbs3.getLumiCountDataSetBlockList(inputDataSet,request['BlockWhitelist'])
        # if there is block black list, substract them from the total
        if request['BlockBlacklist']:
            lumis = (totalLumis - 
                    dbs3.getLumiCountDataSetBlockList(inputDataSet,request['BlockBlacklist']))
            return lumis
        # same if a run whitelist
        if request['RunWhitelist']:
            lumis = dbs3.getLumiCountDataSetRunList(inputDataSet, request['RunWhitelist'])
            return lumis
        # otherwize, the full lumi count
        else:
            lumis = totalLumis
            return lumis
    lumis = dbs3.getLumiCountDataSet(inputDataSet)
    # if black list, subsctract them    
    if request['BlockBlacklist']:
        lumis = totalLumis - dbs3.getLumiCountDataSetBlockList(inputDataSet, request['BlockBlacklist'])
    # if white list, only the ones in the whitelist.
    if request['RunWhitelist']:
        lumis = totalLumis.getLumiCountDataSetRunList(inputDataSet, request['RunWhitelist'])
    # if white list of blocks
    if request['BlockWhitelist']:
        lumis = dbs3.getLumiCountDataSetBlockList(inputDataSet, request['BlockWhitelist'])

    return lumis
def getInputLumis(url, workflow):
    """
    Gets the input lumis of a given workflow
    depending of the kind of workflow
    TODO this can be replaced by getting it from the workload cache
    """
    request = getWorkflowInfo(url, workflow)
    requestType = request['RequestType']
    #if request is montecarlo or Step0, the numer of
    #input events is by the requsted events
    if requestType == 'MonteCarlo' or requestType == 'LHEStepZero':
        raise Exception("This request has no input dataset")
    if requestType == 'TaskChain':
        return Exception("Not implemented yet")

    #if request is not montecarlo, then we need to check the size
    #of input datasets
    #This loops fixes the white and blacklists in the workflow
    #information,
    for listitem in [
            "RunWhitelist", "RunBlacklist", "BlockWhitelist", "BlockBlacklist"
    ]:
        if listitem in request:
            #if empty
            if request[listitem] == '[]' or request[listitem] == '':
                request[listitem] = []
            #if there is not a list but some elements it creates a list
            if type(request[listitem]) is not list:
                # if doesn't contain "[" is a single block
                if '[' not in request[listitem]:
                    #wrap in a list
                    request[listitem] = [request[listitem]]
                #else parse a list
                else:
                    request[listitem] = eval(request[listitem])
        #if not, an empty list will do
        else:
            request[listitem] = []

    inputDataSet = request['InputDataset']
    totalLumis = dbs3.getLumiCountDataSet(inputDataSet)
    #it the request is rereco, we valiate white/black lists
    if requestType == 'ReReco':
        # if there is block whte list, count only the selected block
        if request['BlockWhitelist']:
            lumis = dbs3.getLumiCountDataSetBlockList(
                inputDataSet, request['BlockWhitelist'])
        # if there is block black list, substract them from the total
        if request['BlockBlacklist']:
            lumis = (totalLumis - dbs3.getLumiCountDataSetBlockList(
                inputDataSet, request['BlockBlacklist']))
            return lumis
        # same if a run whitelist
        if request['RunWhitelist']:
            lumis = dbs3.getLumiCountDataSetRunList(inputDataSet,
                                                    request['RunWhitelist'])
            return lumis
        # otherwize, the full lumi count
        else:
            lumis = totalLumis
            return lumis
    lumis = dbs3.getLumiCountDataSet(inputDataSet)
    # if black list, subsctract them
    if request['BlockBlacklist']:
        lumis = totalLumis - dbs3.getLumiCountDataSetBlockList(
            inputDataSet, request['BlockBlacklist'])
    # if white list, only the ones in the whitelist.
    if request['RunWhitelist']:
        lumis = totalLumis.getLumiCountDataSetRunList(inputDataSet,
                                                      request['RunWhitelist'])
    # if white list of blocks
    if request['BlockWhitelist']:
        lumis = dbs3.getLumiCountDataSetBlockList(inputDataSet,
                                                  request['BlockWhitelist'])

    return lumis