コード例 #1
0
    def _getPileupConfigFromJson(self):
        """
        There has been stored pileup configuration stored in a JSON file
        as a result of DBS querrying when running PileupFetcher,
        this method loads this configuration from sandbox and returns it
        as dictionary.

        The PileupFetcher was called by WorkQueue which creates job's sandbox
        and sandbox gets migrated to the worker node.

        """
        workingDir = self.stepSpace.location
        jsonPileupConfig = os.path.join(workingDir, "pileupconf.json")
        print "Pileup JSON configuration file: '%s'" % jsonPileupConfig
        # load the JSON config file into a Python dictionary
        decoder = JSONDecoder()
        try:
            f = open(jsonPileupConfig, 'r')
            json = f.read()
            pileupDict = decoder.decode(json)
            f.close()
        except IOError:
            m = "Could not read pileup JSON configuration file: '%s'" % jsonPileupConfig
            raise RuntimeError(m)
        return pileupDict
コード例 #2
0
ファイル: SetupCMSSWPset.py プロジェクト: ticoann/WMCore
    def _getPileupConfigFromJson(self):
        """
        There has been stored pileup configuration stored in a JSON file
        as a result of DBS querrying when running PileupFetcher,
        this method loads this configuration from sandbox and returns it
        as dictionary.

        The PileupFetcher was called by WorkQueue which creates job's sandbox
        and sandbox gets migrated to the worker node.

        """
        workingDir = self.stepSpace.location
        jsonPileupConfig = os.path.join(workingDir, "pileupconf.json")
        print "Pileup JSON configuration file: '%s'" % jsonPileupConfig
        # load the JSON config file into a Python dictionary
        decoder = JSONDecoder()
        try:
            f = open(jsonPileupConfig, 'r')
            json = f.read()
            pileupDict =  decoder.decode(json)
            f.close()
        except IOError:
            m = "Could not read pileup JSON configuration file: '%s'" % jsonPileupConfig
            raise RuntimeError(m)
        return pileupDict
コード例 #3
0
ファイル: PileupFetcher_t.py プロジェクト: ticoann/WMCore
    def _queryPileUpConfigFile(self, defaultArguments, task, taskPath):
        """
        Query and compare contents of the the pileup JSON
        configuration files. Iterate over tasks's steps as
        it happens in the PileupFetcher.

        """
        for step in task.steps().nodeIterator():
            helper = WMStep.WMStepHelper(step)
            # returns e.g. instance of CMSSWHelper
            if hasattr(helper.data, "pileup"):
                decoder = JSONDecoder()

                stepPath = "%s/%s" % (taskPath, helper.name())
                pileupConfig = "%s/%s" % (stepPath, "pileupconf.json")
                try:
                    f = open(pileupConfig, 'r')
                    json = f.read()
                    # loads directly the Python dictionary
                    pileupDict = decoder.decode(json)
                    f.close()
                except IOError:
                    m = "Could not read pileup JSON configuration file: '%s'" % pileupConfig
                    raise RuntimeError(m)
                self._queryAndCompareWithDBS(pileupDict, defaultArguments,
                                             helper.data.dbsUrl)
コード例 #4
0
ファイル: PileupFetcher_t.py プロジェクト: zhiwenuil/WMCore
 def _queryPileUpConfigFile(self, defaultArguments, task, taskPath):
     """
     Query and compare contents of the the pileup JSON
     configuration files. Iterate over tasks's steps as
     it happens in the PileupFetcher.
     
     """
     for step in task.steps().nodeIterator():
         helper = WMStep.WMStepHelper(step)
         # returns e.g. instance of CMSSWHelper
         if hasattr(helper.data, "pileup"):
             decoder = JSONDecoder()
             
             stepPath = "%s/%s" % (taskPath, helper.name())
             pileupConfig = "%s/%s" % (stepPath, "pileupconf.json")
             try:
                 f = open(pileupConfig, 'r')
                 json = f.read()
                 # loads directly the Python dictionary
                 pileupDict =  decoder.decode(json)
                 f.close()
             except IOError:
                 m = "Could not read pileup JSON configuration file: '%s'" % pileupConfig 
                 raise RuntimeError(m)
             self._queryAndCompareWithDBS(pileupDict, defaultArguments, helper.data.dbsUrl)                
コード例 #5
0
 def decode(self, data):
     """
     decode the data to python from json
     """
     if data:
         decoder = JSONDecoder()
         thunker = JSONThunker()
         data = decoder.decode(data)
         unthunked = thunker.unthunk(data)
         return unthunked
     else:
         return {}
コード例 #6
0
 def decode(self, data):
     """
     decode the data to python from json
     """
     if data:
         decoder = JSONDecoder()
         thunker = JSONThunker()
         data =  decoder.decode(data)
         unthunked = thunker.unthunk(data)
         return unthunked
     else:
         return {}