def Queue(self, run_before=False): """ Queue for Labelit. """ if self.verbose: self.logger.debug('LabelitPP::Queue') try: timed_out = False timer = 0 rerun = False jobs = self.pp_jobs.keys() if jobs != ['None']: counter = len(jobs) while counter != 0: for job in jobs: if job.is_alive() == False: jobs.remove(job) del self.pids[self.pp_jobs[job]] job = self.postprocessLabelitPP(self.pp_jobs[job]) if job == 'kill': timed_out = True rerun = True counter = 0 break else: counter -= 1 time.sleep(0.2) timer += 0.2 if self.output == None: if self.verbose: if round(timer % 1, 1) in (0.0, 1.0): print 'Waiting for Labelit.precession_photo to finish %s seconds' % timer if self.labelitpp_timer: if timer >= self.labelitpp_timer: timed_out = True #Check folders to see why it timed out. self.clean = False break if timed_out: if self.verbose: self.logger.debug('Labelitpp timed out.') print 'Labelitpp timed out.' for pid in self.pids.values(): if self.cluster_use: #Utils.killChildrenCluster(self,pid) BLspec.killChildrenCluster(self, pid) else: Utils.killChildren(self, pid) if rerun: if run_before == False: self.pp_jobs = {} self.pids = {} self.processLabelitPP() self.Queue(True) #if self.verbose: self.logger.debug('LabelitPP finished.') except: self.logger.exception('**Error in LabelitPP.Queue**')
def Queue(self,run_before=False): """ Queue for Labelit. """ if self.verbose: self.logger.debug('LabelitPP::Queue') try: timed_out = False timer = 0 rerun = False jobs = self.pp_jobs.keys() if jobs != ['None']: counter = len(jobs) while counter != 0: for job in jobs: if job.is_alive() == False: jobs.remove(job) del self.pids[self.pp_jobs[job]] job = self.postprocessLabelitPP(self.pp_jobs[job]) if job == 'kill': timed_out = True rerun = True counter = 0 break else: counter -= 1 time.sleep(0.2) timer += 0.2 if self.output == None: if self.verbose: if round(timer%1,1) in (0.0,1.0): print 'Waiting for Labelit.precession_photo to finish %s seconds'%timer if self.labelitpp_timer: if timer >= self.labelitpp_timer: timed_out = True #Check folders to see why it timed out. self.clean = False break if timed_out: if self.verbose: self.logger.debug('Labelitpp timed out.') print 'Labelitpp timed out.' for pid in self.pids.values(): if self.cluster_use: #Utils.killChildrenCluster(self,pid) BLspec.killChildrenCluster(self,pid) else: Utils.killChildren(self,pid) if rerun: if run_before == False: self.pp_jobs = {} self.pids = {} self.processLabelitPP() self.Queue(True) #if self.verbose: self.logger.debug('LabelitPP finished.') except: self.logger.exception('**Error in LabelitPP.Queue**')
def Queue(self): """ queue system. """ if self.verbose: self.logger.debug('AutoStats::Queue') try: timed_out = False timer = 0 jobs = self.jobs_output.keys() if jobs != ['None']: counter = len(jobs) while counter != 0: for job in jobs: if job.is_alive() == False: if self.jobs_output[job] == 'xtriage': self.postprocessXtriage() if self.jobs_output[job] == 'molrep': self.postprocessMolrep() if self.jobs_output[job] == 'NCS': self.postprocessNCS() jobs.remove(job) del self.pids[self.jobs_output[job]] counter -= 1 time.sleep(0.2) timer += 0.2 """ if self.verbose: if round(timer%1,1) in (0.0,1.0): print 'Waiting for AutoStat jobs to finish '+str(timer)+' seconds' """ if self.stats_timer: if timer >= self.stats_timer: timed_out = True break if timed_out: if self.verbose: self.logger.debug('AutoStat timed out.') print 'AutoStat timed out.' for pid in self.pids.values(): #jobs are not sent to cluster Utils.killChildren(self,pid) for job in jobs: if self.jobs_output[job] == 'xtriage': self.postprocessXtriage() if self.jobs_output[job] == 'molrep': self.postprocessMolrep() if self.jobs_output[job] == 'NCS': self.postprocessNCS() if self.verbose: self.logger.debug('AutoStats Queue finished.') except: self.logger.exception('**ERROR in Autostat.Queue**')
def checkSolution(self): """ Check if solution is found. If not alter input and rerun. """ if self.verbose: self.logger.debug('AutoMolRep::checkSolution') try: solution = False keys = self.phaser_results.keys() keys0 = [key for key in keys if key[-1] == '0'] keys1 = [key for key in keys if key[-1] == '1'] for key in keys0: sg = self.phaser_results[key].get('AutoMR results').get('AutoMR sg') if sg not in ('No solution','Timed out','NA'): solution = True if solution: #Kill the jobs and remove the results for k in keys1: if self.cluster_use: #Utils.killChildrenCluster(self,self.output['pids'][k]) BLspec.killChildrenCluster(self,self.output['pids'][k]) else: Utils.killChildren(self,self.output['pids'][k]) del self.phaser_results[k] else: self.run_before = True #Remove results from quick run if no solution found. for k in keys0: del self.phaser_results[k] #Run the full Phaser jobs. if self.cluster_use == False: self.preprocessPhaser() else: self.phaser_jobs = keys1 self.postprocess(False) self.Queue() except: self.logger.exception('**ERROR in AutoMolRep.checkSolution**')
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**')