Skip to content

Commit

Permalink
allow launcher specification by prefix alone
Browse files Browse the repository at this point in the history
e.g. ipcluster start --engines=SGE
  • Loading branch information
minrk committed Sep 16, 2011
1 parent d24b9a6 commit 9937d3c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions IPython/parallel/apps/ipclusterapp.py
Expand Up @@ -275,19 +275,22 @@ def initialize(self, argv=None):
self.init_launchers()

def init_launchers(self):
self.engine_launcher = self.build_launcher(self.engine_launcher_class)
self.engine_launcher = self.build_launcher(self.engine_launcher_class, 'EngineSet')
self.engine_launcher.on_stop(lambda r: self.loop.stop())

def init_signal(self):
# Setup signals
signal.signal(signal.SIGINT, self.sigint_handler)

def build_launcher(self, clsname):
def build_launcher(self, clsname, kind=None):
"""import and instantiate a Launcher based on importstring"""
if '.' not in clsname:
# not a module, presume it's the raw name in apps.launcher
if kind and kind not in clsname:
# doesn't match necessary full class name, assume it's
# just 'PBS' or 'MPIExec' prefix:
clsname = clsname + kind + 'Launcher'
clsname = 'IPython.parallel.apps.launcher.'+clsname
# print repr(clsname)
try:
klass = import_item(clsname)
except (ImportError, KeyError):
Expand Down Expand Up @@ -422,8 +425,8 @@ def _classes_default(self,):
aliases = Dict(start_aliases)

def init_launchers(self):
self.controller_launcher = self.build_launcher(self.controller_launcher_class)
self.engine_launcher = self.build_launcher(self.engine_launcher_class)
self.controller_launcher = self.build_launcher(self.controller_launcher_class, 'Controller')
self.engine_launcher = self.build_launcher(self.engine_launcher_class, 'EngineSet')
self.controller_launcher.on_stop(self.stop_launchers)

def start_controller(self):
Expand Down

0 comments on commit 9937d3c

Please sign in to comment.