def testPSCOisCorrectlyReadAndRead(self): from pycompss.api.api import compss_wait_on as sync myPSCO = PSCO([1, 2, 3, 4, 5]) myPSCO.make_persistent() res = compute_sum(myPSCO) res = sync(res) res = sync(res) self.assertEqual(res, 15)
def testPSCOwithTasksPersist(self): from pycompss.api.api import compss_wait_on as sync obj = PSCOWithTasks("Hello world") obj.persist_notIsModifier() obj = sync(obj) self.assertTrue(obj.getID() is None) obj = PSCOWithTasks("Hello world2") obj.persist_isModifier() obj = sync(obj) self.assertTrue(obj.getID() is not None)
def testPSCOwithTasks(self): from pycompss.api.api import compss_wait_on as sync obj = PSCOWithTasks("Hello world") obj.make_persistent() initialContent = obj.get_content() obj.set_content("Goodbye world") modifiedContent = obj.get_content() iC = sync(initialContent) mC = sync(modifiedContent) self.assertEqual('Hello world', iC) self.assertEqual('Goodbye world', mC)
def testTaskPersister_inout(self): from pycompss.api.api import compss_wait_on as sync a = PSCO('Persisted in task') newId = psco_persister_inout(a) b = sync(a) newId = sync(newId) self.assertEqual(a.getID(), None) self.assertNotEqual(b.getID(), None) self.assertNotEqual(a.getID(), b.getID()) self.assertEqual(b.getID(), newId) from storage.api import getByID bn = getByID(newId) self.assertEqual(a.get_content(), b.get_content(), bn.get_content())
def testAutoModification(self): from pycompss.api.api import compss_wait_on as sync p = creator_task(0) p = inc(p) p = inc(p) p = sync(p) self.assertEqual(2, p.get_content())
def testTaskPersisterReturn(self): from pycompss.api.api import compss_wait_on as sync a = PSCO('Persisted in task') self.assertTrue(a.getID() is None) b = psco_persister_return(a) b = sync(b) self.assertTrue(b.getID() is not None) self.assertEqual('Persisted in task', b.get_content())
def testTaskPersister(self): from pycompss.api.api import compss_wait_on as sync a = PSCO('Persisted in task') ID = psco_persister(a) ID = sync(ID) from storage.api import getByID an = getByID(ID) self.assertEqual('Persisted in task', an.get_content())
def testMultiParam(self): from pycompss.api.api import compss_wait_on as sync a = PSCO('a') b = PSCO('b') a.make_persistent() b.make_persistent() l = selfConcat(a, b) l = sync(l) a, b = l self.assertEqual('aa', a.get_content()) self.assertEqual('bb', b.get_content())
def testPSCOisCorrectlyCreatedInsideTask(self): from pycompss.api.api import compss_wait_on as sync obj = list(range(100)) myPSCO = creator_task(obj) myPSCO = sync(myPSCO) self.assertEqual(list(range(100)), myPSCO.get_content())
def testPSCOisCorrectlyModifiedInsideTask(self): from pycompss.api.api import compss_wait_on as sync myPSCO = PSCO('Hello world') myPSCO = modifier_task(myPSCO) myPSCO = sync(myPSCO) self.assertEqual('Goodbye world', myPSCO.get_content())