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


Python InMemoryCumulusSimulation.computeUsingSeveralWorkers方法代碼示例

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


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

示例1: test_sortVecOfVec

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def test_sortVecOfVec(self):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        text = """
            let values = []
            let ct = 500000

            values = [(ix % 100, Vector.range(40)) for ix in sequence(ct)]

            let res = cached`(#ExternalIoTask(#DistributedDataOperation(#Sort(values.paged))));

            let firstAreSorted = true;
            for ix in sequence(size(res)-1)
                if (res[ix][0] > res[ix+1][0])
                    firstAreSorted = false;

            size(res) == size(values) and firstAreSorted
            """

        result = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
            text,
            s3,
            1,
            timeout=TIMEOUT,
            memoryLimitMb=3000
            )

        self.assertTrue(result is not None)
        self.assertTrue(result.isResult(), result)
        self.assertTrue(result.asResult.result.pyval == True, result)
開發者ID:ufora,項目名稱:ufora,代碼行數:32,代碼來源:DistributedDataTasks_test.py

示例2: test_transposeToColumnMajor

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def test_transposeToColumnMajor(self):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        nRows = 100000
        nColumns = 50

        result, simulation = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
            self.transposeSetupScript(nRows, nColumns),
            s3, 1, timeout = 300, memoryLimitMb = 45 * 1024, threadCount = 30,
            returnSimulation = True, useInMemoryCache = False)

        try:
            self.assertTrue(result.isResult())

            rowMajor = result.asResult.result

            t0 = time.time()
            result = simulation.compute(
                self.transposeRowMajorToColumnMajorScript(nRows, nColumns),
                timeout = 500,
                rowMajor = rowMajor
                )
            totalTimeToReturnResult = time.time() - t0

            self.assertTrue(result.isResult())

            PerformanceTestReporter.recordTest(
                "algorithms.text.transposeRowMajorToColumnMajor.%srows_%scolumns" % (nRows, nColumns),
                totalTimeToReturnResult, None)

        finally:
            simulation.teardown()
開發者ID:vishnur,項目名稱:ufora,代碼行數:34,代碼來源:testTextManipulation.py

示例3: classSortingTest

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def classSortingTest(self, sz, useClass = True, machines=1, memory=1000):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        text = """
            let N = __size__;

            let C = if (__use_class__) { class { member x; } } else { Int64 }

            let values = Vector.range(N, C).paged;

            let s1 = cached`(#ExternalIoTask(#DistributedDataOperation(#Sort(values))))
            
            return size(s1) == N
            """.replace("__size__", str(sz)).replace("__use_class__", '1' if useClass else '0')

        result = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
            text,
            s3,
            machines,
            timeout=TIMEOUT,
            memoryLimitMb=memory
            )

        self.assertTrue(result is not None)
        self.assertTrue(result.isResult(), result)
        self.assertTrue(result.asResult.result.pyval == True, result)
開發者ID:WantonSoup,項目名稱:ufora,代碼行數:28,代碼來源:DistributedDataTasks_test.py

示例4: multiboxDataTasksSort

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def multiboxDataTasksSort(self, ct, workers=2, memoryLimit=100, pageSizeOverrideMB=1):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        text = """
            let N = __ct__;
            let aPrime = 503

            let toSort = Vector.range(N, { ((_ * _) % aPrime, _) }).paged;

            let result = cached`(#ExternalIoTask(#DistributedDataOperation(#Sort(toSort))))

            sorting.isSorted(result)
            """.replace("__ct__", str(ct))

        result = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
            text,
            s3,
            workers,
            timeout=TIMEOUT,
            memoryLimitMb=memoryLimit,
            pageSizeOverride=pageSizeOverrideMB*1024*1024
            )

        self.assertTrue(result is not None)
        self.assertTrue(result.isResult(), result)
        self.assertTrue(result.asResult.result.pyval == True, result)
開發者ID:WantonSoup,項目名稱:ufora,代碼行數:28,代碼來源:DistributedDataTasks_test.py

