Repository: ipython/ipython

Issue:
Reload button on the clusters tab is not working
I had a gazillion IPython profiles in my profile folder from a theme experiment that were all showing up on the `Clusters` tab.
While the IPython server was running, I deleted all these profiles.
When I now click on the reload icon, nothing happens. A web-browser reload also keeps showing the now non-existing profiles.
Version: 2.2
Edit: After restarting the notebook server, the list of non-existing profiles was purged and only the existing profiles are shown.



Discussion:
IIRC reload only reload if the cluster(s) are running or not. 
Not their existence. 

— 
M

Le 8 sept. 2014 à 05:52, K.-Michael Aye notifications@github.com a écrit :

> I had a gazillion IPython profiles in my profile folder from a theme experiment that were all showing up on the Clusters tab.
> While the IPython server was running, I deleted all these profiles.
> When I now click on the reload icon, nothing happens. A web-browser reload also keeps showing the now non-existing profiles.
> Version: 2.2
> 
> —
> Reply to this email directly or view it on GitHub.


Resolving patch:
diff --git a/IPython/html/services/clusters/clustermanager.py b/IPython/html/services/clusters/clustermanager.py
--- a/IPython/html/services/clusters/clustermanager.py
+++ b/IPython/html/services/clusters/clustermanager.py
@@ -1,20 +1,7 @@
-"""Manage IPython.parallel clusters in the notebook.
+"""Manage IPython.parallel clusters in the notebook."""
 
-Authors:
-
-* Brian Granger
-"""
-
-#-----------------------------------------------------------------------------
-#  Copyright (C) 2008-2011  The IPython Development Team
-#
-#  Distributed under the terms of the BSD License.  The full license is in
-#  the file COPYING, distributed as part of this software.
-#-----------------------------------------------------------------------------
-
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
 
 from tornado import web
 from zmq.eventloop import ioloop
@@ -27,13 +14,6 @@
 from IPython.utils.path import get_ipython_dir
 
 
-#-----------------------------------------------------------------------------
-# Classes
-#-----------------------------------------------------------------------------
-
-
-
-
 class ClusterManager(LoggingConfigurable):
 
     profiles = Dict()
@@ -75,16 +55,24 @@ def get_profile_dir(self, name, path):
     def update_profiles(self):
         """List all profiles in the ipython_dir and cwd.
         """
+        
+        stale = set(self.profiles)
         for path in [get_ipython_dir(), py3compat.getcwd()]:
             for profile in list_profiles_in(path):
+                if profile in stale:
+                    stale.remove(profile)
                 pd = self.get_profile_dir(profile, path)
                 if profile not in self.profiles:
-                    self.log.debug("Adding cluster profile '%s'" % profile)
+                    self.log.debug("Adding cluster profile '%s'", profile)
                     self.profiles[profile] = {
                         'profile': profile,
                         'profile_dir': pd,
                         'status': 'stopped'
                     }
+        for profile in stale:
+            # remove profiles that no longer exist
+            self.log.debug("Profile '%s' no longer exists", profile)
+            self.profiles.pop(stale)
 
     def list_profiles(self):
         self.update_profiles()


Test patch: