Esempio n. 1
0
 def wait_on_job(self, job_id):
     if self.cluster_type == "bsub":
         print "Waiting on %s.. (started wait @ %s)" \
             %(job_id,
               time.strftime("%x, %X"))
         Mybsub.waitUntilDone(job_id)
         print "  - Completed at %s" %(time.strftime("%x, %X"))
         return True
     elif self.cluster_type == "qsub":
         print "Waiting on %s.. (started wait @ %s)" \
             %(job_id,
               time.strftime("%x, %X"))
         Mypbm.waitUntilDone(job_id)
         print "  - Completed at %s" %(time.strftime("%x, %X"))
         return True
     elif self.cluster_type == "none":
         self.jobs[job_id].wait()
     else:
         raise Exception, "Not implemented yet."
Esempio n. 2
0
    def launch_job(self, cmd, job_name,
                   ppn=1,
                   unless_exists=None,
                   bsub_queue_type="normal"):
        """
        Launch job on cluster and return a job id.

        if unless_exists flag is given, do not execute command
        if the given filename path exists.
        
        Wrapper to Mysge/Mypbm/Mybsub.
        """
        job_id = None
        script_options = {}
        if (unless_exists is not None) and \
            os.path.isfile(unless_exists):
            print "launch_job: SKIPPING %s since %s exists." \
                %(cmd, unless_exists)
            return job_id
        if self.cluster_type == "bsub":
            # Use bsub for submission
            job_id = Mybsub.launchJob(cmd, job_name,
                                      script_options,
                                      self.output_dir,
                                      queue_type=bsub_queue_type,
                                      ppn=ppn)
        elif self.cluster_type == "qsub":
            # Use qsub for submission
            job_id = Mypbm.launchJob(cmd, job_name,
                                     script_options,
                                     self.output_dir,
                                     queue_type="long",
                                     ppn=ppn)
        elif self.cluster_type == "none":
            # Use local machine (multi-cores)
            p = subprocess.Popen(cmd, shell=True)
            self.jobs[self._curjobid] = p
            job_id = self._curjobid
            self._curjobid += 1
        if job_id is None:
            print "WARNING: Job %s not submitted." %(job_name)
        return job_id