def job_start(self, params): work_dir = params['working_directory'] self.machine = self.get_machine() use_machine(self.machine) self.cdir = CreateDirectory("remote", work_dir) trans = TransferFiles("remote", params['input_directory'], work_dir, dependencies=[self.cdir]) self.job = PBSScript("remote", params['command'], work_dir, dependencies=[trans], **params['additional_arguments']) self.job.run() ret = self.job._ret if ret: try: job_id = int(ret.split('\n')[0]) except ValueError: end_machine() raise ModuleError(self, "Error submitting job: %s" % ret) self.set_job_machine(params, self.machine) return params
def job_start(self, params): work_dir = params['working_directory'] self.machine = self.get_machine() use_machine(self.machine) self.cdir = CreateDirectory("remote", work_dir) trans = TransferFiles("remote", params['input_directory'], work_dir, dependencies = [self.cdir]) self.job = PBSScript("remote", params['command'], work_dir, dependencies = [trans], **params['additional_arguments']) self.job.run() ret = self.job._ret if ret: try: job_id = int(ret.split('\n')[0]) except ValueError: end_machine() raise ModuleError(self, "Error submitting job: %s" % ret) self.set_job_machine(params, self.machine) return params
class RunPBSScript(RQModule): """ Run a pbs script by submitting it to a PBS scheduler """ _input_ports = [('machine', Machine), ('command', '(edu.utah.sci.vistrails.basic:String)', True), ('working_directory', '(edu.utah.sci.vistrails.basic:String)'), ('input_directory', '(edu.utah.sci.vistrails.basic:String)'), ('processes', '(edu.utah.sci.vistrails.basic:Integer)', True), ('time', '(edu.utah.sci.vistrails.basic:String)', True), ('mpi', '(edu.utah.sci.vistrails.basic:Boolean)', True), ('threads', '(edu.utah.sci.vistrails.basic:Integer)', True), ('memory', '(edu.utah.sci.vistrails.basic:String)', True), ('diskspace', '(edu.utah.sci.vistrails.basic:String)', True), ] _output_ports = [('stdout', '(edu.utah.sci.vistrails.basic:String)'), ('stderr', '(edu.utah.sci.vistrails.basic:String)'), ] job = None def job_read_inputs(self): d = {} if not self.has_input('command'): raise ModuleError(self, "No command specified") d['command'] = self.get_input('command').strip() d['working_directory'] = self.get_input('working_directory') \ if self.has_input('working_directory') else '.' if not self.has_input('input_directory'): raise ModuleError(self, "No input directory specified") d['input_directory'] = self.get_input('input_directory').strip() d['additional_arguments'] = {'processes': 1, 'time': -1, 'mpi': False, 'threads': 1, 'memory':-1, 'diskspace': -1} for k in d['additional_arguments']: if self.has_input(k): d['additional_arguments'][k] = self.get_input(k) return d def job_start(self, params): work_dir = params['working_directory'] self.machine = self.get_machine() use_machine(self.machine) self.cdir = CreateDirectory("remote", work_dir) trans = TransferFiles("remote", params['input_directory'], work_dir, dependencies = [self.cdir]) self.job = PBSScript("remote", params['command'], work_dir, dependencies = [trans], **params['additional_arguments']) self.job.run() ret = self.job._ret if ret: try: job_id = int(ret.split('\n')[0]) except ValueError: end_machine() raise ModuleError(self, "Error submitting job: %s" % ret) self.set_job_machine(params, self.machine) return params def job_get_handle(self, params): if not self.job: self.job_start(params) return self.job def job_finish(self, params): job_info = self.job.get_job_info() if job_info: self.annotate({'job_info': job_info}) # copies the created files to the client get_result = TransferFiles("local", params['input_directory'], params['working_directory'], dependencies = [self.cdir]) get_result.run() end_machine() params['stdout'] = self.job.standard_output() params['stderr'] = self.job.standard_error() return params def job_set_results(self, params): self.set_output('stdout', params['stdout']) self.set_output('stderr', params['stderr'])
class RunPBSScript(RQModule): """ Run a pbs script by submitting it to a PBS scheduler """ _input_ports = [ ('machine', Machine), ('command', '(edu.utah.sci.vistrails.basic:String)', True), ('working_directory', '(edu.utah.sci.vistrails.basic:String)'), ('input_directory', '(edu.utah.sci.vistrails.basic:String)'), ('processes', '(edu.utah.sci.vistrails.basic:Integer)', True), ('time', '(edu.utah.sci.vistrails.basic:String)', True), ('mpi', '(edu.utah.sci.vistrails.basic:Boolean)', True), ('threads', '(edu.utah.sci.vistrails.basic:Integer)', True), ('memory', '(edu.utah.sci.vistrails.basic:String)', True), ('diskspace', '(edu.utah.sci.vistrails.basic:String)', True), ] _output_ports = [ ('stdout', '(edu.utah.sci.vistrails.basic:String)'), ('stderr', '(edu.utah.sci.vistrails.basic:String)'), ] job = None def job_read_inputs(self): d = {} if not self.has_input('command'): raise ModuleError(self, "No command specified") d['command'] = self.get_input('command').strip() d['working_directory'] = self.get_input('working_directory') \ if self.has_input('working_directory') else '.' if not self.has_input('input_directory'): raise ModuleError(self, "No input directory specified") d['input_directory'] = self.get_input('input_directory').strip() d['additional_arguments'] = { 'processes': 1, 'time': -1, 'mpi': False, 'threads': 1, 'memory': -1, 'diskspace': -1 } for k in d['additional_arguments']: if self.has_input(k): d['additional_arguments'][k] = self.get_input(k) return d def job_start(self, params): work_dir = params['working_directory'] self.machine = self.get_machine() use_machine(self.machine) self.cdir = CreateDirectory("remote", work_dir) trans = TransferFiles("remote", params['input_directory'], work_dir, dependencies=[self.cdir]) self.job = PBSScript("remote", params['command'], work_dir, dependencies=[trans], **params['additional_arguments']) self.job.run() ret = self.job._ret if ret: try: job_id = int(ret.split('\n')[0]) except ValueError: end_machine() raise ModuleError(self, "Error submitting job: %s" % ret) self.set_job_machine(params, self.machine) return params def job_get_handle(self, params): if not self.job: self.job_start(params) return self.job def job_finish(self, params): job_info = self.job.get_job_info() if job_info: self.annotate({'job_info': job_info}) # copies the created files to the client get_result = TransferFiles("local", params['input_directory'], params['working_directory'], dependencies=[self.cdir]) get_result.run() end_machine() params['stdout'] = self.job.standard_output() params['stderr'] = self.job.standard_error() return params def job_set_results(self, params): self.set_output('stdout', params['stdout']) self.set_output('stderr', params['stderr'])