##// END OF EJS Templates
Final few cleanup changes to the PBS cluster in ipcluster.
Brian Granger -
Show More
@@ -1,3 +1,19 b''
1 #!/usr/bin/env python
2 # encoding: utf-8
3
4 """Start an IPython cluster = (controller + engines)."""
5
6 #-----------------------------------------------------------------------------
7 # Copyright (C) 2008 The IPython Development Team
8 #
9 # Distributed under the terms of the BSD License. The full license is in
10 # the file COPYING, distributed as part of this software.
11 #-----------------------------------------------------------------------------
12
13 #-----------------------------------------------------------------------------
14 # Imports
15 #-----------------------------------------------------------------------------
16
1 import os
17 import os
2 import re
18 import re
3 import sys
19 import sys
@@ -16,6 +32,10 b' from IPython.kernel.twistedutil import gatherBoth'
16 from IPython.kernel.util import printer
32 from IPython.kernel.util import printer
17 from IPython.genutils import get_ipython_dir, num_cpus
33 from IPython.genutils import get_ipython_dir, num_cpus
18
34
35 #-----------------------------------------------------------------------------
36 # General process handling code
37 #-----------------------------------------------------------------------------
38
19 def find_exe(cmd):
39 def find_exe(cmd):
20 try:
40 try:
21 import win32api
41 import win32api
@@ -25,10 +45,6 b' def find_exe(cmd):'
25 (path, offest) = win32api.SearchPath(os.environ['PATH'],cmd)
45 (path, offest) = win32api.SearchPath(os.environ['PATH'],cmd)
26 return path
46 return path
27
47
28 # Test local cluster on Win32
29 # Look at local cluster usage strings
30 # PBS stuff
31
32 class ProcessStateError(Exception):
48 class ProcessStateError(Exception):
33 pass
49 pass
34
50
@@ -146,6 +162,11 b' class ProcessLauncher(object):'
146 reactor.callLater(delay, self.signal, 'KILL')
162 reactor.callLater(delay, self.signal, 'KILL')
147
163
148
164
165 #-----------------------------------------------------------------------------
166 # Code for launching controller and engines
167 #-----------------------------------------------------------------------------
168
169
149 class ControllerLauncher(ProcessLauncher):
170 class ControllerLauncher(ProcessLauncher):
150
171
151 def __init__(self, extra_args=None):
172 def __init__(self, extra_args=None):
@@ -247,7 +268,6 b' class BatchEngineSet(object):'
247 self.context['n'] = n
268 self.context['n'] = n
248 template = open(self.template_file, 'r').read()
269 template = open(self.template_file, 'r').read()
249 log.msg('Using template for batch script: %s' % self.template_file)
270 log.msg('Using template for batch script: %s' % self.template_file)
250 log.msg(repr(self.context))
251 script_as_string = Itpl.itplns(template, self.context)
271 script_as_string = Itpl.itplns(template, self.context)
252 log.msg('Writing instantiated batch script: %s' % self.batch_file)
272 log.msg('Writing instantiated batch script: %s' % self.batch_file)
253 f = open(self.batch_file,'w')
273 f = open(self.batch_file,'w')
@@ -281,6 +301,16 b' class PBSEngineSet(BatchEngineSet):'
281 BatchEngineSet.__init__(self, template_file, **kwargs)
301 BatchEngineSet.__init__(self, template_file, **kwargs)
282
302
283
303
304 #-----------------------------------------------------------------------------
305 # Main functions for the different types of clusters
306 #-----------------------------------------------------------------------------
307
308 # TODO:
309 # The logic in these codes should be moved into classes like LocalCluster
310 # MpirunCluster, PBSCluster, etc. This would remove alot of the duplications.
311 # The main functions should then just parse the command line arguments, create
312 # the appropriate class and call a 'start' method.
313
284 def main_local(args):
314 def main_local(args):
285 cont_args = []
315 cont_args = []
286 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
316 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
@@ -430,7 +460,7 b' def get_args():'
430 parser_mpirun.set_defaults(func=main_mpirun)
460 parser_mpirun.set_defaults(func=main_mpirun)
431
461
432 parser_pbs = subparsers.add_parser(
462 parser_pbs = subparsers.add_parser(
433 'pbs',
463 'pbs',
434 help='run a pbs cluster',
464 help='run a pbs cluster',
435 parents=[base_parser]
465 parents=[base_parser]
436 )
466 )
General Comments 0
You need to be logged in to leave comments. Login now