Show More
@@ -12,7 +12,7 b' c = get_config()' | |||
|
12 | 12 | # - Start using mpiexec. |
|
13 | 13 | # - Start using the Windows HPC Server 2008 scheduler |
|
14 | 14 | # - Start using PBS |
|
15 |
# - Start using SSH |
|
|
15 | # - Start using SSH | |
|
16 | 16 | |
|
17 | 17 | |
|
18 | 18 | # The selected launchers can be configured below. |
@@ -22,14 +22,14 b' c = get_config()' | |||
|
22 | 22 | # - MPIExecControllerLauncher |
|
23 | 23 | # - PBSControllerLauncher |
|
24 | 24 | # - WindowsHPCControllerLauncher |
|
25 |
# c.Global.controller_launcher = 'IPython. |
|
|
25 | # c.Global.controller_launcher = 'IPython.zmq.parallel.launcher.LocalControllerLauncher' | |
|
26 | 26 | |
|
27 | 27 | # Options are: |
|
28 | 28 | # - LocalEngineSetLauncher |
|
29 | 29 | # - MPIExecEngineSetLauncher |
|
30 | 30 | # - PBSEngineSetLauncher |
|
31 | 31 | # - WindowsHPCEngineSetLauncher |
|
32 |
# c.Global.engine_launcher = 'IPython. |
|
|
32 | # c.Global.engine_launcher = 'IPython.zmq.parallel.launcher.LocalEngineSetLauncher' | |
|
33 | 33 | |
|
34 | 34 | #----------------------------------------------------------------------------- |
|
35 | 35 | # Global configuration |
@@ -25,112 +25,112 b' c = get_config()' | |||
|
25 | 25 | # be imported in the controller for pickling to work. |
|
26 | 26 | # c.Global.import_statements = ['import math'] |
|
27 | 27 | |
|
28 |
# Reuse the controller's |
|
|
28 | # Reuse the controller's JSON files. If False, JSON files are regenerated | |
|
29 | 29 | # each time the controller is run. If True, they will be reused, *but*, you |
|
30 | 30 | # also must set the network ports by hand. If set, this will override the |
|
31 | 31 | # values set for the client and engine connections below. |
|
32 |
# c.Global.reuse_f |
|
|
32 | # c.Global.reuse_files = True | |
|
33 | 33 | |
|
34 | # Enable SSL encryption on all connections to the controller. If set, this | |
|
35 | # will override the values set for the client and engine connections below. | |
|
34 | # Enable exec_key authentication on all messages. Default is True | |
|
36 | 35 | # c.Global.secure = True |
|
37 | 36 | |
|
38 | 37 | # The working directory for the process. The application will use os.chdir |
|
39 | 38 | # to change to this directory before starting. |
|
40 | 39 | # c.Global.work_dir = os.getcwd() |
|
41 | 40 | |
|
42 | #----------------------------------------------------------------------------- | |
|
43 | # Configure the client services | |
|
44 | #----------------------------------------------------------------------------- | |
|
41 | # The log url for logging to an `iploggerz` application. This will override | |
|
42 | # log-to-file. | |
|
43 | # c.Global.log_url = 'tcp://127.0.0.1:20202' | |
|
45 | 44 | |
|
46 | # Basic client service config attributes | |
|
45 | # The specific external IP that is used to disambiguate multi-interface URLs. | |
|
46 | # The default behavior is to guess from external IPs gleaned from `socket`. | |
|
47 | # c.Global.location = '192.168.1.123' | |
|
47 | 48 | |
|
48 | # The network interface the controller will listen on for client connections. | |
|
49 | # This should be an IP address or hostname of the controller's host. The empty | |
|
50 | # string means listen on all interfaces. | |
|
51 | # c.FCClientServiceFactory.ip = '' | |
|
49 | # The ssh server remote clients should use to connect to this controller. | |
|
50 | # It must be a machine that can see the interface specified in client_ip. | |
|
51 | # The default for client_ip is localhost, in which case the sshserver must | |
|
52 | # be an external IP of the controller machine. | |
|
53 | # c.Global.sshserver = 'controller.example.com' | |
|
54 | ||
|
55 | # the url to use for registration. If set, this overrides engine-ip, | |
|
56 | # engine-transport client-ip,client-transport, and regport. | |
|
57 | # c.RegistrationFactory.url = 'tcp://*:12345' | |
|
52 | 58 | |
|
53 | # The TCP/IP port the controller will listen on for client connections. If 0 | |
|
54 | # a random port will be used. If the controller's host has a firewall running | |
|
55 | # it must allow incoming traffic on this port. | |
|
56 | # c.FCClientServiceFactory.port = 0 | |
|
59 | # the port to use for registration. Clients and Engines both use this | |
|
60 | # port for registration. | |
|
61 | # c.RegistrationFactory.regport = 10101 | |
|
57 | 62 | |
|
58 | # The client learns how to connect to the controller by looking at the | |
|
59 | # location field embedded in the FURL. If this field is empty, all network | |
|
60 | # interfaces that the controller is listening on will be listed. To have the | |
|
61 | # client connect on a particular interface, list it here. | |
|
62 | # c.FCClientServiceFactory.location = '' | |
|
63 | #----------------------------------------------------------------------------- | |
|
64 | # Configure the Task Scheduler | |
|
65 | #----------------------------------------------------------------------------- | |
|
63 | 66 | |
|
64 | # Use SSL encryption for the client connection. | |
|
65 | # c.FCClientServiceFactory.secure = True | |
|
67 | # The routing scheme. 'pure' will use the pure-ZMQ scheduler. Any other | |
|
68 | # value will use a Python scheduler with various routing schemes. | |
|
69 | # python schemes are: lru, weighted, random, twobin. Default is 'weighted'. | |
|
70 | # Note that the pure ZMQ scheduler does not support many features, such as | |
|
71 | # dying engines, dependencies, or engine-subset load-balancing. | |
|
72 | # c.ControllerFactory.scheme = 'pure' | |
|
66 | 73 | |
|
67 | # Reuse the client FURL each time the controller is started. If set, you must | |
|
68 | # also pick a specific network port above (FCClientServiceFactory.port). | |
|
69 | # c.FCClientServiceFactory.reuse_furls = False | |
|
74 | # The pure ZMQ scheduler can limit the number of outstanding tasks per engine | |
|
75 | # by using the ZMQ HWM option. This allows engines with long-running tasks | |
|
76 | # to not steal too many tasks from other engines. The default is 0, which | |
|
77 | # means agressively distribute messages, never waiting for them to finish. | |
|
78 | # c.ControllerFactory.hwm = 1 | |
|
79 | ||
|
80 | # Whether to use Threads or Processes to start the Schedulers. Threads will | |
|
81 | # use less resources, but potentially reduce throughput. Default is to | |
|
82 | # use processes. Note that the a Python scheduler will always be in a Process. | |
|
83 | # c.ControllerFactory.usethreads | |
|
70 | 84 | |
|
71 | 85 | #----------------------------------------------------------------------------- |
|
72 |
# Configure the |
|
|
86 | # Configure the Hub | |
|
73 | 87 | #----------------------------------------------------------------------------- |
|
74 | 88 | |
|
75 | # Basic config attributes for the engine services. | |
|
89 | # Which class to use for the db backend. Currently supported are DictDB (the | |
|
90 | # default), and MongoDB. Uncomment this line to enable MongoDB, which will | |
|
91 | # slow-down the Hub's responsiveness, but also reduce its memory footprint. | |
|
92 | # c.HubFactory.db_class = 'IPython.zmq.parallel.mongodb.MongoDB' | |
|
76 | 93 | |
|
77 | # The network interface the controller will listen on for engine connections. | |
|
78 | # This should be an IP address or hostname of the controller's host. The empty | |
|
79 | # string means listen on all interfaces. | |
|
80 | # c.FCEngineServiceFactory.ip = '' | |
|
94 | # The heartbeat ping frequency. This is the frequency (in ms) at which the | |
|
95 | # Hub pings engines for heartbeats. This determines how quickly the Hub | |
|
96 | # will react to engines coming and going. A lower number means faster response | |
|
97 | # time, but more network activity. The default is 100ms | |
|
98 | # c.HubFactory.ping = 100 | |
|
81 | 99 | |
|
82 | # The TCP/IP port the controller will listen on for engine connections. If 0 | |
|
83 | # a random port will be used. If the controller's host has a firewall running | |
|
84 | # it must allow incoming traffic on this port. | |
|
85 | # c.FCEngineServiceFactory.port = 0 | |
|
100 | # HubFactory queue port pairs, to set by name: mux, iopub, control, task. Set | |
|
101 | # each as a tuple of length 2 of ints. The default is to find random | |
|
102 | # available ports | |
|
103 | # c.HubFactory.mux = (10102,10112) | |
|
86 | 104 | |
|
87 | # The engine learns how to connect to the controller by looking at the | |
|
88 | # location field embedded in the FURL. If this field is empty, all network | |
|
89 | # interfaces that the controller is listening on will be listed. To have the | |
|
90 | # client connect on a particular interface, list it here. | |
|
91 | # c.FCEngineServiceFactory.location = '' | |
|
105 | #----------------------------------------------------------------------------- | |
|
106 | # Configure the client connections | |
|
107 | #----------------------------------------------------------------------------- | |
|
92 | 108 | |
|
93 | # Use SSL encryption for the engine connection. | |
|
94 | # c.FCEngineServiceFactory.secure = True | |
|
109 | # Basic client connection config attributes | |
|
110 | ||
|
111 | # The network interface the controller will listen on for client connections. | |
|
112 | # This should be an IP address or interface on the controller. An asterisk | |
|
113 | # means listen on all interfaces. The transport can be any transport | |
|
114 | # supported by zeromq (tcp,epgm,pgm,ib,ipc): | |
|
115 | # c.HubFactory.client_ip = '*' | |
|
116 | # c.HubFactory.client_transport = 'tcp' | |
|
95 | 117 | |
|
96 | # Reuse the client FURL each time the controller is started. If set, you must | |
|
97 | # also pick a specific network port above (FCClientServiceFactory.port). | |
|
98 | # c.FCEngineServiceFactory.reuse_furls = False | |
|
118 | # individual client ports to configure by name: query_port, notifier_port | |
|
119 | # c.HubFactory.query_port = 12345 | |
|
99 | 120 | |
|
100 | 121 | #----------------------------------------------------------------------------- |
|
101 | # Developer level configuration attributes | |
|
122 | # Configure the engine connections | |
|
102 | 123 | #----------------------------------------------------------------------------- |
|
103 | 124 | |
|
104 | # You shouldn't have to modify anything in this section. These attributes | |
|
105 | # are more for developers who want to change the behavior of the controller | |
|
106 | # at a fundamental level. | |
|
107 | ||
|
108 | # c.FCClientServiceFactory.cert_file = u'ipcontroller-client.pem' | |
|
109 | ||
|
110 | # default_client_interfaces = Config() | |
|
111 | # default_client_interfaces.Task.interface_chain = [ | |
|
112 | # 'IPython.kernel.task.ITaskController', | |
|
113 | # 'IPython.kernel.taskfc.IFCTaskController' | |
|
114 | # ] | |
|
115 | # | |
|
116 | # default_client_interfaces.Task.furl_file = u'ipcontroller-tc.furl' | |
|
117 | # | |
|
118 | # default_client_interfaces.MultiEngine.interface_chain = [ | |
|
119 | # 'IPython.kernel.multiengine.IMultiEngine', | |
|
120 | # 'IPython.kernel.multienginefc.IFCSynchronousMultiEngine' | |
|
121 | # ] | |
|
122 | # | |
|
123 | # default_client_interfaces.MultiEngine.furl_file = u'ipcontroller-mec.furl' | |
|
124 | # | |
|
125 | # c.FCEngineServiceFactory.interfaces = default_client_interfaces | |
|
126 | ||
|
127 | # c.FCEngineServiceFactory.cert_file = u'ipcontroller-engine.pem' | |
|
128 | ||
|
129 | # default_engine_interfaces = Config() | |
|
130 | # default_engine_interfaces.Default.interface_chain = [ | |
|
131 | # 'IPython.kernel.enginefc.IFCControllerBase' | |
|
132 | # ] | |
|
133 | # | |
|
134 | # default_engine_interfaces.Default.furl_file = u'ipcontroller-engine.furl' | |
|
135 | # | |
|
136 | # c.FCEngineServiceFactory.interfaces = default_engine_interfaces | |
|
125 | # Basic config attributes for the engine connections. | |
|
126 | ||
|
127 | # The network interface the controller will listen on for engine connections. | |
|
128 | # This should be an IP address or interface on the controller. An asterisk | |
|
129 | # means listen on all interfaces. The transport can be any transport | |
|
130 | # supported by zeromq (tcp,epgm,pgm,ib,ipc): | |
|
131 | # c.HubFactory.engine_ip = '*' | |
|
132 | # c.HubFactory.engine_transport = 'tcp' | |
|
133 | ||
|
134 | # set the engine heartbeat ports to use: | |
|
135 | # c.HubFactory.hb = (10303,10313) | |
|
136 |
@@ -29,10 +29,10 b' c = get_config()' | |||
|
29 | 29 | # c.Global.connect_delay = 0.1 |
|
30 | 30 | # c.Global.connect_max_tries = 15 |
|
31 | 31 | |
|
32 |
# By default, the engine will look for the controller's |
|
|
33 |
# cluster directory. Sometimes, the |
|
|
34 |
# attribute can be set to the full path of the |
|
|
35 | # c.Global.furl_file = u'' | |
|
32 | # By default, the engine will look for the controller's JSON file in its own | |
|
33 | # cluster directory. Sometimes, the JSON file will be elsewhere and this | |
|
34 | # attribute can be set to the full path of the JSON file. | |
|
35 | # c.Global.url_file = u'/path/to/my/ipcontroller-engine.json' | |
|
36 | 36 | |
|
37 | 37 | # The working directory for the process. The application will use os.chdir |
|
38 | 38 | # to change to this directory before starting. |
@@ -78,12 +78,7 b' c = get_config()' | |||
|
78 | 78 | |
|
79 | 79 | # You should not have to change these attributes. |
|
80 | 80 | |
|
81 | # c.Global.shell_class = 'IPython.kernel.core.interpreter.Interpreter' | |
|
82 | ||
|
83 | # c.Global.furl_file_name = u'ipcontroller-engine.furl' | |
|
84 | ||
|
85 | ||
|
86 | ||
|
81 | # c.Global.url_file_name = u'ipcontroller-engine.furl' | |
|
87 | 82 | |
|
88 | 83 | |
|
89 | 84 |
@@ -18,7 +18,7 b' import logging' | |||
|
18 | 18 | from multiprocessing import Process |
|
19 | 19 | |
|
20 | 20 | import zmq |
|
21 | ||
|
21 | from zmq.devices import ProcessMonitoredQueue | |
|
22 | 22 | # internal: |
|
23 | 23 | from IPython.utils.importstring import import_item |
|
24 | 24 | from IPython.utils.traitlets import Int, Str, Instance, List, Bool |
@@ -38,6 +38,8 b' class ControllerFactory(HubFactory):' | |||
|
38 | 38 | """Configurable for setting up a Hub and Schedulers.""" |
|
39 | 39 | |
|
40 | 40 | usethreads = Bool(False, config=True) |
|
41 | # pure-zmq downstream HWM | |
|
42 | hwm = Int(0, config=True) | |
|
41 | 43 | |
|
42 | 44 | # internal |
|
43 | 45 | children = List() |
@@ -52,22 +54,28 b' class ControllerFactory(HubFactory):' | |||
|
52 | 54 | |
|
53 | 55 | def start(self): |
|
54 | 56 | super(ControllerFactory, self).start() |
|
57 | child_procs = [] | |
|
55 | 58 | for child in self.children: |
|
56 | 59 | child.start() |
|
57 | if not self.usethreads: | |
|
58 | signal_children([ getattr(c, 'launcher', c) for c in self.children ]) | |
|
60 | if isinstance(child, ProcessMonitoredQueue): | |
|
61 | child_procs.append(child.launcher) | |
|
62 | elif isinstance(child, Process): | |
|
63 | child_procs.append(child) | |
|
64 | if child_procs: | |
|
65 | signal_children(child_procs) | |
|
59 | 66 | |
|
60 | 67 | |
|
61 | 68 | def construct_schedulers(self): |
|
62 | 69 | children = self.children |
|
63 | 70 | mq = import_item(self.mq_class) |
|
64 | 71 | |
|
72 | maybe_inproc = 'inproc://monitor' if self.usethreads else self.monitor_url | |
|
65 | 73 | # IOPub relay (in a Process) |
|
66 | 74 | q = mq(zmq.PUB, zmq.SUB, zmq.PUB, 'N/A','iopub') |
|
67 | 75 | q.bind_in(self.client_info['iopub']) |
|
68 | 76 | q.bind_out(self.engine_info['iopub']) |
|
69 | 77 | q.setsockopt_out(zmq.SUBSCRIBE, '') |
|
70 |
q.connect_mon( |
|
|
78 | q.connect_mon(maybe_inproc) | |
|
71 | 79 | q.daemon=True |
|
72 | 80 | children.append(q) |
|
73 | 81 | |
@@ -75,7 +83,7 b' class ControllerFactory(HubFactory):' | |||
|
75 | 83 | q = mq(zmq.XREP, zmq.XREP, zmq.PUB, 'in', 'out') |
|
76 | 84 | q.bind_in(self.client_info['mux']) |
|
77 | 85 | q.bind_out(self.engine_info['mux']) |
|
78 |
q.connect_mon( |
|
|
86 | q.connect_mon(maybe_inproc) | |
|
79 | 87 | q.daemon=True |
|
80 | 88 | children.append(q) |
|
81 | 89 | |
@@ -83,16 +91,17 b' class ControllerFactory(HubFactory):' | |||
|
83 | 91 | q = mq(zmq.XREP, zmq.XREP, zmq.PUB, 'incontrol', 'outcontrol') |
|
84 | 92 | q.bind_in(self.client_info['control']) |
|
85 | 93 | q.bind_out(self.engine_info['control']) |
|
86 |
q.connect_mon( |
|
|
94 | q.connect_mon(maybe_inproc) | |
|
87 | 95 | q.daemon=True |
|
88 | 96 | children.append(q) |
|
89 | 97 | # Task Queue (in a Process) |
|
90 | 98 | if self.scheme == 'pure': |
|
91 | 99 | self.log.warn("task::using pure XREQ Task scheduler") |
|
92 | 100 | q = mq(zmq.XREP, zmq.XREQ, zmq.PUB, 'intask', 'outtask') |
|
101 | q.setsockopt_out(zmq.HWM, self.hwm) | |
|
93 | 102 | q.bind_in(self.client_info['task'][1]) |
|
94 | 103 | q.bind_out(self.engine_info['task']) |
|
95 |
q.connect_mon( |
|
|
104 | q.connect_mon(maybe_inproc) | |
|
96 | 105 | q.daemon=True |
|
97 | 106 | children.append(q) |
|
98 | 107 | elif self.scheme == 'none': |
@@ -26,7 +26,7 b' from zmq.eventloop.zmqstream import ZMQStream' | |||
|
26 | 26 | |
|
27 | 27 | # internal: |
|
28 | 28 | from IPython.config.configurable import Configurable |
|
29 | from IPython.utils.traitlets import HasTraits, Instance, Int, Str, Dict, Set, List, Bool | |
|
29 | from IPython.utils.traitlets import HasTraits, Instance, Int, CStr, Str, Dict, Set, List, Bool | |
|
30 | 30 | from IPython.utils.importstring import import_item |
|
31 | 31 | |
|
32 | 32 | from entry_point import select_random_ports |
@@ -138,18 +138,18 b' class HubFactory(RegistrationFactory):' | |||
|
138 | 138 | |
|
139 | 139 | ping = Int(1000, config=True) # ping frequency |
|
140 | 140 | |
|
141 | engine_ip = Str('127.0.0.1', config=True) | |
|
142 | engine_transport = Str('tcp', config=True) | |
|
141 | engine_ip = CStr('127.0.0.1', config=True) | |
|
142 | engine_transport = CStr('tcp', config=True) | |
|
143 | 143 | |
|
144 | client_ip = Str('127.0.0.1', config=True) | |
|
145 | client_transport = Str('tcp', config=True) | |
|
144 | client_ip = CStr('127.0.0.1', config=True) | |
|
145 | client_transport = CStr('tcp', config=True) | |
|
146 | 146 | |
|
147 | monitor_ip = Str('127.0.0.1', config=True) | |
|
148 | monitor_transport = Str('tcp', config=True) | |
|
147 | monitor_ip = CStr('127.0.0.1', config=True) | |
|
148 | monitor_transport = CStr('tcp', config=True) | |
|
149 | 149 | |
|
150 | monitor_url = Str('') | |
|
150 | monitor_url = CStr('') | |
|
151 | 151 | |
|
152 | db_class = Str('IPython.zmq.parallel.dictdb.DictDB', config=True) | |
|
152 | db_class = CStr('IPython.zmq.parallel.dictdb.DictDB', config=True) | |
|
153 | 153 | |
|
154 | 154 | # not configurable |
|
155 | 155 | db = Instance('IPython.zmq.parallel.dictdb.BaseDB') |
@@ -234,6 +234,7 b' class HubFactory(RegistrationFactory):' | |||
|
234 | 234 | sub = ctx.socket(zmq.SUB) |
|
235 | 235 | sub.setsockopt(zmq.SUBSCRIBE, "") |
|
236 | 236 | sub.bind(self.monitor_url) |
|
237 | sub.bind('inproc://monitor') | |
|
237 | 238 | sub = ZMQStream(sub, loop) |
|
238 | 239 | |
|
239 | 240 | # connect the db |
@@ -38,7 +38,7 b' from IPython.zmq.parallel.clusterdir import (' | |||
|
38 | 38 | #----------------------------------------------------------------------------- |
|
39 | 39 | |
|
40 | 40 | |
|
41 | default_config_file_name = u'ipcluster_config.py' | |
|
41 | default_config_file_name = u'ipclusterz_config.py' | |
|
42 | 42 | |
|
43 | 43 | |
|
44 | 44 | _description = """\ |
@@ -49,7 +49,7 b' from util import disambiguate_ip_address, split_url' | |||
|
49 | 49 | |
|
50 | 50 | |
|
51 | 51 | #: The default config file name for this application |
|
52 | default_config_file_name = u'ipcontroller_config.py' | |
|
52 | default_config_file_name = u'ipcontrollerz_config.py' | |
|
53 | 53 | |
|
54 | 54 | |
|
55 | 55 | _description = """Start the IPython controller for parallel computing. |
@@ -58,7 +58,7 b' The IPython controller provides a gateway between the IPython engines and' | |||
|
58 | 58 | clients. The controller needs to be started before the engines and can be |
|
59 | 59 | configured using command line options or using a cluster directory. Cluster |
|
60 | 60 | directories contain config, log and security files and are usually located in |
|
61 |
your |
|
|
61 | your ipython directory and named as "cluster_<profile>". See the --profile | |
|
62 | 62 | and --cluster-dir options for details. |
|
63 | 63 | """ |
|
64 | 64 | |
@@ -189,6 +189,7 b' class IPControllerAppConfigLoader(ClusterDirConfigLoader):' | |||
|
189 | 189 | help='The (2) ports the IOPub scheduler will listen on for client,engine ' |
|
190 | 190 | 'connections, respectively [default: random]', |
|
191 | 191 | metavar='Scheduler.iopub_ports') |
|
192 | ||
|
192 | 193 | paa('--scheme', |
|
193 | 194 | type=str, dest='HubFactory.scheme', |
|
194 | 195 | choices = ['pure', 'lru', 'plainrandom', 'weighted', 'twobin','leastload'], |
@@ -198,6 +199,12 b' class IPControllerAppConfigLoader(ClusterDirConfigLoader):' | |||
|
198 | 199 | dest='ControllerFactory.usethreads', action="store_true", |
|
199 | 200 | help='Use threads instead of processes for the schedulers', |
|
200 | 201 | ) |
|
202 | paa('--hwm', | |
|
203 | dest='ControllerFactory.hwm', type=int, | |
|
204 | help='specify the High Water Mark (HWM) for the downstream ' | |
|
205 | 'socket in the pure ZMQ scheduler. This is the maximum number ' | |
|
206 | 'of allowed outstanding tasks on each engine.', | |
|
207 | ) | |
|
201 | 208 | |
|
202 | 209 | ## Global config |
|
203 | 210 | paa('--log-to-file', |
@@ -206,9 +213,9 b' class IPControllerAppConfigLoader(ClusterDirConfigLoader):' | |||
|
206 | 213 | paa('--log-url', |
|
207 | 214 | type=str, dest='Global.log_url', |
|
208 | 215 | help='Broadcast logs to an iploggerz process [default: disabled]') |
|
209 |
paa('-r','--reuse- |
|
|
210 |
action='store_true', dest='Global.reuse_ |
|
|
211 |
help='Try to reuse existing |
|
|
216 | paa('-r','--reuse-files', | |
|
217 | action='store_true', dest='Global.reuse_files', | |
|
218 | help='Try to reuse existing json connection files.') | |
|
212 | 219 | paa('--no-secure', |
|
213 | 220 | action='store_false', dest='Global.secure', |
|
214 | 221 | help='Turn off execution keys (default).') |
@@ -255,7 +262,7 b' class IPControllerApp(ApplicationWithClusterDir):' | |||
|
255 | 262 | self.default_config.Global.import_statements = [] |
|
256 | 263 | self.default_config.Global.clean_logs = True |
|
257 | 264 | self.default_config.Global.secure = True |
|
258 |
self.default_config.Global.reuse_ |
|
|
265 | self.default_config.Global.reuse_files = False | |
|
259 | 266 | self.default_config.Global.exec_key = "exec_key.key" |
|
260 | 267 | self.default_config.Global.sshserver = None |
|
261 | 268 | self.default_config.Global.location = None |
@@ -293,24 +300,53 b' class IPControllerApp(ApplicationWithClusterDir):' | |||
|
293 | 300 | with open(fname, 'w') as f: |
|
294 | 301 | f.write(json.dumps(cdict, indent=2)) |
|
295 | 302 | os.chmod(fname, stat.S_IRUSR|stat.S_IWUSR) |
|
303 | ||
|
304 | def load_config_from_json(self): | |
|
305 | """load config from existing json connector files.""" | |
|
306 | c = self.master_config | |
|
307 | # load from engine config | |
|
308 | with open(os.path.join(c.Global.security_dir, 'ipcontroller-engine.json')) as f: | |
|
309 | cfg = json.loads(f.read()) | |
|
310 | key = c.SessionFactory.exec_key = cfg['exec_key'] | |
|
311 | xport,addr = cfg['url'].split('://') | |
|
312 | c.HubFactory.engine_transport = xport | |
|
313 | ip,ports = addr.split(':') | |
|
314 | c.HubFactory.engine_ip = ip | |
|
315 | c.HubFactory.regport = int(ports) | |
|
316 | c.Global.location = cfg['location'] | |
|
296 | 317 | |
|
318 | # load client config | |
|
319 | with open(os.path.join(c.Global.security_dir, 'ipcontroller-client.json')) as f: | |
|
320 | cfg = json.loads(f.read()) | |
|
321 | assert key == cfg['exec_key'], "exec_key mismatch between engine and client keys" | |
|
322 | xport,addr = cfg['url'].split('://') | |
|
323 | c.HubFactory.client_transport = xport | |
|
324 | ip,ports = addr.split(':') | |
|
325 | c.HubFactory.client_ip = ip | |
|
326 | c.Global.sshserver = cfg['ssh'] | |
|
327 | assert int(ports) == c.HubFactory.regport, "regport mismatch" | |
|
328 | ||
|
297 | 329 | def construct(self): |
|
298 | 330 | # This is the working dir by now. |
|
299 | 331 | sys.path.insert(0, '') |
|
300 | 332 | c = self.master_config |
|
301 | 333 | |
|
302 | 334 | self.import_statements() |
|
303 | ||
|
304 |
if |
|
|
335 | reusing = c.Global.reuse_files | |
|
336 | if reusing: | |
|
337 | try: | |
|
338 | self.load_config_from_json() | |
|
339 | except (AssertionError,IOError): | |
|
340 | reusing=False | |
|
341 | # check again, because reusing may have failed: | |
|
342 | if reusing: | |
|
343 | pass | |
|
344 | elif c.Global.secure: | |
|
305 | 345 | keyfile = os.path.join(c.Global.security_dir, c.Global.exec_key) |
|
306 | if not c.Global.reuse_key or not os.path.exists(keyfile): | |
|
307 | key = str(uuid.uuid4()) | |
|
308 |
wit |
|
|
309 | f.write(key) | |
|
310 | os.chmod(keyfile, stat.S_IRUSR|stat.S_IWUSR) | |
|
311 | else: | |
|
312 | with open(keyfile) as f: | |
|
313 | key = f.read().strip() | |
|
346 | key = str(uuid.uuid4()) | |
|
347 | with open(keyfile, 'w') as f: | |
|
348 | f.write(key) | |
|
349 | os.chmod(keyfile, stat.S_IRUSR|stat.S_IWUSR) | |
|
314 | 350 | c.SessionFactory.exec_key = key |
|
315 | 351 | else: |
|
316 | 352 | c.SessionFactory.exec_key = '' |
@@ -324,16 +360,18 b' class IPControllerApp(ApplicationWithClusterDir):' | |||
|
324 | 360 | self.log.error("Couldn't construct the Controller", exc_info=True) |
|
325 | 361 | self.exit(1) |
|
326 | 362 | |
|
327 | f = self.factory | |
|
328 | cdict = {'exec_key' : key, | |
|
329 | 'ssh' : c.Global.sshserver, | |
|
330 | 'url' : "%s://%s:%s"%(f.client_transport, f.client_ip, f.regport), | |
|
331 |
' |
|
|
332 | } | |
|
333 | self.save_connection_dict('ipcontroller-client.json', cdict) | |
|
334 | edict = cdict | |
|
335 | edict['url']="%s://%s:%s"%((f.client_transport, f.client_ip, f.regport)) | |
|
336 | self.save_connection_dict('ipcontroller-engine.json', edict) | |
|
363 | if not reusing: | |
|
364 | # save to new json config files | |
|
365 | f = self.factory | |
|
366 | cdict = {'exec_key' : key, | |
|
367 | 'ssh' : c.Global.sshserver, | |
|
368 | 'url' : "%s://%s:%s"%(f.client_transport, f.client_ip, f.regport), | |
|
369 | 'location' : c.Global.location | |
|
370 | } | |
|
371 | self.save_connection_dict('ipcontroller-client.json', cdict) | |
|
372 | edict = cdict | |
|
373 | edict['url']="%s://%s:%s"%((f.client_transport, f.client_ip, f.regport)) | |
|
374 | self.save_connection_dict('ipcontroller-engine.json', edict) | |
|
337 | 375 | |
|
338 | 376 | |
|
339 | 377 | def save_urls(self): |
@@ -40,7 +40,7 b' from util import disambiguate_url' | |||
|
40 | 40 | #----------------------------------------------------------------------------- |
|
41 | 41 | |
|
42 | 42 | #: The default config file name for this application |
|
43 | default_config_file_name = u'ipengine_config.py' | |
|
43 | default_config_file_name = u'ipenginez_config.py' | |
|
44 | 44 | |
|
45 | 45 | |
|
46 | 46 | mpi4py_init = """from mpi4py import MPI as mpi |
@@ -64,7 +64,7 b' IPython engines run in parallel and perform computations on behalf of a client' | |||
|
64 | 64 | and controller. A controller needs to be started before the engines. The |
|
65 | 65 | engine can be configured using command line options or using a cluster |
|
66 | 66 | directory. Cluster directories contain config, log and security files and are |
|
67 |
usually located in your |
|
|
67 | usually located in your ipython directory and named as "cluster_<profile>". | |
|
68 | 68 | See the --profile and --cluster-dir options for details. |
|
69 | 69 | """ |
|
70 | 70 | |
@@ -79,7 +79,7 b' class IPEngineAppConfigLoader(ClusterDirConfigLoader):' | |||
|
79 | 79 | super(IPEngineAppConfigLoader, self)._add_arguments() |
|
80 | 80 | paa = self.parser.add_argument |
|
81 | 81 | # Controller config |
|
82 | paa('--file', | |
|
82 | paa('--file', '-f', | |
|
83 | 83 | type=unicode, dest='Global.url_file', |
|
84 | 84 | help='The full location of the file containing the connection information fo ' |
|
85 | 85 | 'controller. If this is not given, the file must be in the ' |
@@ -39,7 +39,7 b' IPython controllers and engines (and your own processes) can broadcast log messa' | |||
|
39 | 39 | by registering a `zmq.log.handlers.PUBHandler` with the `logging` module. The |
|
40 | 40 | logger can be configured using command line options or using a cluster |
|
41 | 41 | directory. Cluster directories contain config, log and security files and are |
|
42 |
usually located in your |
|
|
42 | usually located in your ipython directory and named as "cluster_<profile>". | |
|
43 | 43 | See the --profile and --cluster-dir options for details. |
|
44 | 44 | """ |
|
45 | 45 |
General Comments 0
You need to be logged in to leave comments.
Login now