Permalink
Browse files

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
  • Loading branch information...
1 parent 7a02b90 commit d24b9a62b48328c1b9a36f9b49145589e853ee24 @minrk committed Sep 16, 2011
@@ -119,9 +119,13 @@ def _work_dir_changed(self, name, old, new):
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-<cluster_id>-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):
@@ -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
@@ -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
@@ -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 @@ def start(self, n):
#-----------------------------------------------------------------------------
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 @@ def start(self):
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 @@ def start(self):
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 @@ def start(self, n):
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 @@ def start(self):
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.")

0 comments on commit d24b9a6

Please sign in to comment.