当前位置: 首页>>代码示例>>Python>>正文


Python Run.lumis方法代码示例

本文整理汇总了Python中WMCore.DataStructs.Run.Run.lumis方法的典型用法代码示例。如果您正苦于以下问题:Python Run.lumis方法的具体用法?Python Run.lumis怎么用?Python Run.lumis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WMCore.DataStructs.Run.Run的用法示例。


在下文中一共展示了Run.lumis方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getRunLumis

# 需要导入模块: from WMCore.DataStructs.Run import Run [as 别名]
# 或者: from WMCore.DataStructs.Run.Run import lumis [as 别名]
    def getRunLumis(self, fileBinds, fileList,
                    conn=None, transaction=False):
        """
        _getRunLumis_

        Fetch run/lumi/events information for each file and append Run objects
        to the files information.
        """
        lumiResult = self.dbi.processData(self.runLumiSQL, fileBinds, conn=conn,
                                          transaction=transaction)
        lumiList = self.formatDict(lumiResult)

        lumiDict = {}
        for l in lumiList:
            lumiDict.setdefault(l['fileid'], [])
            lumiDict[l['fileid']].append(l)

        for f in fileList:
            # Add new runs
            f.setdefault('newRuns', [])

            fileRuns = {}
            if f['id'] in lumiDict.keys():
                for l in lumiDict[f['id']]:
                    run = l['run']
                    lumi = l['lumi']
                    numEvents = l['num_events']
                    fileRuns.setdefault(run, [])
                    fileRuns[run].append((lumi, numEvents))

            for r in fileRuns.keys():
                newRun = Run(runNumber=r)
                newRun.lumis = fileRuns[r]
                f['newRuns'].append(newRun)
        return
开发者ID:dmwm,项目名称:WMCore,代码行数:37,代码来源:LoadForErrorHandler.py

示例2: execute

# 需要导入模块: from WMCore.DataStructs.Run import Run [as 别名]
# 或者: from WMCore.DataStructs.Run.Run import lumis [as 别名]
    def execute(self, jobID, fileSelection = None,
                conn = None, transaction = False):
        """
        _execute_

        Execute the SQL for the given job ID and then format and return
        the result.
        """

        if type(jobID) == list:
            if len(jobID) < 1:
                # Nothing to do
                return []
            binds = jobID
        else:
            binds = {"jobid": jobID}

        result = self.dbi.processData(self.sql, binds, conn = conn,
                                      transaction = transaction)

        jobList = self.formatJobs(result)

        filesResult = self.dbi.processData(self.fileSQL, binds, conn = conn,
                                           transaction = transaction)
        fileList  = self.formatDict(filesResult)
        fileBinds = []
        if fileSelection:
            fileList = filter(lambda x : x['lfn'] in fileSelection[x['jobid']], fileList)
        for x in fileList:
            # Add new runs
            x['newRuns'] = []
            # Assemble unique list of binds
            if not {'fileid': x['id']} in fileBinds:
                fileBinds.append({'fileid': x['id']})

        parentList = []
        if len(fileBinds) > 0:
            parentResult = self.dbi.processData(self.parentSQL, fileBinds, conn = conn,
                                                transaction = transaction)
            parentList   = self.formatDict(parentResult)

            lumiResult = self.dbi.processData(self.runLumiSQL, fileBinds, conn = conn,
                                              transaction = transaction)
            lumiList = self.formatDict(lumiResult)
            lumiDict = {}
            for l in lumiList:
                if not l['fileid'] in lumiDict.keys():
                    lumiDict[l['fileid']] = []
                lumiDict[l['fileid']].append(l)

            for f in fileList:
                fileRuns = {}
                if f['id'] in lumiDict.keys():
                    for l in lumiDict[f['id']]:
                        run  = l['run']
                        lumi = l['lumi']
                        try:
                            fileRuns[run].append(lumi)
                        except KeyError:
                            fileRuns[run] = []
                            fileRuns[run].append(lumi)

                for r in fileRuns.keys():
                    newRun = Run(runNumber = r)
                    newRun.lumis = fileRuns[r]
                    f['newRuns'].append(newRun)

        filesForJobs = {}
        for f in fileList:
            jobid = f['jobid']
            if not jobid in filesForJobs.keys():
                filesForJobs[jobid] = {}
            if f['id'] not in filesForJobs[jobid].keys():
                wmbsFile = File(id = f['id'])
                wmbsFile.update(f)
                wmbsFile['locations'].add(f['se_name'])
                for r in wmbsFile['newRuns']:
                    wmbsFile.addRun(r)
                for entry in parentList:
                    if entry['id'] == f['id']:
                        wmbsFile['parents'].add(entry['lfn'])
                filesForJobs[jobid][f['id']] = wmbsFile
            else:
                # If the file is there, just add the location
                filesForJobs[jobid][f['id']]['locations'].add(f['se_name'])

        for j in jobList:
            if j['id'] in filesForJobs.keys():
                j['input_files'] = filesForJobs[j['id']].values()

        return jobList
