Show More
@@ -24,7 +24,7 from zmq.eventloop import ioloop | |||||
24 | from IPython.config.configurable import LoggingConfigurable |
|
24 | from IPython.config.configurable import LoggingConfigurable | |
25 | from IPython.config.loader import load_pyconfig_files |
|
25 | from IPython.config.loader import load_pyconfig_files | |
26 | from IPython.utils.traitlets import Dict, Instance, CFloat |
|
26 | from IPython.utils.traitlets import Dict, Instance, CFloat | |
27 |
from IPython.parallel.apps.ipclusterapp import |
|
27 | from IPython.parallel.apps.ipclusterapp import IPClusterStart | |
28 | from IPython.core.profileapp import list_profiles_in |
|
28 | from IPython.core.profileapp import list_profiles_in | |
29 | from IPython.core.profiledir import ProfileDir |
|
29 | from IPython.core.profiledir import ProfileDir | |
30 | from IPython.utils.path import get_ipython_dir |
|
30 | from IPython.utils.path import get_ipython_dir | |
@@ -35,6 +35,22 from IPython.utils.sysinfo import num_cpus | |||||
35 | # Classes |
|
35 | # Classes | |
36 | #----------------------------------------------------------------------------- |
|
36 | #----------------------------------------------------------------------------- | |
37 |
|
37 | |||
|
38 | ||||
|
39 | class DummyIPClusterStart(IPClusterStart): | |||
|
40 | """Dummy subclass to skip init steps that conflict with global app. | |||
|
41 | ||||
|
42 | Instantiating and initializing this class should result in fully configured | |||
|
43 | launchers, but no other side effects or state. | |||
|
44 | """ | |||
|
45 | ||||
|
46 | def init_signal(self): | |||
|
47 | pass | |||
|
48 | def init_logging(self): | |||
|
49 | pass | |||
|
50 | def reinit_logging(self): | |||
|
51 | pass | |||
|
52 | ||||
|
53 | ||||
38 | class ClusterManager(LoggingConfigurable): |
|
54 | class ClusterManager(LoggingConfigurable): | |
39 |
|
55 | |||
40 | profiles = Dict() |
|
56 | profiles = Dict() | |
@@ -47,22 +63,12 class ClusterManager(LoggingConfigurable): | |||||
47 | from zmq.eventloop.ioloop import IOLoop |
|
63 | from zmq.eventloop.ioloop import IOLoop | |
48 | return IOLoop.instance() |
|
64 | return IOLoop.instance() | |
49 |
|
65 | |||
50 | def load_cluster_config(self, profile_dir): |
|
|||
51 | config_files = ['ipcontroller_config.py', 'ipengine_config.py', 'ipcluster_config.py'] |
|
|||
52 | config = load_pyconfig_files(config_files, profile_dir) |
|
|||
53 | return config |
|
|||
54 |
|
||||
55 | def build_launchers(self, profile_dir): |
|
66 | def build_launchers(self, profile_dir): | |
56 | config = self.load_cluster_config(profile_dir) |
|
67 | starter = DummyIPClusterStart(log=self.log) | |
57 | cont_clsname = config.IPClusterStart.get('controller_launcher_class','Local') |
|
68 | starter.initialize(['--profile-dir', profile_dir]) | |
58 | cont_class = find_launcher_class(cont_clsname,'Controller') |
|
69 | cl = starter.controller_launcher | |
59 | cl = cont_class(work_dir=u'.',config=config, profile_dir=profile_dir) |
|
70 | esl = starter.engine_launcher | |
60 |
|
71 | n = starter.n | ||
61 | engine_clsname = config.IPClusterEngines.get('engine_launcher_class','Local') |
|
|||
62 | engine_class = find_launcher_class(engine_clsname,'EngineSet') |
|
|||
63 | esl = engine_class(work_dir=u'.',config=config, profile_dir=profile_dir) |
|
|||
64 | n = config.IPClusterEngines.get('n', num_cpus()) |
|
|||
65 | n = getattr(esl, 'engine_count', n) |
|
|||
66 | return cl, esl, n |
|
72 | return cl, esl, n | |
67 |
|
73 | |||
68 | def get_profile_dir(self, name, path): |
|
74 | def get_profile_dir(self, name, path): |
@@ -512,7 +512,6 class IPClusterStart(IPClusterEngines): | |||||
512 | def init_launchers(self): |
|
512 | def init_launchers(self): | |
513 | self.controller_launcher = self.build_launcher(self.controller_launcher_class, 'Controller') |
|
513 | self.controller_launcher = self.build_launcher(self.controller_launcher_class, 'Controller') | |
514 | self.engine_launcher = self.build_launcher(self.engine_launcher_class, 'EngineSet') |
|
514 | self.engine_launcher = self.build_launcher(self.engine_launcher_class, 'EngineSet') | |
515 | self.controller_launcher.on_stop(self.stop_launchers) |
|
|||
516 |
|
515 | |||
517 | def engines_stopped(self, r): |
|
516 | def engines_stopped(self, r): | |
518 | """prevent parent.engines_stopped from stopping everything on engine shutdown""" |
|
517 | """prevent parent.engines_stopped from stopping everything on engine shutdown""" | |
@@ -520,6 +519,7 class IPClusterStart(IPClusterEngines): | |||||
520 |
|
519 | |||
521 | def start_controller(self): |
|
520 | def start_controller(self): | |
522 | self.log.info("Starting Controller with %s", self.controller_launcher_class) |
|
521 | self.log.info("Starting Controller with %s", self.controller_launcher_class) | |
|
522 | self.controller_launcher.on_stop(self.stop_launchers) | |||
523 | self.controller_launcher.start() |
|
523 | self.controller_launcher.start() | |
524 |
|
524 | |||
525 | def stop_controller(self): |
|
525 | def stop_controller(self): |
General Comments 0
You need to be logged in to leave comments.
Login now