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