當前位置: 首頁>>代碼示例>>Python>>正文


Python DataBlockGenerator.getParentBlock方法代碼示例

本文整理匯總了Python中WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator.DataBlockGenerator.getParentBlock方法的典型用法代碼示例。如果您正苦於以下問題:Python DataBlockGenerator.getParentBlock方法的具體用法?Python DataBlockGenerator.getParentBlock怎麽用?Python DataBlockGenerator.getParentBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator.DataBlockGenerator的用法示例。


在下文中一共展示了DataBlockGenerator.getParentBlock方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator import DataBlockGenerator [as 別名]
# 或者: from WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator.DataBlockGenerator import getParentBlock [as 別名]

#.........這裏部分代碼省略.........

    def listRuns(self, dataset = None, block = None):
        def getRunsFromBlock(b):
            results = set()
            for x in self.dataBlocks.getFiles(b):
                results = results.union([y['RunNumber'] for y in x['LumiList']])
            return list(results)

        if block:
            return getRunsFromBlock(block)
        if dataset:
            runs = set()
            for block in self.dataBlocks.getBlocks(dataset):
                runs = runs.union(getRunsFromBlock(block['Name']))
            return list(runs)
        return None

    def listRunLumis(self, dataset = None, block = None):
        def getRunsFromBlock(b):
            results = {}
            for x in self.dataBlocks.getFiles(b):
                for y in x['LumiList']:
                    if y['RunNumber'] not in results:
                        results[y['RunNumber']] = 0
                    results[y['RunNumber']] += 1
            return results

        if block:
            return getRunsFromBlock(block)
        if dataset:
            runs = {}
            for block in self.dataBlocks.getBlocks(dataset):
                updateRuns = getRunsFromBlock(block['Name'])
                for run in updateRuns:
                    if run not in runs:
                        runs[run] = 0
                    runs[run] += updateRuns[run]
            return runs
        return None



    def getDBSSummaryInfo(self, dataset=None, block=None):

        """Dataset summary"""
        def getLumisectionsInBlock(b):
            lumis = set()
            for file in self.dataBlocks.getFiles(b):
                for x in file['LumiList']:
                    lumis.add(x['LumiSectionNumber'])
            return lumis

        result = {}
        if block:
            result['NumberOfEvents'] = str(sum([x['NumberOfEvents']
                                for x in self.dataBlocks.getFiles(block)]))
            result['NumberOfFiles'] = str(len(self.dataBlocks.getFiles(block)))

            result['NumberOfLumis'] = str(len(getLumisectionsInBlock(block)))

            result['path'] = dataset
            result['block'] = block
            result['OpenForWriting'] = '1' if self.dataBlocks._openForWriting() else '0'

        if dataset:
            if self.dataBlocks.getBlocks(dataset):
                result['NumberOfEvents'] = str(sum([x['NumberOfEvents']
                                    for x in self.dataBlocks.getBlocks(dataset)]))
                result['NumberOfFiles'] = str(sum([x['NumberOfFiles']
                                    for x in self.dataBlocks.getBlocks(dataset)]))
                lumis = set()
                for b in self.dataBlocks.getBlocks(dataset):
                    lumis = lumis.union(getLumisectionsInBlock(b['Name']))

                result['NumberOfLumis'] = str(len(lumis))
                result['path'] = dataset

        # Weird error handling follows, this is what dbs does
        if not result:
            raise DBSReaderError('DbsConnectionError: Database exception,Invalid parameters')
        return result

    def listBlockParents(self, block):
        return self.dataBlocks.getParentBlock(block, 1)

    def listDatasetLocation(self, dataset):
        """
        _listDatasetLocation_

        List the SEs where there is at least a block of the given
        dataset.
        """
        blocks = self.getFileBlocksInfo(dataset, onlyClosedBlocks = False,
                                        blockName = '*', locations = True)

        result = set()
        for block in blocks:
            result |= set([x['Name'] for x in block['StorageElementList']])

        return list(result)
開發者ID:AndrewLevin,項目名稱:WMCore,代碼行數:104,代碼來源:DBSReader.py

示例2: __init__

# 需要導入模塊: from WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator import DataBlockGenerator [as 別名]
# 或者: from WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator.DataBlockGenerator import getParentBlock [as 別名]

#.........這裏部分代碼省略.........

    def listFileBlockLocation(self, block):
        """Fake locations"""
        return self.dataBlocks.getLocation(block)

    def listFilesInBlock(self, block):
        """Fake files"""
        return self.dataBlocks.getFiles(block)

    def listFilesInBlockWithParents(self, block):
        return self.dataBlocks.getFiles(block, True)

    def getFileBlock(self, block):
        """Return block + locations"""
        result = { block : {
            "StorageElements" : self.listFileBlockLocation(block),
            "Files" : self.listFilesInBlock(block),
            "IsOpen" : False,
            }
                }
        return result

    def getFileBlockWithParents(self, fileBlockName):
        """
        _getFileBlockWithParents_

        return a dictionary:
        { blockName: {
             "StorageElements" : [<se list>],
             "Files" : dictionaries representing each file
             }
        }

        files

        """

        result = { fileBlockName: {
            "StorageElements" : self.listFileBlockLocation(fileBlockName),
            "Files" : self.listFilesInBlockWithParents(fileBlockName),
            "IsOpen" : False,

            }
                   }
        return result

    def listRuns(self, dataset = None, block = None):
        def getRunsFromBlock(b):
            results = []
            for x in self.dataBlocks.getFiles(b):
                results.extend([y['RunNumber'] for y in x['LumiList']])
            return results

        if block:
            return getRunsFromBlock(block)
        if dataset:
            runs = []
            for block in self.dataBlocks.getBlocks(dataset):
                runs.extend(getRunsFromBlock(block['Name']))
            return runs
        return None


    def getDBSSummaryInfo(self, dataset=None, block=None):

        """Dataset summary"""
        def getLumisectionsInBlock(b):
            lumis = set()
            for file in self.dataBlocks.getFiles(b):
                for x in file['LumiList']:
                    lumis.add(x['LumiSectionNumber'])
            return lumis

        result = {}
        if block:
            result['NumberOfEvents'] = sum([x['NumberOfEvents']
                                for x in self.dataBlocks.getFiles(block)])
            result['NumberOfFiles'] = len(self.dataBlocks.getFiles(block))

            result['NumberOfLumis'] = len(getLumisectionsInBlock(block))

            result['path'] = dataset

        if dataset:
            if self.dataBlocks.getBlocks(dataset):
                result['NumberOfEvents'] = sum([x['NumberOfEvents']
                                    for x in self.dataBlocks.getBlocks(dataset)])
                result['NumberOfFiles'] = sum([x['NumberOfFiles']
                                    for x in self.dataBlocks.getBlocks(dataset)])
                lumis = set()
                for b in self.dataBlocks.getBlocks(dataset):
                    lumis = lumis.union(getLumisectionsInBlock(b['Name']))

                result['NumberOfLumis'] = len(lumis)
                result['path'] = dataset

        return result

    def listBlockParents(self, block):
        return self.dataBlocks.getParentBlock(block, 1)
開發者ID:zhiwenuil,項目名稱:WMCore,代碼行數:104,代碼來源:DBSReader.py


注:本文中的WMQuality.Emulators.DataBlockGenerator.DataBlockGenerator.DataBlockGenerator.getParentBlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。