def cancel(self): super().cancel() # Recreate the full job id jobid = str(self._jobid) if self._pbs_server: jobid += '.' + self._pbs_server getlogger().debug('cancelling job (id=%s)' % jobid) self._run_command('qdel %s' % jobid, settings().job_submit_timeout)
def submit(self): cmd = 'sbatch %s' % self.script_filename completed = _run_strict(cmd, timeout=settings().job_submit_timeout) jobid_match = re.search(r'Submitted batch job (?P<jobid>\d+)', completed.stdout) if not jobid_match: raise JobError( 'could not retrieve the job id of the submitted job') self._jobid = int(jobid_match.group('jobid'))
def wait(self): super().wait() # Quickly return in case we have finished already if self._state in self._completion_states: return intervals = itertools.cycle(settings().job_poll_intervals) self._update_state() while self._state not in self._completion_states: time.sleep(next(intervals)) self._update_state()
def submit(self): # `-o` and `-e` options are only recognized in command line by the PBS # Slurm wrappers. cmd = 'qsub -o %s -e %s %s' % (self.stdout, self.stderr, self.script_filename) completed = self._run_command(cmd, settings().job_submit_timeout) jobid_match = re.search(r'^(?P<jobid>\S+)', completed.stdout) if not jobid_match: raise JobError('could not retrieve the job id ' 'of the submitted job') jobid, *info = jobid_match.group('jobid').split('.', maxsplit=2) self._jobid = int(jobid) if info: self._pbs_server = info[0]
def wait(self, job): # Quickly return in case we have finished already if slurm_state_completed(job.state): if self.is_array(job): self._merge_files(job) return intervals = itertools.cycle(settings().job_poll_intervals) self._update_state(job) while not slurm_state_completed(job.state): time.sleep(next(intervals)) self._update_state(job) if self.is_array(job): self._merge_files(job)
def wait(self, job): # Quickly return in case we have finished already if slurm_state_completed(job.state): if self.is_array(job): self._merge_files(job) return intervals = itertools.cycle(settings().job_poll_intervals) self._update_state(job) while not slurm_state_completed(job.state): if job.max_pending_time and slurm_state_pending(job.state): if datetime.now() - self._submit_time >= job.max_pending_time: self.cancel(job) raise JobError('maximum pending time exceeded', jobid=job.jobid) time.sleep(next(intervals)) self._update_state(job) if self.is_array(job): self._merge_files(job)
def cancel(self): super().cancel() getlogger().debug('cancelling job (id=%s)' % self._jobid) _run_strict('scancel %s' % self._jobid, timeout=settings().job_submit_timeout) self._is_cancelling = True
def wait(self): super().wait() intervals = itertools.cycle(settings().job_poll_intervals) while not self.finished(): time.sleep(next(intervals))
def wait(self, job): intervals = itertools.cycle(settings().job_poll_intervals) while not self.finished(job): time.sleep(next(intervals))