Ejemplo n.º 1
0
 def launchJob(inp2,k):
   """
   Launch Phaser job on cluster and pass back the process job and pid.
   """
   Utils.folders(self,k)
   #Remove leftover file if rerunning.
   if os.path.exists('adf.com'):
     os.system('rm -rf adf.com')
   queue = Queue()
   j = Process(target=RunPhaser,args=(inp2,queue,self.logger))
   j.start()
   queue.get()#For the log I am not using
   if self.output['jobs'] == None:
     self.output['jobs'] = {j:k}
     self.output['pids'] = {k:queue.get()}
   else:
     self.output['jobs'].update({j:k})
     self.output['pids'].update({k:queue.get()})
   #Setup initial results for all running jobs.
   self.phaser_results[k] = { 'AutoMR results' : Parse.setPhaserFailed('Still running')}
Ejemplo n.º 2
0
  def Queue(self):
    """
    queue system.
    """
    if self.verbose:
      self.logger.debug('AutoMolRep::Queue')
    try:
      timed_out = False
      timer = 0
      jobs = self.output['jobs'].keys()
      #set which jobs to watch.
      if self.run_before:
        jobs = [job for job in jobs if self.output['jobs'][job][-1] == '1']
      else:
        jobs = [job for job in jobs if self.output['jobs'][job][-1] == '0']
      counter = len(jobs)
      while counter != 0:
        for job in jobs:
          if job.is_alive() == False:
            jobs.remove(job)
            if self.verbose:
              self.logger.debug('Finished Phaser on %s'%self.output['jobs'][job])
            Utils.folders(self,self.output['jobs'][job])
            if self.adf:
              if os.path.exists('adf.com'):
                del self.output['pids'][self.output['jobs'][job]]
                counter -= 1
              else:
                key = self.output['jobs'].pop(job)
                p = self.postprocessPhaser(key)
                if p == 'ADF':
                  #Calculate ADF map.
                  adf = Process(target=Utils.calcADF,name='ADF%s'%key,args=(self,key))
                  adf.start()
                  jobs.append(adf)
                  self.output['jobs'][adf] = key
                else:
                  counter -= 1
                self.postprocess(False)
            else:
              self.postprocessPhaser(self.output['jobs'][job])
              del self.output['pids'][self.output['jobs'][job]]
              self.postprocess(False)
              counter -= 1
        time.sleep(0.2)
        timer += 0.2
        if self.verbose:
          number = round(timer%1,1)
          if number in (0.0,1.0):
            print 'Waiting for Phaser to finish %s seconds'%timer
        if self.phaser_timer:
          if timer >= self.phaser_timer:
            timed_out = True
            break
      if timed_out:
        self.logger.debug('Phaser timed out.')
        print 'Phaser timed out.'
        for job in jobs:
          self.phaser_results[self.output['jobs'][job]] = {'AutoMR results':Parse.setPhaserFailed('Timed out')}
          if self.cluster_use:
            #Utils.killChildrenCluster(self,self.output['pids'][self.output['jobs'][job]])
            BLspec.killChildrenCluster(self,self.output['pids'][self.output['jobs'][job]])
          else:
            Utils.killChildren(self,self.output['pids'][self.output['jobs'][job]])
      #Check if solution has been found.
      if self.run_before == False:
        self.checkSolution()
      self.logger.debug('Phaser finished.')

    except:
      self.logger.exception('**ERROR in AutoMolRep.Queue**')