##// END OF EJS Templates
The local mode of ipcluster now works on Win32.
Brian Granger -
Show More
@@ -14,8 +14,16 b' from IPython.external import argparse'
14 14 from IPython.external import Itpl
15 15 from IPython.kernel.twistedutil import gatherBoth
16 16 from IPython.kernel.util import printer
17 from IPython.genutils import get_ipython_dir
17 from IPython.genutils import get_ipython_dir, num_cpus
18 18
19 def find_exe(cmd):
20 try:
21 import win32api
22 except ImportError:
23 raise ImportError('you need to have pywin32 installed for this to work')
24 else:
25 (path, offest) = win32api.SearchPath(os.environ['PATH'],cmd)
26 return path
19 27
20 28 # Test local cluster on Win32
21 29 # Look at local cluster usage strings
@@ -66,7 +74,6 b' class ProcessLauncher(object):'
66 74 a formal NotificationCenter.
67 75 """
68 76 def __init__(self, cmd_and_args):
69
70 77 self.cmd = cmd_and_args[0]
71 78 self.args = cmd_and_args
72 79 self._reset()
@@ -131,8 +138,8 b' class ProcessLauncher(object):'
131 138 if self.state == 'running':
132 139 self.process_transport.signalProcess(sig)
133 140
134 def __del__(self):
135 self.signal('KILL')
141 # def __del__(self):
142 # self.signal('KILL')
136 143
137 144 def interrupt_then_kill(self, delay=1.0):
138 145 self.signal('INT')
@@ -142,23 +149,29 b' class ProcessLauncher(object):'
142 149 class ControllerLauncher(ProcessLauncher):
143 150
144 151 def __init__(self, extra_args=None):
145 self.args = ['ipcontroller']
152 if sys.platform == 'win32':
153 args = [find_exe('ipcontroller.bat')]
154 else:
155 args = ['ipcontroller']
146 156 self.extra_args = extra_args
147 157 if extra_args is not None:
148 self.args.extend(extra_args)
158 args.extend(extra_args)
149 159
150 ProcessLauncher.__init__(self, self.args)
160 ProcessLauncher.__init__(self, args)
151 161
152 162
153 163 class EngineLauncher(ProcessLauncher):
154 164
155 165 def __init__(self, extra_args=None):
156 self.args = ['ipengine']
166 if sys.platform == 'win32':
167 args = [find_exe('ipengine.bat')]
168 else:
169 args = ['ipengine']
157 170 self.extra_args = extra_args
158 171 if extra_args is not None:
159 self.args.extend(extra_args)
172 args.extend(extra_args)
160 173
161 ProcessLauncher.__init__(self, self.args)
174 ProcessLauncher.__init__(self, args)
162 175
163 176
164 177 class LocalEngineSet(object):
@@ -271,6 +284,10 b' class PBSEngineSet(BatchEngineSet):'
271 284 def main_local(args):
272 285 cont_args = []
273 286 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
287 if args.x:
288 cont_args.append('-x')
289 if args.y:
290 cont_args.append('-y')
274 291 cl = ControllerLauncher(extra_args=cont_args)
275 292 dstart = cl.start()
276 293 def start_engines(cont_pid):
@@ -299,6 +316,10 b' def main_local(args):'
299 316 def main_mpirun(args):
300 317 cont_args = []
301 318 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
319 if args.x:
320 cont_args.append('-x')
321 if args.y:
322 cont_args.append('-y')
302 323 cl = ControllerLauncher(extra_args=cont_args)
303 324 dstart = cl.start()
304 325 def start_engines(cont_pid):
@@ -340,29 +361,62 b' def main_pbs(args):'
340 361
341 362
342 363 def get_args():
343 parser = argparse.ArgumentParser(
344 description='IPython cluster startup')
345 newopt = parser.add_argument # shorthand
364 base_parser = argparse.ArgumentParser(add_help=False)
365 base_parser.add_argument(
366 '-x',
367 action='store_true',
368 dest='x',
369 help='turn off client security'
370 )
371 base_parser.add_argument(
372 '-y',
373 action='store_true',
374 dest='y',
375 help='turn off engine security'
376 )
377 base_parser.add_argument(
378 "--logdir",
379 type=str,
380 dest="logdir",
381 help="directory to put log files (default=$IPYTHONDIR/log)",
382 default=pjoin(get_ipython_dir(),'log')
383 )
384 base_parser.add_argument(
385 "-n",
386 "--num",
387 type=int,
388 dest="n",
389 default=2,
390 help="the number of engines to start"
391 )
346 392
347 subparsers = parser.add_subparsers(help='sub-command help')
393 parser = argparse.ArgumentParser(
394 description='IPython cluster startup. This starts a controller and\
395 engines using various approaches'
396 )
397 subparsers = parser.add_subparsers(
398 help='available cluster types. For help, do "ipcluster TYPE --help"')
348 399
349 parser_local = subparsers.add_parser('local', help='run a local cluster')
350 parser_local.add_argument("--logdir", type=str, dest="logdir",
351 help="directory to put log files (default=$IPYTHONDIR/log)",
352 default=pjoin(get_ipython_dir(),'log'))
353 parser_local.add_argument("-n", "--num", type=int, dest="n",default=2,
354 help="the number of engines to start")
400 parser_local = subparsers.add_parser(
401 'local',
402 help='run a local cluster',
403 parents=[base_parser]
404 )
355 405 parser_local.set_defaults(func=main_local)
356 406
357 parser_local = subparsers.add_parser('mpirun', help='run a cluster using mpirun')
358 parser_local.add_argument("--logdir", type=str, dest="logdir",
359 help="directory to put log files (default=$IPYTHONDIR/log)",
360 default=pjoin(get_ipython_dir(),'log'))
361 parser_local.add_argument("-n", "--num", type=int, dest="n",default=2,
362 help="the number of engines to start")
363 parser_local.add_argument("--mpi", type=str, dest="mpi",default='mpi4py',
364 help="how to call MPI_Init (default=mpi4py)")
365 parser_local.set_defaults(func=main_mpirun)
407 parser_mpirun = subparsers.add_parser(
408 'mpirun',
409 help='run a cluster using mpirun',
410 parents=[base_parser]
411 )
412 parser_mpirun.add_argument(
413 "--mpi",
414 type=str,
415 dest="mpi",
416 default='mpi4py',
417 help="how to call MPI_Init (default=mpi4py)"
418 )
419 parser_mpirun.set_defaults(func=main_mpirun)
366 420
367 421 parser_pbs = subparsers.add_parser('pbs', help='run a pbs cluster')
368 422 parser_pbs.add_argument('--pbs-script', type=str, dest='pbsscript',
General Comments 0
You need to be logged in to leave comments. Login now