From 37c29460515ae639ec7f9667755a4d79b464a469 2011-09-20 20:33:22 From: MinRK Date: 2011-09-20 20:33:22 Subject: [PATCH] parallel.apps cleanup per review STY: added spaces in string formatting calls STY: expanded helpstring for cluster-id ENH: allow BatchClusterAppMixin to be the second inherited class --- diff --git a/IPython/parallel/apps/baseapp.py b/IPython/parallel/apps/baseapp.py index 400cda7..86a8506 100755 --- a/IPython/parallel/apps/baseapp.py +++ b/IPython/parallel/apps/baseapp.py @@ -119,9 +119,13 @@ class BaseParallelApplication(BaseIPythonApplication): cluster_id = Unicode('', config=True, help="""String id to add to runtime files, to prevent name collisions when - using multiple clusters with a single profile. + using multiple clusters with a single profile simultaneously. When set, files will be named like: 'ipcontroller--engine.json' + + Since this is text inserted into filenames, typical recommendations apply: + Simple character strings are ideal, and spaces are not recommended (but should + generally work). """ ) def _cluster_id_changed(self, name, old, new): diff --git a/IPython/parallel/apps/ipcontrollerapp.py b/IPython/parallel/apps/ipcontrollerapp.py index b084348..538f38f 100755 --- a/IPython/parallel/apps/ipcontrollerapp.py +++ b/IPython/parallel/apps/ipcontrollerapp.py @@ -183,8 +183,8 @@ class IPControllerApp(BaseParallelApplication): def _cluster_id_changed(self, name, old, new): super(IPControllerApp, self)._cluster_id_changed(name, old, new) - self.engine_json_file = "%s-engine.json"%self.name - self.client_json_file = "%s-client.json"%self.name + self.engine_json_file = "%s-engine.json" % self.name + self.client_json_file = "%s-client.json" % self.name # internal diff --git a/IPython/parallel/apps/ipengineapp.py b/IPython/parallel/apps/ipengineapp.py index 055318f..6917733 100755 --- a/IPython/parallel/apps/ipengineapp.py +++ b/IPython/parallel/apps/ipengineapp.py @@ -93,7 +93,7 @@ class MPI(Configurable): help='How to enable MPI (mpi4py, pytrilinos, or empty string to disable).' ) - def _on_use_changed(self, old, new): + def _use_changed(self, name, old, new): # load default init script if it's not set if not self.init_script: self.init_script = self.default_inits.get(new, '') @@ -162,10 +162,10 @@ class IPEngineApp(BaseParallelApplication): def _cluster_id_changed(self, name, old, new): if new: - base = 'ipcontroller-%s'%new + base = 'ipcontroller-%s' % new else: base = 'ipcontroller' - self.url_file_name = "%s-engine.json"%base + self.url_file_name = "%s-engine.json" % base log_url = Unicode('', config=True, help="""The URL for the iploggerapp instance, for forwarding diff --git a/IPython/parallel/apps/launcher.py b/IPython/parallel/apps/launcher.py index 25daa98..9267f38 100644 --- a/IPython/parallel/apps/launcher.py +++ b/IPython/parallel/apps/launcher.py @@ -232,14 +232,14 @@ class ControllerMixin(ClusterAppMixin): controller_cmd = List(ipcontroller_cmd_argv, config=True, help="""Popen command to launch ipcontroller.""") # Command line arguments to ipcontroller. - controller_args = List(['--log-to-file','--log-level=%i'%logging.INFO], config=True, + controller_args = List(['--log-to-file','--log-level=%i' % logging.INFO], config=True, help="""command-line args to pass to ipcontroller""") class EngineMixin(ClusterAppMixin): engine_cmd = List(ipengine_cmd_argv, config=True, help="""command to launch the Engine.""") # Command line arguments for ipengine. - engine_args = List(['--log-to-file','--log-level=%i'%logging.INFO], config=True, + engine_args = List(['--log-to-file','--log-level=%i' % logging.INFO], config=True, help="command-line arguments to pass to ipengine" ) @@ -807,12 +807,19 @@ class WindowsHPCEngineSetLauncher(WindowsHPCLauncher, ClusterAppMixin): #----------------------------------------------------------------------------- class BatchClusterAppMixin(ClusterAppMixin): - """ClusterApp mixin that updates context dict, rather than args""" - context = Dict({'profile_dir':'', 'cluster_id':''}) + """ClusterApp mixin that updates the self.context dict, rather than cl-args.""" def _profile_dir_changed(self, name, old, new): self.context[name] = new _cluster_id_changed = _profile_dir_changed + def _profile_dir_default(self): + self.context['profile_dir'] = '' + return '' + def _cluster_id_default(self): + self.context['cluster_id'] = '' + return '' + + class BatchSystemLauncher(BaseLauncher): """Launch an external process using a batch system. @@ -956,7 +963,7 @@ class PBSLauncher(BatchSystemLauncher): queue_template = Unicode('#PBS -q {queue}') -class PBSControllerLauncher(BatchClusterAppMixin, PBSLauncher): +class PBSControllerLauncher(PBSLauncher, BatchClusterAppMixin): """Launch a controller using PBS.""" batch_file_name = Unicode(u'pbs_controller', config=True, @@ -974,7 +981,7 @@ class PBSControllerLauncher(BatchClusterAppMixin, PBSLauncher): return super(PBSControllerLauncher, self).start(1) -class PBSEngineSetLauncher(BatchClusterAppMixin, PBSLauncher): +class PBSEngineSetLauncher(PBSLauncher, BatchClusterAppMixin): """Launch Engines using PBS""" batch_file_name = Unicode(u'pbs_engines', config=True, help="batch file name for the engine(s) job.") @@ -998,7 +1005,7 @@ class SGELauncher(PBSLauncher): queue_regexp = Unicode('#\$\W+-q\W+\$?\w+') queue_template = Unicode('#$ -q {queue}') -class SGEControllerLauncher(BatchClusterAppMixin, SGELauncher): +class SGEControllerLauncher(SGELauncher, BatchClusterAppMixin): """Launch a controller using SGE.""" batch_file_name = Unicode(u'sge_controller', config=True, @@ -1014,7 +1021,7 @@ class SGEControllerLauncher(BatchClusterAppMixin, SGELauncher): self.log.info("Starting PBSControllerLauncher: %r" % self.args) return super(SGEControllerLauncher, self).start(1) -class SGEEngineSetLauncher(BatchClusterAppMixin, SGELauncher): +class SGEEngineSetLauncher(SGELauncher, BatchClusterAppMixin): """Launch Engines with SGE""" batch_file_name = Unicode(u'sge_engines', config=True, help="batch file name for the engine(s) job.") @@ -1066,7 +1073,7 @@ class LSFLauncher(BatchSystemLauncher): return job_id -class LSFControllerLauncher(BatchClusterAppMixin, LSFLauncher): +class LSFControllerLauncher(LSFLauncher, BatchClusterAppMixin): """Launch a controller using LSF.""" batch_file_name = Unicode(u'lsf_controller', config=True, @@ -1084,7 +1091,7 @@ class LSFControllerLauncher(BatchClusterAppMixin, LSFLauncher): return super(LSFControllerLauncher, self).start(1) -class LSFEngineSetLauncher(BatchClusterAppMixin, LSFLauncher): +class LSFEngineSetLauncher(LSFLauncher, BatchClusterAppMixin): """Launch Engines using LSF""" batch_file_name = Unicode(u'lsf_engines', config=True, help="batch file name for the engine(s) job.")