开发者ID:AndrewLevin,项目名称:WMCore,代码行数:93,代码来源:LoadForErrorHandler.py

示例3: execute

# 需要导入模块: from WMCore.DataStructs.Run import Run [as 别名]
# 或者: from WMCore.DataStructs.Run.Run import lumis [as 别名]
    def execute(self, jobID, conn = None, transaction = False):
        """
        _execute_

        Execute the SQL for the given job ID(s) and then format and return
        the result.
        """

        if type(jobID) != list:
            jobID = [jobID]

        binds = [{"jobid": x} for x in jobID]

        if not binds:
            return []

        #First load full file information with run/lumis
        filesResult = self.dbi.processData(self.fileSQL, binds, conn = conn,
                                           transaction = transaction)
        fileList = self.formatDict(filesResult)

        #Clear duplicates
        bindDict = {}
        for result in fileList:
            bindDict[result['id']] = 1
            result['newRuns'] = []
        fileBinds = [{'fileid' : x} for x in bindDict.keys()]

        #Load file information
        if len(fileBinds):
            lumiResult = self.dbi.processData(self.runLumiSQL, fileBinds, conn = conn,
                                              transaction = transaction)
            lumiList = self.formatDict(lumiResult)
            lumiDict = {}
            for l in lumiList:
                if not l['fileid'] in lumiDict.keys():
                    lumiDict[l['fileid']] = []
                lumiDict[l['fileid']].append(l)

            for f in fileList:
                fileRuns = {}
                if f['id'] in lumiDict.keys():
                    for l in lumiDict[f['id']]:
                        run = l['run']
                        lumi = l['lumi']
                        try:
                            fileRuns[run].append(lumi)
                        except KeyError:
                            fileRuns[run] = []
                            fileRuns[run].append(lumi)

                for r in fileRuns.keys():
                    newRun = Run(runNumber = r)
                    newRun.lumis = fileRuns[r]
                    f['newRuns'].append(newRun)

        filesForJobs = {}
        for f in fileList:
            jobid = f['jobid']
            if not jobid in filesForJobs.keys():
                filesForJobs[jobid] = {}
            if f['id'] not in filesForJobs[jobid].keys():
                wmbsFile = File(id = f['id'])
                wmbsFile.update(f)
                for r in wmbsFile['newRuns']:
                    wmbsFile.addRun(r)
                filesForJobs[jobid][f['id']] = wmbsFile


        #Add the file information to job objects and load the masks
        jobList = [Job(id = x) for x in jobID]
        for j in jobList:
            if j['id'] in filesForJobs.keys():
                j['input_files'] = filesForJobs[j['id']].values()
            j['mask'].load(j['id'])

        return jobList
开发者ID:AndresTanasijczuk,项目名称:WMCore,代码行数:79,代码来源:LoadForTaskArchiver.py


注:本文中的WMCore.DataStructs.Run.Run.lumis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。