Source

pythongrid / example.py

Diff from to

File example.py

 import sys
 import getopt
 import pythongrid
-from pythongrid import KybJob, Usage
+from pythongrid import Job, Usage
 from pythongrid import process_jobs, submit_jobs, collect_jobs, get_status
 import time
 
     for input in inputvec:
         # We need to use the full identifier
         # such that the module name is explicit.
-        job = KybJob(example.computeFactorial, input) 
-        job.h_vmem="300M"
-        
+        job = Job(example.computeFactorial, input, cleanup=False) 
         jobs.append(job)
-        
 
     return jobs
 
 
 def runExample():
-    '''
+    """
     execute example    
-    ''' 
-
-    print "====================================="
-    print "======  Local Multithreading  ======="
-    print "====================================="
-    print ""
-    print ""
-
-    print "generating function jobs"
-
+    """ 
+    print "===  Local Multithreading  ==="
     functionJobs = makeJobs()
 
     print "output ret field in each job before multithreaded computation"
     for (i, job) in enumerate(functionJobs):
         print "Job #", i, "- ret: ", job.ret
 
-    print ""
     print "executing jobs on local machine using 3 threads"
     if not pythongrid.multiprocessing_present:
         print 'multiprocessing not found, serial computation'
-    print ""
-
 
     processedFunctionJobs = process_jobs(functionJobs, local=True, maxNumThreads=3)
-    
 
     print "ret fields AFTER execution on local machine"
     for (i, job) in enumerate(processedFunctionJobs):
         print "Job #", i, "- ret: ", str(job.ret)[0:10]
     
     
-    print ""
-    print ""
-    print "====================================="
-    print "========   Submit and Wait   ========"
-    print "====================================="
-    print ""
-    print ""
-
+    print "===  Submit and Wait  ==="
     functionJobs = makeJobs()
 
     print "output ret field in each job before sending it onto the cluster"
     for (i, job) in enumerate(functionJobs):
         print "Job #", i, "- ret: ", job.ret
 
-    print ""
     print "sending function jobs to cluster"
-    print ""
-
     processedFunctionJobs = process_jobs(functionJobs)
 
     print "ret fields AFTER execution on cluster"
     for (i, job) in enumerate(processedFunctionJobs):
         print "Job #", i, "- ret: ", str(job.ret)[0:10]
 
+    return
 
-    print ""
-    print ""
-    print "====================================="
-    print "=======  Submit and Forget   ========"
-    print "====================================="
-    print ""
-    print ""
-
-
-    print 'demo session'
+    print "===  Submit and Forget  ==="
     myjobs = makeJobs()
 
     (sid, jobids) = submit_jobs(myjobs)
     for (i, job) in enumerate(retjobs):
         print "Job #", i, "- ret: ", str(job.ret)[0:10]
 
-    print '--------------'
-
 
 def computeFactorial(n):
     """