def launch(self,jobdir,job_email=None,job_email_options='bae'): cmds = self.commands(jobdir) pbsfile = self.pbs_path() outlog = self.outlog_path() pbs = PBS(pbsfile,outlog,cmds,self.processor.walltime_str,self.processor.memreq_mb,self.processor.ppn,job_email,job_email_options) pbs.write() jobid = pbs.submit() if jobid == '' or jobid == '0': # TODO: raise exception print('ERROR:failed to launch job on cluster') return False else: self.set_status(JOB_RUNNING) self.set_jobid(jobid) self.set_jobstartdate_today() #save record on redcap for the job that has been launch project=self.assessor_label.split('-x-')[0] SM_name=self.get_processor_name() data,record_id=XnatUtils.create_record_redcap(project, SM_name) run=XnatUtils.save_job_redcap(data,record_id) if not run: print(' ->ERROR: did not send the job to redcap for jobID <'+str(jobid)+'>: '+record_id) return True
def launch(self, jobdir, job_email=None, job_email_options='bae'): cmds = self.commands(jobdir) pbsfile = self.pbs_path() outlog = self.outlog_path() pbs = PBS(pbsfile, outlog, cmds, self.processor.walltime_str, self.processor.memreq_mb, self.processor.ppn, job_email, job_email_options) pbs.write() jobid = pbs.submit() if jobid == '' or jobid == '0': # TODO: raise exception print('ERROR:failed to launch job on cluster') return False else: self.set_status(JOB_RUNNING) self.set_jobid(jobid) self.set_jobstartdate_today() #save record on redcap for the job that has been launch project = self.assessor_label.split('-x-')[0] SM_name = self.get_processor_name() data, record_id = XnatUtils.create_record_redcap(project, SM_name) run = XnatUtils.save_job_redcap(data, record_id) if not run: print(' ->ERROR: did not send the job to redcap for jobID <' + str(jobid) + '>: ' + record_id) return True
def launch( self, jobdir, job_email=None, job_email_options=DEFAULT_EMAIL_OPTS, xnat_host=None, writeonly=False, pbsdir=None ): """ Method to launch a job on the grid :param jobdir: absolute path to where the data will be stored on the node :param job_email: who to email if the job fails :param job_email_options: grid-specific job email options (e.g., fails, starts, exits etc) :param xnat_host: set the XNAT_HOST in the PBS job :param writeonly: write the job files without submitting them :param pbsdir: folder to store the pbs file :raises: cluster.ClusterLaunchException if the jobid is 0 or empty as returned by pbs.submit() method :return: True if the job failed """ cmds = self.commands(jobdir) pbsfile = self.pbs_path(writeonly, pbsdir) outlog = self.outlog_path() pbs = PBS( pbsfile, outlog, cmds, self.processor.walltime_str, self.processor.memreq_mb, self.processor.ppn, job_email, job_email_options, xnat_host, ) pbs.write() if writeonly: mes_format = """ filepath: {path}""" LOGGER.info(mes_format.format(path=pbsfile)) return True else: jobid = pbs.submit() if jobid == "" or jobid == "0": LOGGER.error("failed to launch job on cluster") raise cluster.ClusterLaunchException else: self.set_launch(jobid) return True
def build_task(self, csess, jobdir, job_email=None, job_email_options=DEFAULT_EMAIL_OPTS, xnat_host=None): """ Method to build a job """ (old_proc_status,old_qc_status,_) = self.get_statuses() try: cmds = self.build_commands(csess, jobdir) batch_file = self.batch_path() outlog = self.outlog_path() batch = PBS(batch_file, outlog, cmds, self.processor.walltime_str, self.processor.memreq_mb, self.processor.ppn, job_email, job_email_options, xnat_host) LOGGER.info('writing:' + batch_file) batch.write() new_proc_status = JOB_RUNNING new_qc_status = JOB_PENDING except NeedInputsException as e: new_proc_status = NEED_INPUTS new_qc_status = e.value except NoDataException as e: new_proc_status = NO_DATA new_qc_status = e.value if new_proc_status != old_proc_status or new_qc_status != old_qc_status: self.set_proc_and_qc_status(new_proc_status, new_qc_status) return (new_proc_status,new_qc_status)
def launch(self, jobdir, job_email=None, job_email_options=DAX_SETTINGS.get_email_opts(), xnat_host=None, writeonly=False, pbsdir=None): """ Method to launch a job on the grid :param jobdir: absolute path to where the data will be stored on the node :param job_email: who to email if the job fails :param job_email_options: grid-specific job email options (e.g., fails, starts, exits etc) :param xnat_host: set the XNAT_HOST in the PBS job :param writeonly: write the job files without submitting them :param pbsdir: folder to store the pbs file :raises: cluster.ClusterLaunchException if the jobid is 0 or empty as returned by pbs.submit() method :return: True if the job failed """ cmds = self.commands(jobdir) pbsfile = self.pbs_path(writeonly, pbsdir) outlog = self.outlog_path() outlog_dir = os.path.dirname(outlog) mkdirp(outlog_dir) pbs = PBS(pbsfile, outlog, cmds, self.processor.walltime_str, self.processor.memreq_mb, self.processor.ppn, job_email, job_email_options, xnat_host) pbs.write() if writeonly: mes_format = """ filepath: {path}""" LOGGER.info(mes_format.format(path=pbsfile)) return True else: jobid = pbs.submit() if jobid == '' or jobid == '0': LOGGER.error('failed to launch job on cluster') raise cluster.ClusterLaunchException else: self.set_launch(jobid) return True