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


Python Job.getBaggage方法代碼示例

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


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

示例1: testBaggage

# 需要導入模塊: from WMCore.DataStructs.Job import Job [as 別名]
# 或者: from WMCore.DataStructs.Job.Job import getBaggage [as 別名]
    def testBaggage(self):
        """
        _testBaggage_

        Verify that job baggage is persisted with the package.
        """
        package = JobPackage()

        for i in range(100):
            newJob = Job("Job%s" % i)
            newJob["id"] = i
            baggage = newJob.getBaggage()
            setattr(baggage, "thisJob", newJob["name"])
            setattr(baggage, "seed1", 11111111)
            setattr(baggage, "seed2", 22222222)
            setattr(baggage, "seed3", 33333333)
            setattr(baggage, "seed4", 44444444)
            setattr(baggage, "seed5", 55555555)
            package[i] = newJob

        package.save(self.persistFile)

        assert os.path.exists(self.persistFile), \
               "Error: Package file was never created."

        newPackage = JobPackage()
        newPackage.load(self.persistFile)

        # There is an extra key for the directory the package is stored in.
        assert len(newPackage.keys()) == 101, \
               "Error: Wrong number of jobs in package."

        for i in range(100):
            job = newPackage[i]
            assert job["id"] == i, \
                   "Error: Jobs has wrong ID."
            assert job["name"] == "Job%d" % i, \
                   "Error: Job has wrong name."
            jobBaggage = job.getBaggage()

            assert jobBaggage.thisJob == "Job%d" % i, \
                   "Error: Job baggage has wrong name."
            assert jobBaggage.seed1 == 11111111, \
                   "Error: Job baggee has wrong value for seed1."
            assert jobBaggage.seed2 == 22222222, \
                   "Error: Job baggee has wrong value for seed2."
            assert jobBaggage.seed3 == 33333333, \
                   "Error: Job baggee has wrong value for seed3."
            assert jobBaggage.seed4 == 44444444, \
                   "Error: Job baggee has wrong value for seed4."
            assert jobBaggage.seed5 == 55555555, \
                   "Error: Job baggee has wrong value for seed5."


        return
開發者ID:AndresTanasijczuk,項目名稱:WMCore,代碼行數:57,代碼來源:JobPackage_t.py

示例2: testA

# 需要導入模塊: from WMCore.DataStructs.Job import Job [as 別名]
# 或者: from WMCore.DataStructs.Job.Job import getBaggage [as 別名]
    def testA(self):
        """instantiate"""

        document = Document()
        document[u'pset_tweak_details'] = {}
        document[u'pset_tweak_details'][u'process'] = {}
        document[u'pset_tweak_details'][u'process'][u'RandomNumberGeneratorService'] = {}
        document[u'pset_tweak_details'][u'process'][u'RandomNumberGeneratorService'][u'seed1'] = {}
        document[u'pset_tweak_details'][u'process'][u'RandomNumberGeneratorService'][u'seed2'] = {}
        document[u'pset_tweak_details'][u'process'][u'RandomNumberGeneratorService'][u'seed3'] = {}

        document = self.database.commitOne(document)[0]
        seeder = ReproducibleSeeding(CouchUrl = self.testInit.couchUrl,
                                     CouchDBName = self.testInit.couchDbName,
                                     ConfigCacheDoc = document[u'id'])

        job = Job("testjob")
        seeder(job)
        baggage = job.getBaggage()
        seed1 = getattr(baggage.process.RandomNumberGeneratorService, "seed1", None)
        self.failUnless(seed1 != None)
開發者ID:AndrewLevin,項目名稱:WMCore,代碼行數:23,代碼來源:ReproducibleSeeding_t.py

示例3: JobTest

# 需要導入模塊: from WMCore.DataStructs.Job import Job [as 別名]
# 或者: from WMCore.DataStructs.Job.Job import getBaggage [as 別名]

#.........這裏部分代碼省略.........
        Verify that the Job::getFiles(type = "list") method returns the same
        files in the same order that they were passed in.
        """
        assert self.dummyJob.getFiles() == self.inputFiles, \
            "ERROR: Initial fileset does not match Job fileset"

        return

    def testGetFilesSet(self):
        """
        _testGetFilesSet_

        Verify that the Job::getFiles(type = "set") method returns the correct
        input files in the form of a set.
        """
        assert self.dummyJob.getFiles(type = "set") == set(self.inputFiles), \
            "ERROR: getFiles(type = 'set') does not work correctly."

        return

    def testGetFilesLFN(self):
        """
        _testGetFilesLFN_

        Verify that the Job::getFiles(type = "lfn") method returns the same
        files in the same order that they were passed in.
        """
        jobLFNs = self.dummyJob.getFiles(type = "lfn")

        goldenLFNs = []
        for file in self.inputFiles:
            goldenLFNs.append(file["lfn"])

        assert len(goldenLFNs) == len(jobLFNs), \
            "ERROR: Job has different number of files than input"

        for jobLFN in jobLFNs:
            assert jobLFN in goldenLFNs, \
                "ERROR: LFN missing from job."

        return

    def testAddFile(self):
        """
        _testAddFile_

        Verify that the Job::addFile() method works properly.
        """
        dummyFileAddFile = File("/tmp/dummyFileAddFileTest", 1234, 1, 2)
        self.dummyJob.addFile(dummyFileAddFile)

        assert dummyFileAddFile in self.dummyJob.getFiles(), \
            "ERROR: Couldn't add file to Job - addFile method error"

        return

    def testChangeState(self):
        """
        _testChangeState_

        Verify that the Job::changeState() method updates the state and the
        state time.
        """
        currentTime = time.time()
        self.dummyJob.changeState("created")

        assert self.dummyJob["state_time"] > currentTime - 1 and \
            self.dummyJob["state_time"] < currentTime + 1, \
            "ERROR: State time not updated on state change"

        assert self.dummyJob["state"] == "created", \
            "ERROR: Couldn't change Job state - changeState method error"

    def testChangeOutcome(self):
        """
        _testChangeOutcome_

        Verify that the Job::changeOutcome() method changes the final outcome
        of the job.
        """
        self.dummyJob.changeOutcome("success")

        assert self.dummyJob["outcome"] == "success", \
            "ERROR: Job outcome failed to update."

        return

    def testGetBaggage(self):
        """
        test that setting/accessing the Job Baggage ConfigSection works
        """
        self.dummyJob.addBaggageParameter("baggageContents", True)
        self.dummyJob.addBaggageParameter("trustPUSitelists", False)
        self.dummyJob.addBaggageParameter("skipPileupEvents", 20000)

        baggage = self.dummyJob.getBaggage()
        self.assertTrue(getattr(baggage, "baggageContents"))
        self.assertFalse(getattr(baggage, "trustPUSitelists"))
        self.assertEqual(getattr(baggage, "skipPileupEvents"), 20000)
        self.assertFalse(hasattr(baggage, "IDontExist"))
開發者ID:alexanderrichards,項目名稱:WMCore,代碼行數:104,代碼來源:Job_t.py


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