Skip to content

Commit 1a68cf2

Browse files
committed
fix parent-app lookup of clusters
app is not always immediate parent (e.g. ClusterManager)
1 parent bac7f97 commit 1a68cf2

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

ipyparallel/cluster/cluster.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,26 @@ def _profile_config_default(self):
293293

294294
from .app import BaseParallelApplication, IPClusterStart
295295

296+
# look up if we are descended from an 'ipcluster' app
297+
# avoids repeated load of the current profile dir
298+
parents = []
299+
parent = self.parent
300+
while parent is not None:
301+
parents.append(parent)
302+
parent = parent.parent
303+
304+
app_parents = list(
305+
filter(lambda p: isinstance(p, BaseParallelApplication), parents)
306+
)
307+
if app_parents:
308+
app_parent = app_parents[0]
309+
else:
310+
app_parent = None
311+
296312
if (
297-
self.parent
298-
and isinstance(self.parent, BaseParallelApplication)
299-
and self.parent.name == 'ipcluster'
300-
and self.parent.profile_dir.location == self.profile_dir
313+
app_parent
314+
and app_parent.name == 'ipcluster'
315+
and app_parent.profile_dir.location == self.profile_dir
301316
):
302317
# profile config already loaded by parent, nothing new to load
303318
return Config()
@@ -308,7 +323,7 @@ def _profile_config_default(self):
308323
config.ProfileDir.location = self.profile_dir
309324

310325
# load profile config via IPCluster
311-
app = IPClusterStart(config=config, log=self.log, log_level=10)
326+
app = IPClusterStart(config=config, log=self.log)
312327
# adds profile dir to config_files_path
313328
app.init_profile_dir()
314329
# adds system to config_files_path

0 commit comments

Comments
 (0)