|
7 | 7 | import asyncio
|
8 | 8 | import inspect
|
9 | 9 | import logging
|
| 10 | +import os |
10 | 11 | import random
|
11 | 12 | import socket
|
12 | 13 | import string
|
|
24 | 25 | from traitlets import Float
|
25 | 26 | from traitlets import Integer
|
26 | 27 | from traitlets import List
|
27 |
| -from traitlets import Type |
28 | 28 | from traitlets import Unicode
|
29 |
| -from traitlets import validate |
30 | 29 | from traitlets.config import LoggingConfigurable
|
31 | 30 |
|
32 | 31 | from . import launcher
|
@@ -106,7 +105,7 @@ def _default_profile_dir(self):
|
106 | 105 | If you are using one of IPython's builtin launchers, you can specify just the
|
107 | 106 | prefix, e.g:
|
108 | 107 |
|
109 |
| - c.IPClusterStart.controller_launcher_class = 'SSH' |
| 108 | + c.Cluster.controller_launcher_class = 'SSH' |
110 | 109 |
|
111 | 110 | or:
|
112 | 111 |
|
@@ -145,7 +144,7 @@ def _default_profile_dir(self):
|
145 | 144 | If you are using one of IPython's builtin launchers, you can specify just the
|
146 | 145 | prefix, e.g:
|
147 | 146 |
|
148 |
| - c.IPClusterEngines.engine_launcher_class = 'SSH' |
| 147 | + c.Cluster.engine_launcher_class = 'SSH' |
149 | 148 |
|
150 | 149 | or:
|
151 | 150 |
|
@@ -206,6 +205,26 @@ def _default_log(self):
|
206 | 205 | _controller = Any()
|
207 | 206 | _engine_sets = Dict()
|
208 | 207 |
|
| 208 | + def __repr__(self): |
| 209 | + profile_dir = self.profile_dir |
| 210 | + home_dir = os.path.expanduser("~") |
| 211 | + if profile_dir.startswith(home_dir + os.path.sep): |
| 212 | + # truncate $HOME/. -> ~/... |
| 213 | + profile_dir = "~" + profile_dir[len(home_dir) :] |
| 214 | + |
| 215 | + fields = { |
| 216 | + "cluster_id": repr(self.cluster_id), |
| 217 | + "profile_dir": repr(profile_dir), |
| 218 | + } |
| 219 | + if self._controller: |
| 220 | + fields["controller"] = "<running>" |
| 221 | + if self._engine_sets: |
| 222 | + fields["engine_sets"] = list(self._engine_sets) |
| 223 | + |
| 224 | + fields_str = ', '.join(f"{key}={value}" for key, value in fields.items()) |
| 225 | + |
| 226 | + return f"<{self.__class__.__name__}({fields_str})>" |
| 227 | + |
209 | 228 | @classmethod
|
210 | 229 | def from_json(self, json_dict):
|
211 | 230 | """Construct a Cluster from serialized state"""
|
|
0 commit comments