##// END OF EJS Templates
move ipcluster create|list to `ipython profile create|list`...
MinRK -
Show More
@@ -0,0 +1,174 b''
1 # encoding: utf-8
2 """
3 An application for managing IPython profiles.
4
5 To be invoked as the `ipython profile` subcommand.
6
7 Authors:
8
9 * Min RK
10
11 """
12
13 #-----------------------------------------------------------------------------
14 # Copyright (C) 2008-2011 The IPython Development Team
15 #
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
18 #-----------------------------------------------------------------------------
19
20 #-----------------------------------------------------------------------------
21 # Imports
22 #-----------------------------------------------------------------------------
23
24 import logging
25 import os
26
27 from IPython.config.application import Application, boolean_flag
28 from IPython.core.application import (
29 BaseIPythonApplication, base_flags, base_aliases
30 )
31 from IPython.core.profiledir import ProfileDir
32 from IPython.utils.path import get_ipython_dir
33 from IPython.utils.traitlets import Unicode, Bool, Dict
34
35 #-----------------------------------------------------------------------------
36 # Constants
37 #-----------------------------------------------------------------------------
38
39 create_help = """Create an ipcluster profile by name
40
41 Create an ipython profile directory by its name or
42 profile directory path. Profile directories contain
43 configuration, log and security related files and are named
44 using the convention 'profile_<name>'. By default they are
45 located in your ipython directory. Once created, you will
46 can edit the configuration files in the profile
47 directory to configure IPython. Most users will create a
48 cluster directory by profile name,
49 `ipython profile create myprofile`, which will put the directory
50 in `<ipython_dir>/profile_myprofile`.
51 """
52 list_help = """List available IPython profiles
53
54 List all available profiles, by profile location, that can
55 be found in the current working directly or in the ipython
56 directory. Profile directories are named using the convention
57 'profile_<profile>'.
58 """
59 profile_help = """Manage IPython profiles
60
61 Profile directories contain
62 configuration, log and security related files and are named
63 using the convention 'profile_<name>'. By default they are
64 located in your ipython directory. You can create profiles
65 with `ipython profile create <name>`, or see the profiles you
66 already have with `ipython profile list`
67
68 To get started configuring IPython, simply do:
69
70 $> ipython profile create
71
72 and IPython will create the default profile in <ipython_dir>/profile_default,
73 where you can edit ipython_config.py to start configuring IPython.
74
75 """
76
77 #-----------------------------------------------------------------------------
78 # Profile Application Class (for `ipython profile` subcommand)
79 #-----------------------------------------------------------------------------
80
81
82
83 class ProfileList(Application):
84 name = u'ipython-profile'
85 description = list_help
86
87 aliases = Dict(dict(
88 ipython_dir = 'ProfileList.ipython_dir',
89 log_level = 'Application.log_level',
90 ))
91 flags = Dict(dict(
92 debug = ({'Application' : {'log_level' : 0}},
93 "Set log_level to 0, maximizing log output."
94 )
95 ))
96 ipython_dir = Unicode(get_ipython_dir(), config=True,
97 help="""
98 The name of the IPython directory. This directory is used for logging
99 configuration (through profiles), history storage, etc. The default
100 is usually $HOME/.ipython. This options can also be specified through
101 the environment variable IPYTHON_DIR.
102 """
103 )
104
105 def list_profile_dirs(self):
106 # Find the search paths
107 paths = [os.getcwdu(), self.ipython_dir]
108
109 self.log.warn('Searching for IPython profiles in paths: %r' % paths)
110 for path in paths:
111 files = os.listdir(path)
112 for f in files:
113 full_path = os.path.join(path, f)
114 if os.path.isdir(full_path) and f.startswith('profile_'):
115 profile = f.split('_',1)[-1]
116 start_cmd = 'ipython profile=%s' % profile
117 print start_cmd + " ==> " + full_path
118
119 def start(self):
120 self.list_profile_dirs()
121
122
123 create_flags = {}
124 create_flags.update(base_flags)
125 create_flags.update(boolean_flag('reset', 'ProfileCreate.overwrite',
126 "reset config files to defaults", "leave existing config files"))
127 create_flags.update(boolean_flag('cluster', 'ProfileCreate.cluster',
128 "Include parallel computing config files",
129 "Don't include parallel computing config files"))
130
131 class ProfileCreate(BaseIPythonApplication):
132 name = u'ipython-profile'
133 description = create_help
134 auto_create = Bool(True, config=False)
135
136 def _copy_config_files_default(self):
137 return True
138
139 cluster = Bool(False, config=True,
140 help="whether to include parallel computing config files")
141 def _cluster_changed(self, name, old, new):
142 cluster_files = [ 'ipcontroller_config.py',
143 'ipengine_config.py',
144 'ipcluster_config.py'
145 ]
146 if new:
147 for cf in cluster_files:
148 self.config_files.append(cf)
149 else:
150 for cf in cluster_files:
151 if cf in self.config_files:
152 self.config_files.remove(cf)
153
154 def parse_command_line(self, argv):
155 super(ProfileCreate, self).parse_command_line(argv)
156 # accept positional arg as profile name
157 if self.extra_args:
158 self.profile = self.extra_args[0]
159
160 flags = Dict(create_flags)
161
162 aliases = Dict(dict(profile='BaseIPythonApplication.profile'))
163
164 classes = [ProfileDir]
165
166 class ProfileApp(Application):
167 name = u'ipython-profile'
168 description = profile_help
169
170 subcommands = Dict(dict(
171 create = (ProfileCreate, "Create a new profile dir with default config files"),
172 list = (ProfileList, "List existing profiles")
173 ))
174
@@ -0,0 +1,206 b''
1 # encoding: utf-8
2 """
3 An object for managing IPython profile directories.
4
5 Authors:
6
7 * Brian Granger
8 * Fernando Perez
9 * Min RK
10
11 """
12
13 #-----------------------------------------------------------------------------
14 # Copyright (C) 2008-2011 The IPython Development Team
15 #
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
18 #-----------------------------------------------------------------------------
19
20 #-----------------------------------------------------------------------------
21 # Imports
22 #-----------------------------------------------------------------------------
23
24 import os
25 import shutil
26 import sys
27
28 from IPython.config.configurable import Configurable
29 from IPython.config.loader import Config
30 from IPython.utils.path import get_ipython_package_dir, expand_path
31 from IPython.utils.traitlets import List, Unicode, Bool
32
33 #-----------------------------------------------------------------------------
34 # Classes and functions
35 #-----------------------------------------------------------------------------
36
37
38 #-----------------------------------------------------------------------------
39 # Module errors
40 #-----------------------------------------------------------------------------
41
42 class ProfileDirError(Exception):
43 pass
44
45
46 #-----------------------------------------------------------------------------
47 # Class for managing profile directories
48 #-----------------------------------------------------------------------------
49
50 class ProfileDir(Configurable):
51 """An object to manage the profile directory and its resources.
52
53 The profile directory is used by all IPython applications, to manage
54 configuration, logging and security.
55
56 This object knows how to find, create and manage these directories. This
57 should be used by any code that wants to handle profiles.
58 """
59
60 security_dir_name = Unicode('security')
61 log_dir_name = Unicode('log')
62 pid_dir_name = Unicode('pid')
63 security_dir = Unicode(u'')
64 log_dir = Unicode(u'')
65 pid_dir = Unicode(u'')
66
67 location = Unicode(u'', config=True,
68 help="""Set the profile location directly. This overrides the logic used by the
69 `profile` option.""",
70 )
71
72 _location_isset = Bool(False) # flag for detecting multiply set location
73
74 def _location_changed(self, name, old, new):
75 if self._location_isset:
76 raise RuntimeError("Cannot set profile location more than once.")
77 self._location_isset = True
78 if not os.path.isdir(new):
79 os.makedirs(new)
80
81 # ensure config files exist:
82 self.security_dir = os.path.join(new, self.security_dir_name)
83 self.log_dir = os.path.join(new, self.log_dir_name)
84 self.pid_dir = os.path.join(new, self.pid_dir_name)
85 self.check_dirs()
86
87 def _log_dir_changed(self, name, old, new):
88 self.check_log_dir()
89
90 def check_log_dir(self):
91 if not os.path.isdir(self.log_dir):
92 os.mkdir(self.log_dir)
93
94 def _security_dir_changed(self, name, old, new):
95 self.check_security_dir()
96
97 def check_security_dir(self):
98 if not os.path.isdir(self.security_dir):
99 os.mkdir(self.security_dir, 0700)
100 else:
101 os.chmod(self.security_dir, 0700)
102
103 def _pid_dir_changed(self, name, old, new):
104 self.check_pid_dir()
105
106 def check_pid_dir(self):
107 if not os.path.isdir(self.pid_dir):
108 os.mkdir(self.pid_dir, 0700)
109 else:
110 os.chmod(self.pid_dir, 0700)
111
112 def check_dirs(self):
113 self.check_security_dir()
114 self.check_log_dir()
115 self.check_pid_dir()
116
117 def copy_config_file(self, config_file, path=None, overwrite=False):
118 """Copy a default config file into the active profile directory.
119
120 Default configuration files are kept in :mod:`IPython.config.default`.
121 This function moves these from that location to the working profile
122 directory.
123 """
124 dst = os.path.join(self.location, config_file)
125 if os.path.isfile(dst) and not overwrite:
126 return
127 if path is None:
128 path = os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default')
129 src = os.path.join(path, config_file)
130 shutil.copy(src, dst)
131
132 @classmethod
133 def create_profile_dir(cls, profile_dir, config=None):
134 """Create a new profile directory given a full path.
135
136 Parameters
137 ----------
138 profile_dir : str
139 The full path to the profile directory. If it does exist, it will
140 be used. If not, it will be created.
141 """
142 return cls(location=profile_dir, config=config)
143
144 @classmethod
145 def create_profile_dir_by_name(cls, path, name=u'default', config=None):
146 """Create a profile dir by profile name and path.
147
148 Parameters
149 ----------
150 path : unicode
151 The path (directory) to put the profile directory in.
152 name : unicode
153 The name of the profile. The name of the profile directory will
154 be "profile_<profile>".
155 """
156 if not os.path.isdir(path):
157 raise ProfileDirError('Directory not found: %s' % path)
158 profile_dir = os.path.join(path, u'profile_' + name)
159 return cls(location=profile_dir, config=config)
160
161 @classmethod
162 def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None):
163 """Find an existing profile dir by profile name, return its ProfileDir.
164
165 This searches through a sequence of paths for a profile dir. If it
166 is not found, a :class:`ProfileDirError` exception will be raised.
167
168 The search path algorithm is:
169 1. ``os.getcwd()``
170 2. ``ipython_dir``
171
172 Parameters
173 ----------
174 ipython_dir : unicode or str
175 The IPython directory to use.
176 name : unicode or str
177 The name of the profile. The name of the profile directory
178 will be "profile_<profile>".
179 """
180 dirname = u'profile_' + name
181 paths = [os.getcwdu(), ipython_dir]
182 for p in paths:
183 profile_dir = os.path.join(p, dirname)
184 if os.path.isdir(profile_dir):
185 return cls(location=profile_dir, config=config)
186 else:
187 raise ProfileDirError('Profile directory not found in paths: %s' % dirname)
188
189 @classmethod
190 def find_profile_dir(cls, profile_dir, config=None):
191 """Find/create a profile dir and return its ProfileDir.
192
193 This will create the profile directory if it doesn't exist.
194
195 Parameters
196 ----------
197 profile_dir : unicode or str
198 The path of the profile directory. This is expanded using
199 :func:`IPython.utils.genutils.expand_path`.
200 """
201 profile_dir = expand_path(profile_dir)
202 if not os.path.isdir(profile_dir):
203 raise ProfileDirError('Profile directory not found: %s' % profile_dir)
204 return cls(location=profile_dir, config=config)
205
206
@@ -14,12 +14,10 b' Authors:'
14 14 * Fernando Perez
15 15 * Min RK
16 16
17 Notes
18 -----
19 17 """
20 18
21 19 #-----------------------------------------------------------------------------
22 # Copyright (C) 2008-2009 The IPython Development Team
20 # Copyright (C) 2008-2011 The IPython Development Team
23 21 #
24 22 # Distributed under the terms of the BSD License. The full license is in
25 23 # the file COPYING, distributed as part of this software.
@@ -38,7 +36,8 b' from IPython.config.application import Application'
38 36 from IPython.config.configurable import Configurable
39 37 from IPython.config.loader import Config
40 38 from IPython.core import release, crashhandler
41 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir, expand_path
39 from IPython.core.profiledir import ProfileDir, ProfileDirError
40 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
42 41 from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict
43 42
44 43 #-----------------------------------------------------------------------------
@@ -47,175 +46,6 b' from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict'
47 46
48 47
49 48 #-----------------------------------------------------------------------------
50 # Module errors
51 #-----------------------------------------------------------------------------
52
53 class ProfileDirError(Exception):
54 pass
55
56
57 #-----------------------------------------------------------------------------
58 # Class for managing profile directories
59 #-----------------------------------------------------------------------------
60
61 class ProfileDir(Configurable):
62 """An object to manage the profile directory and its resources.
63
64 The profile directory is used by all IPython applications, to manage
65 configuration, logging and security.
66
67 This object knows how to find, create and manage these directories. This
68 should be used by any code that wants to handle profiles.
69 """
70
71 security_dir_name = Unicode('security')
72 log_dir_name = Unicode('log')
73 pid_dir_name = Unicode('pid')
74 security_dir = Unicode(u'')
75 log_dir = Unicode(u'')
76 pid_dir = Unicode(u'')
77
78 location = Unicode(u'', config=True,
79 help="""Set the profile location directly. This overrides the logic used by the
80 `profile` option.""",
81 )
82
83 _location_isset = Bool(False) # flag for detecting multiply set location
84
85 def _location_changed(self, name, old, new):
86 if self._location_isset:
87 raise RuntimeError("Cannot set profile location more than once.")
88 self._location_isset = True
89 if not os.path.isdir(new):
90 os.makedirs(new)
91
92 # ensure config files exist:
93 self.security_dir = os.path.join(new, self.security_dir_name)
94 self.log_dir = os.path.join(new, self.log_dir_name)
95 self.pid_dir = os.path.join(new, self.pid_dir_name)
96 self.check_dirs()
97
98 def _log_dir_changed(self, name, old, new):
99 self.check_log_dir()
100
101 def check_log_dir(self):
102 if not os.path.isdir(self.log_dir):
103 os.mkdir(self.log_dir)
104
105 def _security_dir_changed(self, name, old, new):
106 self.check_security_dir()
107
108 def check_security_dir(self):
109 if not os.path.isdir(self.security_dir):
110 os.mkdir(self.security_dir, 0700)
111 else:
112 os.chmod(self.security_dir, 0700)
113
114 def _pid_dir_changed(self, name, old, new):
115 self.check_pid_dir()
116
117 def check_pid_dir(self):
118 if not os.path.isdir(self.pid_dir):
119 os.mkdir(self.pid_dir, 0700)
120 else:
121 os.chmod(self.pid_dir, 0700)
122
123 def check_dirs(self):
124 self.check_security_dir()
125 self.check_log_dir()
126 self.check_pid_dir()
127
128 def copy_config_file(self, config_file, path=None, overwrite=False):
129 """Copy a default config file into the active profile directory.
130
131 Default configuration files are kept in :mod:`IPython.config.default`.
132 This function moves these from that location to the working profile
133 directory.
134 """
135 dst = os.path.join(self.location, config_file)
136 if os.path.isfile(dst) and not overwrite:
137 return
138 if path is None:
139 path = os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default')
140 src = os.path.join(path, config_file)
141 shutil.copy(src, dst)
142
143 @classmethod
144 def create_profile_dir(cls, profile_dir, config=None):
145 """Create a new profile directory given a full path.
146
147 Parameters
148 ----------
149 profile_dir : str
150 The full path to the profile directory. If it does exist, it will
151 be used. If not, it will be created.
152 """
153 return cls(location=profile_dir, config=config)
154
155 @classmethod
156 def create_profile_dir_by_name(cls, path, name=u'default', config=None):
157 """Create a profile dir by profile name and path.
158
159 Parameters
160 ----------
161 path : unicode
162 The path (directory) to put the profile directory in.
163 name : unicode
164 The name of the profile. The name of the profile directory will
165 be "profile_<profile>".
166 """
167 if not os.path.isdir(path):
168 raise ProfileDirError('Directory not found: %s' % path)
169 profile_dir = os.path.join(path, u'profile_' + name)
170 return cls(location=profile_dir, config=config)
171
172 @classmethod
173 def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None):
174 """Find an existing profile dir by profile name, return its ProfileDir.
175
176 This searches through a sequence of paths for a profile dir. If it
177 is not found, a :class:`ProfileDirError` exception will be raised.
178
179 The search path algorithm is:
180 1. ``os.getcwd()``
181 2. ``ipython_dir``
182
183 Parameters
184 ----------
185 ipython_dir : unicode or str
186 The IPython directory to use.
187 name : unicode or str
188 The name of the profile. The name of the profile directory
189 will be "profile_<profile>".
190 """
191 dirname = u'profile_' + name
192 paths = [os.getcwdu(), ipython_dir]
193 for p in paths:
194 profile_dir = os.path.join(p, dirname)
195 if os.path.isdir(profile_dir):
196 return cls(location=profile_dir, config=config)
197 else:
198 raise ProfileDirError('Profile directory not found in paths: %s' % dirname)
199
200 @classmethod
201 def find_profile_dir(cls, profile_dir, config=None):
202 """Find/create a profile dir and return its ProfileDir.
203
204 This will create the profile directory if it doesn't exist.
205
206 Parameters
207 ----------
208 profile_dir : unicode or str
209 The path of the profile directory. This is expanded using
210 :func:`IPython.utils.genutils.expand_path`.
211 """
212 profile_dir = expand_path(profile_dir)
213 if not os.path.isdir(profile_dir):
214 raise ProfileDirError('Profile directory not found: %s' % profile_dir)
215 return cls(location=profile_dir, config=config)
216
217
218 #-----------------------------------------------------------------------------
219 49 # Base Application Class
220 50 #-----------------------------------------------------------------------------
221 51
@@ -54,10 +54,10 b' from IPython.core.inputsplitter import IPythonInputSplitter'
54 54 from IPython.core.logger import Logger
55 55 from IPython.core.macro import Macro
56 56 from IPython.core.magic import Magic
57 from IPython.core.application import ProfileDir
58 57 from IPython.core.payload import PayloadManager
59 58 from IPython.core.plugin import PluginManager
60 59 from IPython.core.prefilter import PrefilterManager, ESC_MAGIC
60 from IPython.core.profiledir import ProfileDir
61 61 from IPython.external.Itpl import ItplNS
62 62 from IPython.utils import PyColorize
63 63 from IPython.utils import io
@@ -46,7 +46,7 b' from IPython.core import debugger, oinspect'
46 46 from IPython.core.error import TryNext
47 47 from IPython.core.error import UsageError
48 48 from IPython.core.fakemodule import FakeModule
49 from IPython.core.application import ProfileDir
49 from IPython.core.profiledir import ProfileDir
50 50 from IPython.core.macro import Macro
51 51 from IPython.core import page
52 52 from IPython.core.prefilter import ESC_MAGIC
@@ -27,7 +27,8 b' from pygments.styles import get_all_styles'
27 27
28 28 # Local imports
29 29 from IPython.config.application import boolean_flag
30 from IPython.core.application import ProfileDir, BaseIPythonApplication
30 from IPython.core.application import BaseIPythonApplication
31 from IPython.core.profiledir import ProfileDir
31 32 from IPython.frontend.qt.console.frontend_widget import FrontendWidget
32 33 from IPython.frontend.qt.console.ipython_widget import IPythonWidget
33 34 from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
@@ -203,7 +203,9 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):'
203 203 subcommands = Dict(dict(
204 204 qtconsole=('IPython.frontend.qt.console.qtconsoleapp.IPythonQtConsoleApp',
205 205 """Launch the IPython Qt Console."""
206 )
206 ),
207 profile = ("IPython.core.profileapp.ProfileApp",
208 "Create and manage IPython profiles.")
207 209 ))
208 210
209 211 # *do* autocreate requested profile
@@ -33,7 +33,8 b' from zmq.eventloop import ioloop'
33 33
34 34 from IPython.config.application import Application, boolean_flag
35 35 from IPython.config.loader import Config
36 from IPython.core.application import BaseIPythonApplication, ProfileDir
36 from IPython.core.application import BaseIPythonApplication
37 from IPython.core.profiledir import ProfileDir
37 38 from IPython.utils.daemonize import daemonize
38 39 from IPython.utils.importstring import import_item
39 40 from IPython.utils.traitlets import Int, Unicode, Bool, CFloat, Dict, List
@@ -89,7 +90,7 b' start_help = """Start an IPython cluster for parallel computing'
89 90 Start an ipython cluster by its profile name or cluster
90 91 directory. Cluster directories contain configuration, log and
91 92 security related files and are named using the convention
92 'cluster_<profile>' and should be creating using the 'start'
93 'profile_<name>' and should be creating using the 'start'
93 94 subcommand of 'ipcluster'. If your cluster directory is in
94 95 the cwd or the ipython directory, you can simply refer to it
95 96 using its profile name, 'ipcluster start n=4 profile=<profile>`,
@@ -99,7 +100,7 b' stop_help = """Stop a running IPython cluster'
99 100
100 101 Stop a running ipython cluster by its profile name or cluster
101 102 directory. Cluster directories are named using the convention
102 'cluster_<profile>'. If your cluster directory is in
103 'profile_<name>'. If your cluster directory is in
103 104 the cwd or the ipython directory, you can simply refer to it
104 105 using its profile name, 'ipcluster stop profile=<profile>`, otherwise
105 106 use the 'profile_dir' option.
@@ -110,93 +111,12 b' Start one or more engines to connect to an existing Cluster'
110 111 by profile name or cluster directory.
111 112 Cluster directories contain configuration, log and
112 113 security related files and are named using the convention
113 'cluster_<profile>' and should be creating using the 'start'
114 'profile_<name>' and should be creating using the 'start'
114 115 subcommand of 'ipcluster'. If your cluster directory is in
115 116 the cwd or the ipython directory, you can simply refer to it
116 117 using its profile name, 'ipcluster engines n=4 profile=<profile>`,
117 118 otherwise use the 'profile_dir' option.
118 119 """
119 create_help = """Create an ipcluster profile by name
120
121 Create an ipython cluster directory by its profile name or
122 cluster directory path. Cluster directories contain
123 configuration, log and security related files and are named
124 using the convention 'cluster_<profile>'. By default they are
125 located in your ipython directory. Once created, you will
126 probably need to edit the configuration files in the cluster
127 directory to configure your cluster. Most users will create a
128 cluster directory by profile name,
129 `ipcluster create profile=mycluster`, which will put the directory
130 in `<ipython_dir>/cluster_mycluster`.
131 """
132 list_help = """List available cluster profiles
133
134 List all available clusters, by cluster directory, that can
135 be found in the current working directly or in the ipython
136 directory. Cluster directories are named using the convention
137 'cluster_<profile>'.
138 """
139
140
141 class IPClusterList(BaseIPythonApplication):
142 name = u'ipcluster-list'
143 description = list_help
144
145 # empty aliases
146 aliases=Dict()
147 flags = Dict(base_flags)
148
149 def _log_level_default(self):
150 return 20
151
152 def list_profile_dirs(self):
153 # Find the search paths
154 profile_dir_paths = os.environ.get('IPYTHON_PROFILE_PATH','')
155 if profile_dir_paths:
156 profile_dir_paths = profile_dir_paths.split(':')
157 else:
158 profile_dir_paths = []
159
160 ipython_dir = self.ipython_dir
161
162 paths = [os.getcwd(), ipython_dir] + profile_dir_paths
163 paths = list(set(paths))
164
165 self.log.info('Searching for cluster profiles in paths: %r' % paths)
166 for path in paths:
167 files = os.listdir(path)
168 for f in files:
169 full_path = os.path.join(path, f)
170 if os.path.isdir(full_path) and f.startswith('profile_') and \
171 os.path.isfile(os.path.join(full_path, 'ipcontroller_config.py')):
172 profile = f.split('_')[-1]
173 start_cmd = 'ipcluster start profile=%s n=4' % profile
174 print start_cmd + " ==> " + full_path
175
176 def start(self):
177 self.list_profile_dirs()
178
179
180 # `ipcluster create` will be deprecated when `ipython profile create` or equivalent exists
181
182 create_flags = {}
183 create_flags.update(base_flags)
184 create_flags.update(boolean_flag('reset', 'IPClusterCreate.overwrite',
185 "reset config files to defaults", "leave existing config files"))
186
187 class IPClusterCreate(BaseParallelApplication):
188 name = u'ipcluster-create'
189 description = create_help
190 auto_create = Bool(True)
191 config_file_name = Unicode(default_config_file_name)
192
193 flags = Dict(create_flags)
194
195 aliases = Dict(dict(profile='BaseIPythonApplication.profile'))
196
197 classes = [ProfileDir]
198
199
200 120 stop_aliases = dict(
201 121 signal='IPClusterStop.signal',
202 122 profile='BaseIPythonApplication.profile',
@@ -37,7 +37,7 b' from zmq.log.handlers import PUBHandler'
37 37 from zmq.utils import jsonapi as json
38 38
39 39 from IPython.config.application import boolean_flag
40 from IPython.core.application import ProfileDir
40 from IPython.core.profiledir import ProfileDir
41 41
42 42 from IPython.parallel.apps.baseapp import (
43 43 BaseParallelApplication,
@@ -80,7 +80,7 b' The IPython controller provides a gateway between the IPython engines and'
80 80 clients. The controller needs to be started before the engines and can be
81 81 configured using command line options or using a cluster directory. Cluster
82 82 directories contain config, log and security files and are usually located in
83 your ipython directory and named as "cluster_<profile>". See the `profile`
83 your ipython directory and named as "profile_name". See the `profile`
84 84 and `profile_dir` options for details.
85 85 """
86 86
@@ -28,7 +28,7 b' import sys'
28 28 import zmq
29 29 from zmq.eventloop import ioloop
30 30
31 from IPython.core.application import ProfileDir
31 from IPython.core.profiledir import ProfileDir
32 32 from IPython.parallel.apps.baseapp import BaseParallelApplication
33 33 from IPython.zmq.log import EnginePUBHandler
34 34
@@ -55,7 +55,7 b' IPython engines run in parallel and perform computations on behalf of a client'
55 55 and controller. A controller needs to be started before the engines. The
56 56 engine can be configured using command line options or using a cluster
57 57 directory. Cluster directories contain config, log and security files and are
58 usually located in your ipython directory and named as "cluster_<profile>".
58 usually located in your ipython directory and named as "profile_name".
59 59 See the `profile` and `profile_dir` options for details.
60 60 """
61 61
@@ -25,7 +25,7 b' import sys'
25 25
26 26 import zmq
27 27
28 from IPython.core.application import ProfileDir
28 from IPython.core.profiledir import ProfileDir
29 29 from IPython.utils.traitlets import Bool, Dict, Unicode
30 30
31 31 from IPython.parallel.apps.baseapp import (
@@ -47,7 +47,7 b' IPython controllers and engines (and your own processes) can broadcast log messa'
47 47 by registering a `zmq.log.handlers.PUBHandler` with the `logging` module. The
48 48 logger can be configured using command line options or using a cluster
49 49 directory. Cluster directories contain config, log and security files and are
50 usually located in your ipython directory and named as "cluster_<profile>".
50 usually located in your ipython directory and named as "profile_name".
51 51 See the `profile` and `profile_dir` options for details.
52 52 """
53 53
@@ -40,7 +40,7 b' from IPython.parallel import util'
40 40 from IPython.zmq.session import Session, Message
41 41
42 42 from .asyncresult import AsyncResult, AsyncHubResult
43 from IPython.core.application import ProfileDir, ProfileDirError
43 from IPython.core.profiledir import ProfileDir, ProfileDirError
44 44 from .view import DirectView, LoadBalancedView
45 45
46 46 #--------------------------------------------------------------------------
@@ -413,13 +413,13 b' def check_for_old_config(ipython_dir=None):'
413 413 if ipython_dir is None:
414 414 ipython_dir = get_ipython_dir()
415 415
416 old_configs = ['ipy_user_conf.py', 'ipythonrc']
416 old_configs = ['ipy_user_conf.py', 'ipythonrc', 'ipython_config.py']
417 417 for cfg in old_configs:
418 418 f = os.path.join(ipython_dir, cfg)
419 419 if os.path.exists(f):
420 420 warn.warn("""Found old IPython config file %r.
421 421 The IPython configuration system has changed as of 0.11, and this file will be ignored.
422 422 See http://ipython.github.com/ipython-doc/dev/config for details on the new config system.
423 The current default config file is 'ipython_config.py', where you can suppress these
424 warnings with `Global.ignore_old_config = True`."""%f)
423 To start configuring IPython, do `ipython profile create`, and edit `ipython_config.py` in
424 <ipython_dir>/profile_default."""%f)
425 425
@@ -68,7 +68,7 b' controller and engines in the following situations:'
68 68 .. note::
69 69
70 70 Currently :command:`ipcluster` requires that the
71 :file:`~/.ipython/cluster_<profile>/security` directory live on a shared filesystem that is
71 :file:`~/.ipython/profile_<name>/security` directory live on a shared filesystem that is
72 72 seen by both the controller and engines. If you don't have a shared file
73 73 system you will need to use :command:`ipcontroller` and
74 74 :command:`ipengine` directly.
@@ -92,7 +92,7 b' Configuring an IPython cluster'
92 92
93 93 Cluster configurations are stored as `profiles`. You can create a new profile with::
94 94
95 $ ipcluster create profile=myprofile
95 $ ipython profile create --cluster profile=myprofile
96 96
97 97 This will create the directory :file:`IPYTHONDIR/cluster_myprofile`, and populate it
98 98 with the default configuration files for the three IPython cluster commands. Once
@@ -133,7 +133,7 b' The mpiexec/mpirun mode is useful if you:'
133 133
134 134 If these are satisfied, you can create a new profile::
135 135
136 $ ipcluster create profile=mpi
136 $ ipython profile create --cluster profile=mpi
137 137
138 138 and edit the file :file:`IPYTHONDIR/cluster_mpi/ipcluster_config.py`.
139 139
@@ -190,7 +190,7 b' The PBS mode uses the Portable Batch System [PBS]_ to start the engines.'
190 190
191 191 As usual, we will start by creating a fresh profile::
192 192
193 $ ipcluster create profile=pbs
193 $ ipython profile create --cluster profile=pbs
194 194
195 195 And in :file:`ipcluster_config.py`, we will select the PBS launchers for the controller
196 196 and engines:
@@ -310,7 +310,7 b' nodes and :command:`ipcontroller` can be run remotely as well, or on localhost.'
310 310
311 311 As usual, we start by creating a clean profile::
312 312
313 $ ipcluster create profile=ssh
313 $ ipython profile create --cluster profile=ssh
314 314
315 315 To use this mode, select the SSH launchers in :file:`ipcluster_config.py`:
316 316
@@ -417,7 +417,7 b' When the controller and engines are running on different hosts, things are'
417 417 slightly more complicated, but the underlying ideas are the same:
418 418
419 419 1. Start the controller on a host using :command:`ipcontroller`.
420 2. Copy :file:`ipcontroller-engine.json` from :file:`~/.ipython/cluster_<profile>/security` on
420 2. Copy :file:`ipcontroller-engine.json` from :file:`~/.ipython/profile_<name>/security` on
421 421 the controller's host to the host where the engines will run.
422 422 3. Use :command:`ipengine` on the engine's hosts to start the engines.
423 423
@@ -425,7 +425,7 b' The only thing you have to be careful of is to tell :command:`ipengine` where'
425 425 the :file:`ipcontroller-engine.json` file is located. There are two ways you
426 426 can do this:
427 427
428 * Put :file:`ipcontroller-engine.json` in the :file:`~/.ipython/cluster_<profile>/security`
428 * Put :file:`ipcontroller-engine.json` in the :file:`~/.ipython/profile_<name>/security`
429 429 directory on the engine's host, where it will be found automatically.
430 430 * Call :command:`ipengine` with the ``--file=full_path_to_the_file``
431 431 flag.
@@ -437,7 +437,7 b' The ``--file`` flag works like this::'
437 437 .. note::
438 438
439 439 If the controller's and engine's hosts all have a shared file system
440 (:file:`~/.ipython/cluster_<profile>/security` is the same on all of them), then things
440 (:file:`~/.ipython/profile_<name>/security` is the same on all of them), then things
441 441 will just work!
442 442
443 443 Make JSON files persistent
@@ -472,7 +472,7 b' Log files'
472 472
473 473 All of the components of IPython have log files associated with them.
474 474 These log files can be extremely useful in debugging problems with
475 IPython and can be found in the directory :file:`~/.ipython/cluster_<profile>/log`.
475 IPython and can be found in the directory :file:`~/.ipython/profile_<name>/log`.
476 476 Sending the log files to us will often help us to debug any problems.
477 477
478 478
@@ -179,7 +179,7 b' describe how to configure and run an IPython cluster on an actual compute'
179 179 cluster running Windows HPC Server 2008. Here is an outline of the needed
180 180 steps:
181 181
182 1. Create a cluster profile using: ``ipcluster create profile=mycluster``
182 1. Create a cluster profile using: ``ipython profile create --cluster profile=mycluster``
183 183
184 184 2. Edit configuration files in the directory :file:`.ipython\\cluster_mycluster`
185 185
@@ -198,13 +198,13 b' directory is a specially named directory (typically located in the'
198 198 :file:`.ipython` subdirectory of your home directory) that contains the
199 199 configuration files for a particular cluster profile, as well as log files and
200 200 security keys. The naming convention for cluster directories is:
201 :file:`cluster_<profile name>`. Thus, the cluster directory for a profile named
201 :file:`profile_<profile name>`. Thus, the cluster directory for a profile named
202 202 "foo" would be :file:`.ipython\\cluster_foo`.
203 203
204 204 To create a new cluster profile (named "mycluster") and the associated cluster
205 205 directory, type the following command at the Windows Command Prompt::
206 206
207 ipcluster create profile=mycluster
207 ipython profile create --cluster profile=mycluster
208 208
209 209 The output of this command is shown in the screenshot below. Notice how
210 210 :command:`ipcluster` prints out the location of the newly created cluster
General Comments 0
You need to be logged in to leave comments. Login now