示例#1
0
    def _createPileupConfigFile(self, helper, fakeSites):
        """
        Stores pileup JSON configuration file in the working
        directory / sandbox.

        """
        stepPath = "%s/%s" % (self.workingDirectory(), helper.name())
        fileName = "%s/%s" % (stepPath, "pileupconf.json")
        if os.path.isfile(fileName) and os.path.getsize(fileName) > 0:
            # if file already exist don't make a new dbs call and overwrite the file.
            # just return
            return

        encoder = JSONEncoder()
        # this should have been set in CMSSWStepHelper along with
        # the pileup configuration
        url = helper.data.dbsUrl

        dbsReader = DBSReader(url)

        configDict = self._queryDbsAndGetPileupConfig(helper, dbsReader, fakeSites)

        # create JSON and save into a file
        json = encoder.encode(configDict)

        if not os.path.exists(stepPath):
            os.mkdir(stepPath)
        try:
            fileName = "%s/%s" % (stepPath, "pileupconf.json")
            f = open(fileName, 'w')
            f.write(json)
            f.close()
        except IOError:
            m = "Could not save pileup JSON configuration file: '%s'" % fileName
            raise RuntimeError(m)
示例#2
0
    def _createPileupConfigFile(self, helper, fakeSites=None):
        """
        Stores pileup JSON configuration file in the working
        directory / sandbox.

        """

        if fakeSites is None:
            fakeSites = []

        if self._isCacheValid(helper):
            # we need to update the new sandbox json file in case TrustPUSitelists is on
            if fakeSites:
                self._updatePileupPNNs(helper, fakeSites)

            # if file already exist don't make a new dbs call and overwrite the file.
            # just return
            return

        encoder = JSONEncoder()
        # this should have been set in CMSSWStepHelper along with
        # the pileup configuration
        url = helper.data.dbsUrl

        dbsReader = DBSReader(url)

        configDict = self._queryDbsAndGetPileupConfig(helper, dbsReader, fakeSites)

        # create JSON and save into a file
        jsonPU = encoder.encode(configDict)
        self._saveFile(helper, jsonPU)
示例#3
0
    def _createPileupConfigFile(self, helper):
        """
        Stores pileup JSON configuration file in the working
        directory / sandbox.
        
        """
        encoder = JSONEncoder()
        args = {}
        # this should have been set in CMSSWStepHelper along with
        # the pileup configuration
        args["url"] = helper.data.dbsUrl
        args["version"] = "DBS_2_0_9"
        args["mode"] = "GET"
        from DBSAPI.dbsApi import DbsApi

        dbsApi = DbsApi(args)

        configDict = self._queryDbsAndGetPileupConfig(helper, dbsApi)

        # create JSON and save into a file
        json = encoder.encode(configDict)

        stepPath = "%s/%s" % (self.workingDirectory(), helper.name())
        if not os.path.exists(stepPath):
            os.mkdir(stepPath)
        try:
            fileName = "%s/%s" % (stepPath, "pileupconf.json")
            f = open(fileName, "w")
            f.write(json)
            f.close()
        except IOError:
            m = "Could not save pileup JSON configuration file: '%s'" % fileName
            raise RuntimeError(m)
示例#4
0
    def _createPileupConfigFile(self, helper, fakeSites=None):
        """
        Stores pileup JSON configuration file in the working
        directory / sandbox.

        """

        if fakeSites is None:
            fakeSites = []

        if self._isCacheValid(helper):
            # if file already exist don't make a new dbs call and overwrite the file.
            # just return
            return

        encoder = JSONEncoder()
        # this should have been set in CMSSWStepHelper along with
        # the pileup configuration
        url = helper.data.dbsUrl

        dbsReader = DBSReader(url)

        configDict = self._queryDbsAndGetPileupConfig(helper, dbsReader,
                                                      fakeSites)

        # create JSON and save into a file
        json = encoder.encode(configDict)
        self._saveFile(helper, json)