示例5: test_sortHeterogeneous

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def test_sortHeterogeneous(self):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        text = """
            let values = []
            let ct = 1000000
            for ix in sequence(ct)
                values = values :: ix :: Float64(ix)

            let sortedVals = cached`(#ExternalIoTask(#DistributedDataOperation(#Sort(values.paged))))

            let sortedAndHomogenous = fun(v) {
                for ix in sequence(size(v)-1)
                    if (v[ix] >= v[ix+1] or `TypeJOV(v[ix]) is not `TypeJOV(v[ix+1]))
                        throw (ix, v[ix], v[ix+1])
                return true;
                }
            
            if (size(sortedVals) != size(values))
                throw "expected " + String(size(values)) + ", not " + String(size(sortedVals))
            sortedAndHomogenous(sortedVals[,ct]) and 
                sortedAndHomogenous(sortedVals[ct,])
            """

        result = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
            text,
            s3,
            1,
            timeout=TIMEOUT,
            memoryLimitMb=1000
            )

        self.assertTrue(result is not None)
        self.assertTrue(result.isResult(), result)
        self.assertTrue(result.asResult.result.pyval == True, result)
開發者ID:WantonSoup,項目名稱:ufora,代碼行數:37,代碼來源:DistributedDataTasks_test.py

示例6: test_multiboxDataTasksTake_1

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def test_multiboxDataTasksTake_1(self):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        text = """
            let N = 10000000;
            let isPrime = fun(p) {
                let x = 2
                while (x*x <= p) {
                    if (p%x == 0)
                        return 0
                    x = x + 1
                    }
                return x
                }

            let takeFrom = Vector.range(N, isPrime).paged;
            let indices = Vector.range(N,fun(x) { (0, (x * 503) % N ) }).paged;

            cached`(#ExternalIoTask(#DistributedDataOperation(#Take(indices, takeFrom)))) ==
                indices ~~ { takeFrom[_[1]] }
            """

        result = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
            text,
            s3,
            2,
            timeout=TIMEOUT,
            memoryLimitMb=1000
            )

        self.assertTrue(result is not None)
        self.assertTrue(result.isResult(), result)
        self.assertTrue(result.asResult.result.pyval == True, result)
開發者ID:WantonSoup,項目名稱:ufora,代碼行數:35,代碼來源:DistributedDataTasks_test.py

示例7: basic_gpu_works_helper

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def basic_gpu_works_helper(self, function, onGPU=True):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        testingVectorText = "Vector.range(1024*4, {_+1000000})"

        text = """
            let f = fun(ct) {
                let res = 0.0
                let x = 1.0
                while (x < ct)
                    {
                    x = x + 1.0
                    res = res + `""" + function + """(x)
                    }
                res
                }"""

        if onGPU:
            text += """`CUDAVectorApply(f,""" + testingVectorText + """)"""
        else:
            text += testingVectorText + """ ~~ f"""

        res = InMemoryCumulusSimulation.computeUsingSeveralWorkers(text, s3, 1, timeout=120, threadCount=4)
        self.assertIsNotNone(res)
        self.assertTrue(res.isResult(), res)
開發者ID:Sandy4321,項目名稱:ufora,代碼行數:27,代碼來源:GpuTestCases.py

示例8: test_takeFromLargeObjects

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def test_takeFromLargeObjects(self):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        text = """
            let N = 100;

            //each string is 1 MB
            let takeFrom = [" " * 100 * 100 * 10 * 10 + " " * ix for ix in sequence(N)].paged;
            let indices = Vector.range(N,fun(x) { x }).paged;

            cached`(#ExternalIoTask(#DistributedDataOperation(#Take(indices, takeFrom))))
            """

        try:
            result, simulation = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
                text,
                s3,
                1,
                timeout=TIMEOUT,
                memoryLimitMb=1000,
                returnSimulation = True,
                pageSizeOverride = 1024 * 1024
                )

            self.assertTrue(result is not None)
            self.assertTrue(result.isResult(), result)

            for page in result.asResult.result.getVectorPageIds(simulation.getWorkerVdm(0)):
                self.assertLess(page.bytecount / 1024.0 / 1024.0, 2.0)
        finally:
            simulation.teardown()
