##// END OF EJS Templates
More changes to the PBS batch cluster.
Brian Granger -
Show More
@@ -231,7 +231,7 b' class BatchEngineSet(object):'
231 self.template_file = template_file
231 self.template_file = template_file
232 self.context = {}
232 self.context = {}
233 self.context.update(kwargs)
233 self.context.update(kwargs)
234 self.batch_file = 'batch-script'
234 self.batch_file = self.template_file+'-run'
235
235
236 def parse_job_id(self, output):
236 def parse_job_id(self, output):
237 m = re.match(self.job_id_regexp, output)
237 m = re.match(self.job_id_regexp, output)
@@ -240,25 +240,23 b' class BatchEngineSet(object):'
240 else:
240 else:
241 raise Exception("job id couldn't be determined: %s" % output)
241 raise Exception("job id couldn't be determined: %s" % output)
242 self.job_id = job_id
242 self.job_id = job_id
243 print 'Job started with job id:', job_id
243 log.msg('Job started with job id: %r' % job_id)
244 return job_id
244 return job_id
245
245
246 def write_batch_script(self, n):
246 def write_batch_script(self, n):
247 print 'n', n
248 self.context['n'] = n
247 self.context['n'] = n
249 template = open(self.template_file, 'r').read()
248 template = open(self.template_file, 'r').read()
250 print 'template', template
249 log.msg('Using template for batch script: %s' % self.template_file)
251 log.msg(template)
252 log.msg(repr(self.context))
250 log.msg(repr(self.context))
253 script_as_string = Itpl.itplns(template, self.context)
251 script_as_string = Itpl.itplns(template, self.context)
254 log.msg(script_as_string)
252 log.msg('Writing instantiated batch script: %s' % self.batch_file)
255 f = open(self.batch_file,'w')
253 f = open(self.batch_file,'w')
256 f.write(script_as_string)
254 f.write(script_as_string)
257 f.close()
255 f.close()
258
256
259 def handle_error(self, f):
257 def handle_error(self, f):
260 f.printTraceback()
258 f.printTraceback()
261 #f.raiseException()
259 f.raiseException()
262
260
263 def start(self, n):
261 def start(self, n):
264 self.write_batch_script(n)
262 self.write_batch_script(n)
@@ -361,6 +359,12 b' def main_pbs(args):'
361 dstart = cl.start()
359 dstart = cl.start()
362 def start_engines(r):
360 def start_engines(r):
363 pbs_set = PBSEngineSet(args.pbsscript)
361 pbs_set = PBSEngineSet(args.pbsscript)
362 def shutdown(signum, frame):
363 log.msg('Stopping pbs cluster')
364 d = pbs_set.kill()
365 d.addBoth(lambda _: cl.interrupt_then_kill(1.0))
366 d.addBoth(lambda _: reactor.callLater(2.0, reactor.stop))
367 signal.signal(signal.SIGINT,shutdown)
364 d = pbs_set.start(args.n)
368 d = pbs_set.start(args.n)
365 return d
369 return d
366 dstart.addCallback(start_engines)
370 dstart.addCallback(start_engines)
General Comments 0
You need to be logged in to leave comments. Login now