From 9e3db2d3a78cd9107c2c58d5c765c21dc2c6b7a9 2009-11-15 22:50:16 From: Brian Granger Date: 2009-11-15 22:50:16 Subject: [PATCH] Fixing minor bugs in IPython.kernel. * Regular expressions now using raw strings in launcher.py * Directory permissions on cluster directory handled properly. * A raw ipcluster start will now create cluster default and add the default config files. * Config files updated to use raw strings where appropriate. --- diff --git a/IPython/config/default/ipcluster_config.py b/IPython/config/default/ipcluster_config.py index d391510..36aa453 100644 --- a/IPython/config/default/ipcluster_config.py +++ b/IPython/config/default/ipcluster_config.py @@ -109,7 +109,7 @@ c = get_config() # c.PBSControllerLauncher.delete_command = 'qdel' # A regular expression that takes the output of qsub and find the job id. -# c.PBSControllerLauncher.job_id_regexp = '\d+' +# c.PBSControllerLauncher.job_id_regexp = r'\d+' # The batch submission script used to start the controller. This is where # environment variables would be setup, etc. This string is interpolated using @@ -129,7 +129,7 @@ c = get_config() # c.PBSEngineSetLauncher.delete_command = 'qdel' # A regular expression that takes the output of qsub and find the job id. -# c.PBSEngineSetLauncher.job_id_regexp = '\d+' +# c.PBSEngineSetLauncher.job_id_regexp = r'\d+' # The batch submission script used to start the engines. This is where # environment variables would be setup, etc. This string is interpolated using @@ -147,7 +147,7 @@ c = get_config() # c.IPControllerJob.job_name = 'IPController' # c.IPControllerJob.is_exclusive = False -# c.IPControllerJob.username = 'USERDOMAIN\\USERNAME' +# c.IPControllerJob.username = r'USERDOMAIN\USERNAME' # c.IPControllerJob.priority = 'Highest' # c.IPControllerJob.requested_nodes = '' # c.IPControllerJob.project = 'MyProject' @@ -163,7 +163,7 @@ c = get_config() # c.IPEngineSetJob.job_name = 'IPEngineSet' # c.IPEngineSetJob.is_exclusive = False -# c.IPEngineSetJob.username = 'USERDOMAIN\\USERNAME' +# c.IPEngineSetJob.username = r'USERDOMAIN\USERNAME' # c.IPEngineSetJob.priority = 'Highest' # c.IPEngineSetJob.requested_nodes = '' # c.IPEngineSetJob.project = 'MyProject' diff --git a/IPython/kernel/clusterdir.py b/IPython/kernel/clusterdir.py index 7168ea4..677d93e 100644 --- a/IPython/kernel/clusterdir.py +++ b/IPython/kernel/clusterdir.py @@ -69,9 +69,7 @@ class ClusterDir(Component): def _location_changed(self, name, old, new): if not os.path.isdir(new): - os.makedirs(new, mode=0777) - else: - os.chmod(new, 0777) + os.makedirs(new) self.security_dir = os.path.join(new, self.security_dir_name) self.log_dir = os.path.join(new, self.log_dir_name) self.pid_dir = os.path.join(new, self.pid_dir_name) @@ -82,9 +80,7 @@ class ClusterDir(Component): def check_log_dir(self): if not os.path.isdir(self.log_dir): - os.mkdir(self.log_dir, 0777) - else: - os.chmod(self.log_dir, 0777) + os.mkdir(self.log_dir) def _security_dir_changed(self, name, old, new): self.check_security_dir() @@ -92,8 +88,7 @@ class ClusterDir(Component): def check_security_dir(self): if not os.path.isdir(self.security_dir): os.mkdir(self.security_dir, 0700) - else: - os.chmod(self.security_dir, 0700) + os.chmod(self.security_dir, 0700) def _pid_dir_changed(self, name, old, new): self.check_pid_dir() @@ -101,8 +96,7 @@ class ClusterDir(Component): def check_pid_dir(self): if not os.path.isdir(self.pid_dir): os.mkdir(self.pid_dir, 0700) - else: - os.chmod(self.pid_dir, 0700) + os.chmod(self.pid_dir, 0700) def check_dirs(self): self.check_security_dir() diff --git a/IPython/kernel/ipclusterapp.py b/IPython/kernel/ipclusterapp.py index e37bbf1..773336d 100644 --- a/IPython/kernel/ipclusterapp.py +++ b/IPython/kernel/ipclusterapp.py @@ -208,7 +208,7 @@ class IPClusterApp(ApplicationWithClusterDir): self.auto_create_cluster_dir = True super(IPClusterApp, self).find_resources() elif subcommand=='start' or subcommand=='stop': - self.auto_create_cluster_dir = False + self.auto_create_cluster_dir = True try: super(IPClusterApp, self).find_resources() except ClusterDirError: @@ -257,13 +257,16 @@ class IPClusterApp(ApplicationWithClusterDir): def construct(self): config = self.master_config - if config.Global.subcommand=='list': - pass - elif config.Global.subcommand=='create': + subcmd = config.Global.subcommand + reset = config.Global.reset_config + if subcmd == 'list': + return + if subcmd == 'create': self.log.info('Copying default config files to cluster directory ' - '[overwrite=%r]' % (config.Global.reset_config,)) - self.cluster_dir_obj.copy_all_config_files(overwrite=config.Global.reset_config) - elif config.Global.subcommand=='start': + '[overwrite=%r]' % (reset,)) + self.cluster_dir_obj.copy_all_config_files(overwrite=reset) + if subcmd =='start': + self.cluster_dir_obj.copy_all_config_files(overwrite=False) self.start_logging() reactor.callWhenRunning(self.start_launchers) @@ -410,6 +413,7 @@ class IPClusterApp(ApplicationWithClusterDir): self.log.info( 'Starting ipcluster with [daemon=%r]' % config.Global.daemonize ) + # TODO: Get daemonize working on Windows or as a Windows Server. if config.Global.daemonize: if os.name=='posix': daemonize() diff --git a/IPython/kernel/launcher.py b/IPython/kernel/launcher.py index e14d9d1..2f41211 100644 --- a/IPython/kernel/launcher.py +++ b/IPython/kernel/launcher.py @@ -505,6 +505,7 @@ class MPIExecEngineSetLauncher(MPIExecLauncher): # SSH launchers #----------------------------------------------------------------------------- +# TODO: Get SSH Launcher working again. class SSHLauncher(BaseLauncher): """A minimal launcher for ssh. @@ -565,7 +566,7 @@ class WindowsHPCLauncher(BaseLauncher): # A regular expression used to get the job id from the output of the # submit_command. - job_id_regexp = Str('\d+', config=True) + job_id_regexp = Str(r'\d+', config=True) # The filename of the instantiated job script. job_file_name = Unicode(u'ipython_job.xml', config=True) # The full path to the instantiated job script. This gets made dynamically @@ -709,6 +710,7 @@ class WindowsHPCEngineSetLauncher(WindowsHPCLauncher): # Batch (PBS) system launchers #----------------------------------------------------------------------------- +# TODO: Get PBS launcher working again. class BatchSystemLauncher(BaseLauncher): """Launch an external process using a batch system. @@ -790,7 +792,7 @@ class PBSLauncher(BatchSystemLauncher): submit_command = Str('qsub', config=True) delete_command = Str('qdel', config=True) - job_id_regexp = Str('\d+', config=True) + job_id_regexp = Str(r'\d+', config=True) batch_template = Str('', config=True) batch_file_name = Unicode(u'pbs_batch_script', config=True) batch_file = Unicode(u'')