開發者ID:WantonSoup,項目名稱:ufora,代碼行數:33,代碼來源:DistributedDataTasks_test.py

示例9: basicTaskPathwayTest

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def basicTaskPathwayTest(self, sz, machines=1, memory=1000):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        text = """
            let N = __size__;

            //let values = Vector.range(N,fun(x) { ((x * 503) % N, x) }).paged;
            let values = Vector.range(N).paged;

            let s1 = cached`(#ExternalIoTask(#DistributedDataOperation(#Sort(values))))
            let s2 = sorting.sort(values)

            if (size(s1) != size(s2))
                return 'wrong size: %s != %s'.format(size(s1), size(s2))
            for ix in sequence(size(s1))
                if (s1[ix] != s2[ix])
                    return 'not equal: index=%s. %s != %s'.format(ix, s1[ix], s2[ix])
            return true
            """.replace("__size__", str(sz))

        result = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
            text,
            s3,
            machines,
            timeout=TIMEOUT,
            memoryLimitMb=memory
            )

        self.assertTrue(result is not None)
        self.assertTrue(result.isResult(), result)
        self.assertTrue(result.asResult.result.pyval == True, result)
開發者ID:WantonSoup,項目名稱:ufora,代碼行數:33,代碼來源:DistributedDataTasks_test.py

示例10: test_vector_string_apply

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def test_vector_string_apply(self):
        #verify that the compiler doesn't crap out during many runs.
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        InMemoryCumulusSimulation.computeUsingSeveralWorkers("""
            let v = Vector.range(10000000)

            let v2 = v.apply(String)

            let v3 = v2.apply({_ + "a"})

            v3.sum(size)
            """,
            s3,
            4,
            timeout=240
            )
開發者ID:vishnur,項目名稱:ufora,代碼行數:19,代碼來源:CumulusWorkerDatasetLoadServiceIntegrationTest_test.py

示例11: gbmRegressionFittingTest

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def gbmRegressionFittingTest(self, nRows, nColumns, depth, nThreads, maxBoosts):
        testName = self.getTestName(nRows, nColumns, depth, maxBoosts, nThreads)

        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        result, simulation = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
                        self.dataGenerationScript(nRows, nColumns),
                        s3,
                        1,
                        timeout = 360,
                        memoryLimitMb = 30 * 1024,
                        threadCount = nThreads,
                        returnSimulation = True,
                        useInMemoryCache = False
                        )
        try:
            self.assertTrue(result.isResult())

            dfPredictors, dfResponse = result.asResult.result

            fitter = simulation.compute(
                self.regressionScript(depth, 1),
                timeout = 360,
                dfResponse = dfResponse,
                dfPredictors = dfPredictors
                ).asResult.result

            t0 = time.time()

            for nBoosts in range(1, maxBoosts):
                testName = self.getTestName(nRows, nColumns, depth, nBoosts, nThreads)

                predictions = simulation.compute(
                    "fitter.predictionsAndPseudoresiduals()",
                    timeout = 360,
                    fitter = fitter
                    ).asResult.result
                totalTimeToReturnResult = time.time() - t0

                PerformanceTestReporter.recordTest(
                    testName + "_predict", totalTimeToReturnResult, None)

                fitter = simulation.compute(
                    "fitter.nextGivenPredictions(predictions)",
                    timeout = 360,
                    fitter = fitter,
                    predictions = predictions
                    ).asResult.result
                totalTimeToReturnResult = time.time() - t0

                PerformanceTestReporter.recordTest(
                    testName, totalTimeToReturnResult, None)

        finally:
            simulation.teardown()
開發者ID:Sandy4321,項目名稱:ufora,代碼行數:57,代碼來源:testGbmRegression.py

