From 9d80f8522cfcff9dad193e979c137c8ae3e174d0 Mon Sep 17 00:00:00 2001 From: MinRK Date: Sat, 18 Feb 2012 12:22:57 -0500 Subject: [PATCH] use DummyIPClusterStart to load config in notebook ClusterManager ensures that config loading matches what would happen in ipcluster. The only change needed in IPClusterStart itself was moving the on_stop registration from init_launchers to start_controller, where it should have been anyway. --- .../frontend/html/notebook/clustermanager.py | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/IPython/frontend/html/notebook/clustermanager.py b/IPython/frontend/html/notebook/clustermanager.py index b2ab3b201..6a28fa4a0 100644 --- a/IPython/frontend/html/notebook/clustermanager.py +++ b/IPython/frontend/html/notebook/clustermanager.py @@ -24,7 +24,7 @@ from zmq.eventloop import ioloop from IPython.config.configurable import LoggingConfigurable from IPython.config.loader import load_pyconfig_files from IPython.utils.traitlets import Dict, Instance, CFloat -from IPython.parallel.apps.ipclusterapp import find_launcher_class +from IPython.parallel.apps.ipclusterapp import IPClusterStart from IPython.core.profileapp import list_profiles_in from IPython.core.profiledir import ProfileDir from IPython.utils.path import get_ipython_dir @@ -35,6 +35,22 @@ from IPython.utils.sysinfo import num_cpus # Classes #----------------------------------------------------------------------------- + +class DummyIPClusterStart(IPClusterStart): + """Dummy subclass to skip init steps that conflict with global app. + + Instantiating and initializing this class should result in fully configured + launchers, but no other side effects or state. + """ + + def init_signal(self): + pass + def init_logging(self): + pass + def reinit_logging(self): + pass + + class ClusterManager(LoggingConfigurable): profiles = Dict() @@ -47,22 +63,12 @@ class ClusterManager(LoggingConfigurable): from zmq.eventloop.ioloop import IOLoop return IOLoop.instance() - def load_cluster_config(self, profile_dir): - config_files = ['ipcontroller_config.py', 'ipengine_config.py', 'ipcluster_config.py'] - config = load_pyconfig_files(config_files, profile_dir) - return config - def build_launchers(self, profile_dir): - config = self.load_cluster_config(profile_dir) - cont_clsname = config.IPClusterStart.get('controller_launcher_class','Local') - cont_class = find_launcher_class(cont_clsname,'Controller') - cl = cont_class(work_dir=u'.',config=config, profile_dir=profile_dir) - - engine_clsname = config.IPClusterEngines.get('engine_launcher_class','Local') - engine_class = find_launcher_class(engine_clsname,'EngineSet') - esl = engine_class(work_dir=u'.',config=config, profile_dir=profile_dir) - n = config.IPClusterEngines.get('n', num_cpus()) - n = getattr(esl, 'engine_count', n) + starter = DummyIPClusterStart(log=self.log) + starter.initialize(['--profile-dir', profile_dir]) + cl = starter.controller_launcher + esl = starter.engine_launcher + n = starter.n return cl, esl, n def get_profile_dir(self, name, path):