示例#5
0
    def _createPileupConfigFile(self, helper):
        """
        Stores pileup JSON configuration file in the working
        directory / sandbox.

        """
        encoder = JSONEncoder()
        # this should have been set in CMSSWStepHelper along with
        # the pileup configuration
        url = helper.data.dbsUrl

        dbsReader = DBSReader(url)

        configDict = self._queryDbsAndGetPileupConfig(helper, dbsReader)

        # create JSON and save into a file
        json = encoder.encode(configDict)

        stepPath = "%s/%s" % (self.workingDirectory(), helper.name())
        if not os.path.exists(stepPath):
            os.mkdir(stepPath)
        try:
            fileName = "%s/%s" % (stepPath, "pileupconf.json")
            f = open(fileName, 'w')
            f.write(json)
            f.close()
        except IOError:
            m = "Could not save pileup JSON configuration file: '%s'" % fileName
            raise RuntimeError(m)
示例#6
0
    def _createPileupConfigFile(self, helper):
        """
        Stores pileup JSON configuration file in the working
        directory / sandbox.

        """
        encoder = JSONEncoder()
        # this should have been set in CMSSWStepHelper along with
        # the pileup configuration
        url = helper.data.dbsUrl

        dbsReader = DBSReader(url)

        configDict = self._queryDbsAndGetPileupConfig(helper, dbsReader)

        # create JSON and save into a file
        json = encoder.encode(configDict)

        stepPath = "%s/%s" % (self.workingDirectory(), helper.name())
        if not os.path.exists(stepPath):
            os.mkdir(stepPath)
        try:
            fileName = "%s/%s" % (stepPath, "pileupconf.json")
            f = open(fileName, 'w')
            f.write(json)
            f.close()
        except IOError:
            m = "Could not save pileup JSON configuration file: '%s'" % fileName
            raise RuntimeError(m)
示例#7
0
 def encode(self, data):
     """
     encode data as json
     """
     encoder = JSONEncoder()
     thunker = JSONThunker()
     thunked = thunker.thunk(data)
     return encoder.encode(thunked)
示例#8
0
 def encode(self, data):
     """
     encode data as json
     """
     encoder = JSONEncoder()
     thunker = JSONThunker()
     thunked = thunker.thunk(data)
     return encoder.encode(thunked)
示例#9
0
    def _updatePileupPNNs(self, stepHelper, fakeSites):
        """
        Update the workflow copy of the cached pileup file with PNNs
        forced by TrustPUSitelists flag
        """
        fileName = self._getStepFilePath(stepHelper)
        fakePNNs = mapSitetoPNN(fakeSites)
        with open(fileName, 'r') as puO:
            pileupData = json.load(puO)

        for dummyPUType, blockDict in pileupData.iteritems():
            for dummyBlockName, blockInfo in blockDict.iteritems():
                blockInfo['PhEDExNodeNames'].extend([x for x in fakePNNs if x not in blockInfo])

        encoder = JSONEncoder()
        jsonPU = encoder.encode(pileupData)
        self._writeFile(fileName, jsonPU)
示例#10
0
    def _createPileupConfigFile(self, helper, fakeSites=None):
        """
        Stores pileup JSON configuration file in the working
        directory / sandbox.

        """

        if fakeSites is None:
            fakeSites = []

        stepPath = "%s/%s" % (self.workingDirectory(), helper.name())
        fileName = "%s/%s" % (stepPath, "pileupconf.json")
        if os.path.isfile(fileName) and os.path.getsize(fileName) > 0:
            # if file already exist don't make a new dbs call and overwrite the file.
            # just return
            return

        encoder = JSONEncoder()
        # this should have been set in CMSSWStepHelper along with
        # the pileup configuration
        url = helper.data.dbsUrl

        dbsReader = DBSReader(url)

        configDict = self._queryDbsAndGetPileupConfig(helper, dbsReader, fakeSites)

        # create JSON and save into a file
        json = encoder.encode(configDict)

        if not os.path.exists(stepPath):
            os.mkdir(stepPath)
        try:
            fileName = "%s/%s" % (stepPath, "pileupconf.json")
            f = open(fileName, 'w')
            f.write(json)
            f.close()
        except IOError:
            m = "Could not save pileup JSON configuration file: '%s'" % fileName
            raise RuntimeError(m)