当前位置: 首页>>代码示例>>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;未经允许,请勿转载。