def basicTest(): ''' This Test: - Instantiates a SCO. - Makes it persistent. - Calls a task with that PSCO -> IN parameter. - Waits for the task result. - Deletes the PSCO. ''' from pycompss.api.api import compss_wait_on o = mySO(10) print("BEFORE MAKEPERSISTENT: o.id: ", o.getID()) # Pesist the object to disk (it will be at /tmp/uuid.PSCO) o.makePersistent() print("AFTER MAKEPERSISTENT: o.id: ", o.getID()) v = simpleTask(o) v1 = compss_wait_on(v) # Remove the persisted object from disk (from /tmp/uuid.PSCO) o.deletePersistent() if v1 == 100: print("- Simple Test Python PSCOs: OK") return True else: print("- Simple Test Python PSCOs: ERROR") return False
def basic3Test(): ''' This Test: - Instantiates a SCO. - Makes it persistent. - Calls a task within that PSCO -> self INOUT - The task increments its value. - Calls it again. - Calls it again. - Waits for the self result. ''' from pycompss.api.api import compss_wait_on p = mySO(1) p.makePersistent() p.increment() p.increment() p.increment() p = compss_wait_on(p) print("p: " + str(p.get())) if p.get() == 4: print("- Complex Test Python PSCOs: OK") return True else: print("- Complex Test Python PSCOs: ERROR") return False
def basic2Test(): ''' This Test: - Instantiates a SCO. - Makes it persistent. - Calls a task with that PSCO -> IN parameter. - The task receives the PSCO and gets its value. - Instantiates another SCO and makes it persistent within the task. - Returns the new PSCO. - Calls another task with the input from the first one. - Gets the output PSCO and receives it as input. - Waits for the first task result. - Waits for the second task result. ''' from pycompss.api.api import compss_wait_on p = mySO(1) p.makePersistent() x = complexTask(p) y = simpleTask(x) res1 = compss_wait_on(x) res2 = compss_wait_on(y) # print "O.get must be 1 = ", p.get() # print "X.get must be 10 = ", res1.get() # print "Y must be 100 = ", res2 if p.get() == 1 and res1.get() == 10 and res2 == 100: print("- Complex Test Python PSCOs: OK") return True else: print("- Complex Test Python PSCOs: ERROR") return False
def complexTask(p): v = p.get() print("P: ", p) print("P.get: ", v) q = mySO(v * 10) q.makePersistent() print("Q: ", q) print("Q.get = ", q.get()) return q
def evaluateMakePersistentInTask(): ''' This Test checks what happens when a not persisted persistent object is passed an INOUT task parameter and made persistent within the task. ''' from pycompss.api.api import compss_wait_on o = mySO(10) makePersistentInTaskAsParameter(o) v = compss_wait_on(o) o.deletePersistent() if v.get() == 27: print("- Persitence of PSCOS in task as INOUT parameter: OK") return True else: print("- Persitence of PSCOS in task as INOUT parameter: ERROR") return False
def evaluateMakePersistentInTask2(): ''' This Test checks what happens when a not persisted persistent object is passed as IN task parameter, made persistent within the task, and returned. ''' from pycompss.api.api import compss_wait_on o = mySO(10) sco = makePersistentInTaskAsReturn(o) v = compss_wait_on(sco) v.deletePersistent() if v.get() == 37: print("- Persitence of PSCOS in task as return: OK") return True else: print("- Persitence of PSCOS in task as return: ERROR") return False