示例12: test_disk_scans

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def test_disk_scans(self):
        s3 = ActualS3Interface.ActualS3InterfaceFactory()
        objectStore = S3ObjectStore.S3ObjectStore(
            s3,
            Setup.config().userDataS3Bucket,
            prefix="test_object_cache/"
            )

        _, simulation = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
            "1+1",
            s3,
            1,
            memoryLimitMb=1 * 1024,
            threadCount=30,
            returnSimulation=True,
            ioTaskThreadOverride=8,
            objectStore=objectStore,
            useInMemoryCache=False  #use an actual disk cache for this
            )

        try:
            gigabytes = 8

            t0 = time.time()

            resultVectors = []
            for ix in range(gigabytes):
                result = simulation.compute("Vector.range(125000000 + %s)" % ix, timeout=120)
                resultVectors.append(result.asResult.result)

            t1 = time.time()

            intResults = []
            for vec in resultVectors:
                result = simulation.compute("v.sum()", timeout = 120, v=vec)
                intResults.append(result.asResult.result.pyval)


            self.assertTrue(len(intResults) == gigabytes)

            PerformanceTestReporter.recordTest(
                "python.BigBox.Disk.Write.10GB",
                t1 - t0,
                None
                )

            PerformanceTestReporter.recordTest(
                "python.BigBox.Disk.WriteAndScan.%sGB" % gigabytes,
                time.time() - t0,
                None
                )
        finally:
            simulation.teardown()
開發者ID:Sandy4321,項目名稱:ufora,代碼行數:55,代碼來源:testBigboxDiskPerf.py

示例13: takeTest

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
        def takeTest(indexExpr):
            result = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
                takeText.replace("__indices__", indexExpr),
                s3,
                1,
                timeout=TIMEOUT,
                memoryLimitMb=1000
                )

            self.assertTrue(result is not None)
            self.assertTrue(result.isResult(), result)
            self.assertTrue(result.asResult.result.pyval == True, result)
開發者ID:WantonSoup,項目名稱:ufora,代碼行數:14,代碼來源:DistributedDataTasks_test.py

示例14: largeDatasetJoinTest

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def largeDatasetJoinTest(self, mbOfData, columns, threads, machineCount, ratio = .5):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        t0 = time.time()

        result, simulation = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
                        self.dataGenerationScript(mbOfData, columns),
                        s3,
                        machineCount,
                        timeout = 360,
                        memoryLimitMb = mbOfData / ratio / machineCount,
                        #channelThroughputMBPerSecond = 100.0,
                        threadCount = threads,
                        returnSimulation = True,
                        useInMemoryCache = False,
                        disableEventHandler = True
                        )

        try:
            self.assertTrue(result.isResult())

            data = result.asResult.result

            joinScript = """
                    let leftDF = dataframe.DataFrame(data[,size(data)/2])
                    let rightDF = dataframe.DataFrame(data[size(data)/2,])

                    size(leftDF.join(rightDF, on: "C0", how: `outer, chunkSize: 1000000, areSorted:true))
                    """

            t0 = time.time()
            result = simulation.compute(
                joinScript,
                timeout=1080,
                data=data
                )
            totalTimeToReturnResult = time.time() - t0

            logging.info("Total time to join: %s", totalTimeToReturnResult)

            self.assertTrue(result.isResult(), result)

            PerformanceTestReporter.recordTest(
                "algorithms.Join.inMemory_%sMB_%scols_%sthreads_%smachines" %
                    (mbOfData, columns,threads,machineCount),
                totalTimeToReturnResult,
                None
                )
        finally:
            dfResponse = None
            dfPredictors = None
            result = None
            simulation.teardown()
開發者ID:WantonSoup,項目名稱:ufora,代碼行數:55,代碼來源:MultimachineJoinSimulation_test.py

示例15: test_importanceSampling

# 需要導入模塊: from ufora.cumulus.test import InMemoryCumulusSimulation [as 別名]
# 或者: from ufora.cumulus.test.InMemoryCumulusSimulation import computeUsingSeveralWorkers [as 別名]
    def test_importanceSampling(self):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        result = InMemoryCumulusSimulation.computeUsingSeveralWorkers(
            importanceSampling,
            s3,
            4,
            memoryLimitMb = 1000,
            timeout=240,
            useInMemoryCache = False
            )

        self.assertTrue(result.isResult())
開發者ID:WantonSoup,項目名稱:ufora,代碼行數:15,代碼來源:InMemoryImportanceSamplingTest_test.py


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