Skip to content

Commit d0505f4

Browse files
committed
give clients a handle on their parent cluster object, if they have one
easiest way to grant clients access to restart/add_engines APIs, especially since the context manager yields the client, not the cluster itself
1 parent 4b9da9c commit d0505f4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

ipyparallel/client/client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ class Client(HasTraits):
330330
outstanding = Set()
331331
results = Instance('collections.defaultdict', (dict,))
332332
metadata = Instance('collections.defaultdict', (Metadata,))
333+
cluster = Instance('ipyparallel.cluster.Cluster', allow_none=True)
333334
history = List()
334335
debug = Bool(False)
335336
_futures = Dict()
@@ -388,12 +389,14 @@ def __init__(
388389
paramiko=None,
389390
timeout=10,
390391
cluster_id=None,
392+
cluster=None,
391393
**extra_args,
392394
):
395+
396+
super_kwargs = {'debug': debug, 'cluster': cluster}
393397
if profile:
394-
super(Client, self).__init__(debug=debug, profile=profile)
395-
else:
396-
super(Client, self).__init__(debug=debug)
398+
super_kwargs['profile'] = profile
399+
super(Client, self).__init__(**super_kwargs)
397400
if context is None:
398401
context = zmq.Context.instance()
399402
self._context = context

ipyparallel/cluster/cluster.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,9 @@ def connect_client(self):
420420
from ipyparallel import Client
421421

422422
return Client(
423-
parent=self, profile_dir=self.profile_dir, cluster_id=self.cluster_id
423+
cluster=self,
424+
profile_dir=self.profile_dir,
425+
cluster_id=self.cluster_id,
424426
)
425427

426428
# context managers (both async and sync)

0 commit comments

Comments
 (0)