Show More
@@ -362,6 +362,7 b' class ArgParseConfigLoader(CommandLineConfigLoader):' | |||
|
362 | 362 | self.parser.add_argument(*argument[0],**argument[1]) |
|
363 | 363 | |
|
364 | 364 | def _add_other_arguments(self): |
|
365 | """Meant for subclasses to add their own arguments.""" | |
|
365 | 366 | pass |
|
366 | 367 | |
|
367 | 368 | def _parse_args(self, args): |
@@ -27,7 +27,6 b' from IPython.core import release' | |||
|
27 | 27 | from IPython.config.loader import PyFileConfigLoader |
|
28 | 28 | from IPython.core.application import Application |
|
29 | 29 | from IPython.core.component import Component |
|
30 | from IPython.config.loader import ArgParseConfigLoader, NoConfigDefault | |
|
31 | 30 | from IPython.utils.traitlets import Unicode, Bool |
|
32 | 31 | from IPython.utils import genutils |
|
33 | 32 | |
@@ -219,55 +218,38 b' class ClusterDir(Component):' | |||
|
219 | 218 | return ClusterDir(cluster_dir) |
|
220 | 219 | |
|
221 | 220 | |
|
222 | class AppWithClusterDirArgParseConfigLoader(ArgParseConfigLoader): | |
|
223 | """Default command line options for IPython cluster applications.""" | |
|
224 | ||
|
225 | def _add_other_arguments(self): | |
|
226 | self.parser.add_argument('--ipython-dir', | |
|
221 | # Default command line options for IPython cluster applications. | |
|
222 | cl_args = ( | |
|
223 | (('--ipython-dir',), dict( | |
|
227 | 224 |
|
|
228 | 225 |
|
|
229 | default=NoConfigDefault, | |
|
230 | metavar='Global.ipython_dir' | |
|
231 | ) | |
|
232 | self.parser.add_argument('-p', '--profile', | |
|
226 | metavar='Global.ipython_dir') ), | |
|
227 | (('-p', '--profile',), dict( | |
|
233 | 228 |
|
|
234 | help='The string name of the profile to be used. This determines ' | |
|
235 | 'the name of the cluster dir as: cluster_<profile>. The default profile ' | |
|
236 | 'is named "default". The cluster directory is resolve this way ' | |
|
237 | 'if the --cluster-dir option is not used.', | |
|
238 | default=NoConfigDefault, | |
|
239 |
|
|
|
240 | ) | |
|
241 | self.parser.add_argument('--log-level', | |
|
242 | dest="Global.log_level",type=int, | |
|
243 | help='Set the log level (0,10,20,30,40,50). Default is 30.', | |
|
244 | default=NoConfigDefault, | |
|
245 | metavar="Global.log_level" | |
|
246 | ) | |
|
247 | self.parser.add_argument('--cluster-dir', | |
|
229 | help= | |
|
230 | """The string name of the profile to be used. This determines the name | |
|
231 | of the cluster dir as: cluster_<profile>. The default profile is named | |
|
232 | 'default'. The cluster directory is resolve this way if the | |
|
233 | --cluster-dir option is not used.""", | |
|
234 | metavar='Global.profile') ), | |
|
235 | (('--cluster-dir',), dict( | |
|
248 | 236 |
|
|
249 |
|
|
|
250 |
|
|
|
251 | default=NoConfigDefault, | |
|
252 | metavar='Global.cluster_dir' | |
|
253 | ), | |
|
254 | self.parser.add_argument('--work-dir', | |
|
237 | help="""Set the cluster dir. This overrides the logic used by the | |
|
238 | --profile option.""", | |
|
239 | metavar='Global.cluster_dir') ), | |
|
240 | (('--work-dir',), dict( | |
|
255 | 241 |
|
|
256 | 242 |
|
|
257 | default=NoConfigDefault, | |
|
258 | metavar='Global.work_dir' | |
|
259 | ) | |
|
260 | self.parser.add_argument('--clean-logs', | |
|
243 | metavar='Global.work_dir') ), | |
|
244 | (('--clean-logs',), dict( | |
|
261 | 245 |
|
|
262 |
|
|
|
263 | default=NoConfigDefault | |
|
264 | ) | |
|
265 | self.parser.add_argument('--no-clean-logs', | |
|
246 | help='Delete old log flies before starting.') ), | |
|
247 | (('--no-clean-logs',), dict( | |
|
266 | 248 |
|
|
267 |
|
|
|
268 | default=NoConfigDefault | |
|
249 | help="Don't Delete old log flies before starting.") ), | |
|
269 | 250 |
|
|
270 | 251 | |
|
252 | ||
|
271 | 253 | class ApplicationWithClusterDir(Application): |
|
272 | 254 | """An application that puts everything into a cluster directory. |
|
273 | 255 | |
@@ -289,6 +271,8 b' class ApplicationWithClusterDir(Application):' | |||
|
289 | 271 | |
|
290 | 272 | auto_create_cluster_dir = True |
|
291 | 273 | |
|
274 | cl_arguments = Application.cl_arguments + cl_args | |
|
275 | ||
|
292 | 276 | def create_default_config(self): |
|
293 | 277 | super(ApplicationWithClusterDir, self).create_default_config() |
|
294 | 278 | self.default_config.Global.profile = u'default' |
@@ -297,13 +281,6 b' class ApplicationWithClusterDir(Application):' | |||
|
297 | 281 | self.default_config.Global.log_to_file = False |
|
298 | 282 | self.default_config.Global.clean_logs = False |
|
299 | 283 | |
|
300 | def create_command_line_config(self): | |
|
301 | """Create and return a command line config loader.""" | |
|
302 | return AppWithClusterDirArgParseConfigLoader( | |
|
303 | description=self.description, | |
|
304 | version=release.version | |
|
305 | ) | |
|
306 | ||
|
307 | 284 | def find_resources(self): |
|
308 | 285 | """This resolves the cluster directory. |
|
309 | 286 | |
@@ -471,5 +448,3 b' class ApplicationWithClusterDir(Application):' | |||
|
471 | 448 | return pid |
|
472 | 449 | else: |
|
473 | 450 | raise PIDFileError('pid file not found: %s' % pid_file) |
|
474 | ||
|
475 |
@@ -18,13 +18,12 b' The ipcluster application.' | |||
|
18 | 18 | import logging |
|
19 | 19 | import os |
|
20 | 20 | import signal |
|
21 | import sys | |
|
22 | 21 | |
|
23 | 22 | if os.name=='posix': |
|
24 | 23 | from twisted.scripts._twistd_unix import daemonize |
|
25 | 24 | |
|
26 | 25 | from IPython.core import release |
|
27 |
from IPython.external import |
|
|
26 | from IPython.external.argparse import ArgumentParser | |
|
28 | 27 | from IPython.config.loader import ArgParseConfigLoader, NoConfigDefault |
|
29 | 28 | from IPython.utils.importstring import import_item |
|
30 | 29 | |
@@ -54,44 +53,40 b' ALREADY_STOPPED = 11' | |||
|
54 | 53 | |
|
55 | 54 | class IPClusterCLLoader(ArgParseConfigLoader): |
|
56 | 55 | |
|
57 | def _add_arguments(self): | |
|
56 | def _add_other_arguments(self): | |
|
58 | 57 | # This has all the common options that all subcommands use |
|
59 |
parent_parser1 = |
|
|
58 | parent_parser1 = ArgumentParser(add_help=False, | |
|
59 | argument_default=NoConfigDefault) | |
|
60 | 60 | parent_parser1.add_argument('--ipython-dir', |
|
61 | 61 | dest='Global.ipython_dir',type=unicode, |
|
62 | 62 | help='Set to override default location of Global.ipython_dir.', |
|
63 | default=NoConfigDefault, | |
|
64 | 63 | metavar='Global.ipython_dir') |
|
65 | 64 | parent_parser1.add_argument('--log-level', |
|
66 | 65 | dest="Global.log_level",type=int, |
|
67 | 66 | help='Set the log level (0,10,20,30,40,50). Default is 30.', |
|
68 | default=NoConfigDefault, | |
|
69 | 67 | metavar='Global.log_level') |
|
70 | 68 | |
|
71 | 69 | # This has all the common options that other subcommands use |
|
72 |
parent_parser2 = |
|
|
70 | parent_parser2 = ArgumentParser(add_help=False, | |
|
71 | argument_default=NoConfigDefault) | |
|
73 | 72 | parent_parser2.add_argument('-p','--profile', |
|
74 | 73 | dest='Global.profile',type=unicode, |
|
75 | 74 | help='The string name of the profile to be used. This determines ' |
|
76 | 75 | 'the name of the cluster dir as: cluster_<profile>. The default profile ' |
|
77 | 76 | 'is named "default". The cluster directory is resolve this way ' |
|
78 | 77 | 'if the --cluster-dir option is not used.', |
|
79 | default=NoConfigDefault, | |
|
80 | 78 | metavar='Global.profile') |
|
81 | 79 | parent_parser2.add_argument('--cluster-dir', |
|
82 | 80 | dest='Global.cluster_dir',type=unicode, |
|
83 | 81 | help='Set the cluster dir. This overrides the logic used by the ' |
|
84 | 82 | '--profile option.', |
|
85 | default=NoConfigDefault, | |
|
86 | 83 | metavar='Global.cluster_dir'), |
|
87 | 84 | parent_parser2.add_argument('--work-dir', |
|
88 | 85 | dest='Global.work_dir',type=unicode, |
|
89 | 86 | help='Set the working dir for the process.', |
|
90 | default=NoConfigDefault, | |
|
91 | 87 | metavar='Global.work_dir') |
|
92 | 88 | parent_parser2.add_argument('--log-to-file', |
|
93 | 89 | action='store_true', dest='Global.log_to_file', |
|
94 | default=NoConfigDefault, | |
|
95 | 90 | help='Log to a file in the log directory (default is stdout)' |
|
96 | 91 | ) |
|
97 | 92 | |
@@ -130,29 +125,24 b' class IPClusterCLLoader(ArgParseConfigLoader):' | |||
|
130 | 125 | parser_start.add_argument( |
|
131 | 126 | '-n', '--number', |
|
132 | 127 | type=int, dest='Global.n', |
|
133 | default=NoConfigDefault, | |
|
134 | 128 | help='The number of engines to start.', |
|
135 | 129 | metavar='Global.n' |
|
136 | 130 | ) |
|
137 | 131 | parser_start.add_argument('--clean-logs', |
|
138 | 132 | dest='Global.clean_logs', action='store_true', |
|
139 | 133 | help='Delete old log flies before starting.', |
|
140 | default=NoConfigDefault | |
|
141 | 134 | ) |
|
142 | 135 | parser_start.add_argument('--no-clean-logs', |
|
143 | 136 | dest='Global.clean_logs', action='store_false', |
|
144 | 137 | help="Don't delete old log flies before starting.", |
|
145 | default=NoConfigDefault | |
|
146 | 138 | ) |
|
147 | 139 | parser_start.add_argument('--daemon', |
|
148 | 140 | dest='Global.daemonize', action='store_true', |
|
149 | 141 | help='Daemonize the ipcluster program. This implies --log-to-file', |
|
150 | default=NoConfigDefault | |
|
151 | 142 | ) |
|
152 | 143 | parser_start.add_argument('--no-daemon', |
|
153 | 144 | dest='Global.daemonize', action='store_false', |
|
154 | 145 | help="Dont't daemonize the ipcluster program.", |
|
155 | default=NoConfigDefault | |
|
156 | 146 | ) |
|
157 | 147 | |
|
158 | 148 | parser_start = subparsers.add_parser( |
@@ -164,7 +154,6 b' class IPClusterCLLoader(ArgParseConfigLoader):' | |||
|
164 | 154 | dest='Global.signal', type=int, |
|
165 | 155 | help="The signal number to use in stopping the cluster (default=2).", |
|
166 | 156 | metavar="Global.signal", |
|
167 | default=NoConfigDefault | |
|
168 | 157 | ) |
|
169 | 158 | |
|
170 | 159 | |
@@ -372,8 +361,8 b' class IPClusterApp(ApplicationWithClusterDir):' | |||
|
372 | 361 | log.msg('Unexpected error in ipcluster:') |
|
373 | 362 | log.msg(r.getTraceback()) |
|
374 | 363 | log.msg("IPython cluster: stopping") |
|
375 |
|
|
|
376 |
|
|
|
364 | self.stop_engines() | |
|
365 | self.stop_controller() | |
|
377 | 366 | # Wait a few seconds to let things shut down. |
|
378 | 367 | reactor.callLater(4.0, reactor.stop) |
|
379 | 368 |
@@ -26,25 +26,17 b' from twisted.internet import reactor' | |||
|
26 | 26 | from twisted.python import log |
|
27 | 27 | |
|
28 | 28 | from IPython.config.loader import Config, NoConfigDefault |
|
29 | ||
|
30 | from IPython.kernel.clusterdir import ( | |
|
31 | ApplicationWithClusterDir, | |
|
32 | AppWithClusterDirArgParseConfigLoader | |
|
33 | ) | |
|
34 | ||
|
35 | 29 | from IPython.core import release |
|
36 | ||
|
37 | from IPython.utils.traitlets import Str, Instance, Unicode | |
|
38 | ||
|
30 | from IPython.core.application import Application | |
|
39 | 31 | from IPython.kernel import controllerservice |
|
40 | ||
|
32 | from IPython.kernel.clusterdir import ApplicationWithClusterDir | |
|
41 | 33 | from IPython.kernel.fcutil import FCServiceFactory |
|
34 | from IPython.utils.traitlets import Str, Instance, Unicode | |
|
42 | 35 | |
|
43 | 36 | #----------------------------------------------------------------------------- |
|
44 | 37 | # Default interfaces |
|
45 | 38 | #----------------------------------------------------------------------------- |
|
46 | 39 | |
|
47 | ||
|
48 | 40 | # The default client interfaces for FCClientServiceFactory.interfaces |
|
49 | 41 | default_client_interfaces = Config() |
|
50 | 42 | default_client_interfaces.Task.interface_chain = [ |
@@ -107,19 +99,19 b' class FCEngineServiceFactory(FCServiceFactory):' | |||
|
107 | 99 | cl_args = ( |
|
108 | 100 | # Client config |
|
109 | 101 | (('--client-ip',), dict( |
|
110 |
type=str, dest='FCClientServiceFactory.ip', |
|
|
102 | type=str, dest='FCClientServiceFactory.ip', | |
|
111 | 103 | help='The IP address or hostname the controller will listen on for ' |
|
112 | 104 | 'client connections.', |
|
113 | 105 | metavar='FCClientServiceFactory.ip') |
|
114 | 106 | ), |
|
115 | 107 | (('--client-port',), dict( |
|
116 |
type=int, dest='FCClientServiceFactory.port', |
|
|
108 | type=int, dest='FCClientServiceFactory.port', | |
|
117 | 109 | help='The port the controller will listen on for client connections. ' |
|
118 | 110 | 'The default is to use 0, which will autoselect an open port.', |
|
119 | 111 | metavar='FCClientServiceFactory.port') |
|
120 | 112 | ), |
|
121 | 113 | (('--client-location',), dict( |
|
122 |
type=str, dest='FCClientServiceFactory.location', |
|
|
114 | type=str, dest='FCClientServiceFactory.location', | |
|
123 | 115 | help='The hostname or IP that clients should connect to. This does ' |
|
124 | 116 | 'not control which interface the controller listens on. Instead, this ' |
|
125 | 117 | 'determines the hostname/IP that is listed in the FURL, which is how ' |
@@ -129,19 +121,19 b' cl_args = (' | |||
|
129 | 121 | ), |
|
130 | 122 | # Engine config |
|
131 | 123 | (('--engine-ip',), dict( |
|
132 |
type=str, dest='FCEngineServiceFactory.ip', |
|
|
124 | type=str, dest='FCEngineServiceFactory.ip', | |
|
133 | 125 | help='The IP address or hostname the controller will listen on for ' |
|
134 | 126 | 'engine connections.', |
|
135 | 127 | metavar='FCEngineServiceFactory.ip') |
|
136 | 128 | ), |
|
137 | 129 | (('--engine-port',), dict( |
|
138 |
type=int, dest='FCEngineServiceFactory.port', |
|
|
130 | type=int, dest='FCEngineServiceFactory.port', | |
|
139 | 131 | help='The port the controller will listen on for engine connections. ' |
|
140 | 132 | 'The default is to use 0, which will autoselect an open port.', |
|
141 | 133 | metavar='FCEngineServiceFactory.port') |
|
142 | 134 | ), |
|
143 | 135 | (('--engine-location',), dict( |
|
144 |
type=str, dest='FCEngineServiceFactory.location', |
|
|
136 | type=str, dest='FCEngineServiceFactory.location', | |
|
145 | 137 | help='The hostname or IP that engines should connect to. This does ' |
|
146 | 138 | 'not control which interface the controller listens on. Instead, this ' |
|
147 | 139 | 'determines the hostname/IP that is listed in the FURL, which is how ' |
@@ -151,31 +143,26 b' cl_args = (' | |||
|
151 | 143 | ), |
|
152 | 144 | # Global config |
|
153 | 145 | (('--log-to-file',), dict( |
|
154 |
action='store_true', dest='Global.log_to_file', |
|
|
146 | action='store_true', dest='Global.log_to_file', | |
|
155 | 147 | help='Log to a file in the log directory (default is stdout)') |
|
156 | 148 | ), |
|
157 | 149 | (('-r','--reuse-furls'), dict( |
|
158 |
action='store_true', dest='Global.reuse_furls', |
|
|
150 | action='store_true', dest='Global.reuse_furls', | |
|
159 | 151 | help='Try to reuse all FURL files. If this is not set all FURL files ' |
|
160 | 152 | 'are deleted before the controller starts. This must be set if ' |
|
161 | 153 | 'specific ports are specified by --engine-port or --client-port.') |
|
162 | 154 | ), |
|
163 | 155 | (('--no-secure',), dict( |
|
164 |
action='store_false', dest='Global.secure', |
|
|
156 | action='store_false', dest='Global.secure', | |
|
165 | 157 | help='Turn off SSL encryption for all connections.') |
|
166 | 158 | ), |
|
167 | 159 | (('--secure',), dict( |
|
168 |
action='store_true', dest='Global.secure', |
|
|
160 | action='store_true', dest='Global.secure', | |
|
169 | 161 | help='Turn off SSL encryption for all connections.') |
|
170 | 162 | ) |
|
171 | 163 | ) |
|
172 | 164 | |
|
173 | 165 | |
|
174 | class IPControllerAppCLConfigLoader(AppWithClusterDirArgParseConfigLoader): | |
|
175 | ||
|
176 | arguments = cl_args | |
|
177 | ||
|
178 | ||
|
179 | 166 | _description = """Start the IPython controller for parallel computing. |
|
180 | 167 | |
|
181 | 168 | The IPython controller provides a gateway between the IPython engines and |
@@ -195,6 +182,7 b' class IPControllerApp(ApplicationWithClusterDir):' | |||
|
195 | 182 | description = _description |
|
196 | 183 | config_file_name = default_config_file_name |
|
197 | 184 | auto_create_cluster_dir = True |
|
185 | cl_arguments = Application.cl_arguments + cl_args | |
|
198 | 186 | |
|
199 | 187 | def create_default_config(self): |
|
200 | 188 | super(IPControllerApp, self).create_default_config() |
@@ -203,13 +191,6 b' class IPControllerApp(ApplicationWithClusterDir):' | |||
|
203 | 191 | self.default_config.Global.import_statements = [] |
|
204 | 192 | self.default_config.Global.clean_logs = True |
|
205 | 193 | |
|
206 | def create_command_line_config(self): | |
|
207 | """Create and return a command line config loader.""" | |
|
208 | return IPControllerAppCLConfigLoader( | |
|
209 | description=self.description, | |
|
210 | version=release.version | |
|
211 | ) | |
|
212 | ||
|
213 | 194 | def post_load_command_line_config(self): |
|
214 | 195 | # Now setup reuse_furls |
|
215 | 196 | c = self.command_line_config |
@@ -272,4 +253,3 b' def launch_new_instance():' | |||
|
272 | 253 | |
|
273 | 254 | if __name__ == '__main__': |
|
274 | 255 | launch_new_instance() |
|
275 |
@@ -22,29 +22,21 b' from twisted.application import service' | |||
|
22 | 22 | from twisted.internet import reactor |
|
23 | 23 | from twisted.python import log |
|
24 | 24 | |
|
25 | from IPython.config.loader import NoConfigDefault | |
|
26 | ||
|
27 |
from IPython.kernel. |
|
|
28 | ApplicationWithClusterDir, | |
|
29 | AppWithClusterDirArgParseConfigLoader | |
|
30 | ) | |
|
31 | from IPython.core import release | |
|
32 | ||
|
33 | from IPython.utils.importstring import import_item | |
|
34 | ||
|
25 | from IPython.core.application import Application | |
|
26 | from IPython.kernel.clusterdir import ApplicationWithClusterDir | |
|
27 | from IPython.kernel.engineconnector import EngineConnector | |
|
35 | 28 | from IPython.kernel.engineservice import EngineService |
|
36 | 29 | from IPython.kernel.fcutil import Tub |
|
37 | from IPython.kernel.engineconnector import EngineConnector | |
|
30 | from IPython.utils.importstring import import_item | |
|
38 | 31 | |
|
39 | 32 | #----------------------------------------------------------------------------- |
|
40 | 33 | # The main application |
|
41 | 34 | #----------------------------------------------------------------------------- |
|
42 | 35 | |
|
43 | ||
|
44 | 36 | cl_args = ( |
|
45 | 37 | # Controller config |
|
46 | 38 | (('--furl-file',), dict( |
|
47 |
type=unicode, dest='Global.furl_file', |
|
|
39 | type=unicode, dest='Global.furl_file', | |
|
48 | 40 | help='The full location of the file containing the FURL of the ' |
|
49 | 41 | 'controller. If this is not given, the FURL file must be in the ' |
|
50 | 42 | 'security directory of the cluster directory. This location is ' |
@@ -53,23 +45,18 b' cl_args = (' | |||
|
53 | 45 | ), |
|
54 | 46 | # MPI |
|
55 | 47 | (('--mpi',), dict( |
|
56 |
type=str, dest='MPI.use', |
|
|
48 | type=str, dest='MPI.use', | |
|
57 | 49 | help='How to enable MPI (mpi4py, pytrilinos, or empty string to disable).', |
|
58 | 50 | metavar='MPI.use') |
|
59 | 51 | ), |
|
60 | 52 | # Global config |
|
61 | 53 | (('--log-to-file',), dict( |
|
62 |
action='store_true', dest='Global.log_to_file', |
|
|
54 | action='store_true', dest='Global.log_to_file', | |
|
63 | 55 | help='Log to a file in the log directory (default is stdout)') |
|
64 | 56 | ) |
|
65 | 57 | ) |
|
66 | 58 | |
|
67 | 59 | |
|
68 | class IPEngineAppCLConfigLoader(AppWithClusterDirArgParseConfigLoader): | |
|
69 | ||
|
70 | arguments = cl_args | |
|
71 | ||
|
72 | ||
|
73 | 60 | mpi4py_init = """from mpi4py import MPI as mpi |
|
74 | 61 | mpi.size = mpi.COMM_WORLD.Get_size() |
|
75 | 62 | mpi.rank = mpi.COMM_WORLD.Get_rank() |
@@ -104,6 +91,7 b' class IPEngineApp(ApplicationWithClusterDir):' | |||
|
104 | 91 | description = _description |
|
105 | 92 | config_file_name = default_config_file_name |
|
106 | 93 | auto_create_cluster_dir = True |
|
94 | cl_arguments = Application.cl_arguments + cl_args | |
|
107 | 95 | |
|
108 | 96 | def create_default_config(self): |
|
109 | 97 | super(IPEngineApp, self).create_default_config() |
@@ -134,13 +122,6 b' class IPEngineApp(ApplicationWithClusterDir):' | |||
|
134 | 122 | self.default_config.MPI.mpi4py = mpi4py_init |
|
135 | 123 | self.default_config.MPI.pytrilinos = pytrilinos_init |
|
136 | 124 | |
|
137 | def create_command_line_config(self): | |
|
138 | """Create and return a command line config loader.""" | |
|
139 | return IPEngineAppCLConfigLoader( | |
|
140 | description=self.description, | |
|
141 | version=release.version | |
|
142 | ) | |
|
143 | ||
|
144 | 125 | def post_load_command_line_config(self): |
|
145 | 126 | pass |
|
146 | 127 |
General Comments 0
You need to be logged in to leave comments.
Login now