diff --git a/notebook/base/handlers.py b/notebook/base/handlers.py index 88ffb0a30f..83cc41335e 100644 --- a/notebook/base/handlers.py +++ b/notebook/base/handlers.py @@ -166,10 +166,6 @@ def kernel_manager(self): def contents_manager(self): return self.settings['contents_manager'] - @property - def cluster_manager(self): - return self.settings['cluster_manager'] - @property def session_manager(self): return self.settings['session_manager'] diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 0dfbd25a52..9e29aa2805 100644 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -59,7 +59,6 @@ from .services.config import ConfigManager from .services.contents.manager import ContentsManager from .services.contents.filemanager import FileContentsManager -from .services.clusters.clustermanager import ClusterManager from .services.sessions.sessionmanager import SessionManager from .auth.login import LoginHandler @@ -134,12 +133,12 @@ def get(self, url_path): class NotebookWebApplication(web.Application): def __init__(self, ipython_app, kernel_manager, contents_manager, - cluster_manager, session_manager, kernel_spec_manager, + session_manager, kernel_spec_manager, config_manager, log, base_url, default_url, settings_overrides, jinja_env_options): settings = self.init_settings( - ipython_app, kernel_manager, contents_manager, cluster_manager, + ipython_app, kernel_manager, contents_manager, session_manager, kernel_spec_manager, config_manager, log, base_url, default_url, settings_overrides, jinja_env_options) handlers = self.init_handlers(settings) @@ -147,7 +146,7 @@ def __init__(self, ipython_app, kernel_manager, contents_manager, super(NotebookWebApplication, self).__init__(handlers, **settings) def init_settings(self, ipython_app, kernel_manager, contents_manager, - cluster_manager, session_manager, kernel_spec_manager, + session_manager, kernel_spec_manager, config_manager, log, base_url, default_url, settings_overrides, jinja_env_options=None): @@ -197,7 +196,6 @@ def init_settings(self, ipython_app, kernel_manager, contents_manager, # managers kernel_manager=kernel_manager, contents_manager=contents_manager, - cluster_manager=cluster_manager, session_manager=session_manager, kernel_spec_manager=kernel_spec_manager, config_manager=config_manager, @@ -233,7 +231,6 @@ def init_handlers(self, settings): handlers.extend(load_handlers('services.config.handlers')) handlers.extend(load_handlers('services.kernels.handlers')) handlers.extend(load_handlers('services.contents.handlers')) - handlers.extend(load_handlers('services.clusters.handlers')) handlers.extend(load_handlers('services.sessions.handlers')) handlers.extend(load_handlers('services.nbconvert.handlers')) handlers.extend(load_handlers('services.kernelspecs.handlers')) @@ -661,11 +658,6 @@ def _mathjax_url_changed(self, name, old, new): config=True, help='The session manager class to use.' ) - cluster_manager_class = Type( - default_value=ClusterManager, - config=True, - help='The cluster manager class to use.' - ) config_manager_class = Type( default_value=ConfigManager, @@ -803,11 +795,6 @@ def init_configurables(self): kernel_manager=self.kernel_manager, contents_manager=self.contents_manager, ) - self.cluster_manager = self.cluster_manager_class( - parent=self, - log=self.log, - ) - self.config_manager = self.config_manager_class( parent=self, log=self.log, @@ -841,7 +828,7 @@ def init_webapp(self): self.web_app = NotebookWebApplication( self, self.kernel_manager, self.contents_manager, - self.cluster_manager, self.session_manager, self.kernel_spec_manager, + self.session_manager, self.kernel_spec_manager, self.config_manager, self.log, self.base_url, self.default_url, self.tornado_settings, self.jinja_environment_options diff --git a/notebook/services/clusters/__init__.py b/notebook/services/clusters/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/notebook/services/clusters/clustermanager.py b/notebook/services/clusters/clustermanager.py deleted file mode 100644 index 5d5a3799b6..0000000000 --- a/notebook/services/clusters/clustermanager.py +++ /dev/null @@ -1,172 +0,0 @@ -"""Manage IPython parallel clusters in the notebook.""" - -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -import os - -from tornado import web - -from traitlets.config.configurable import LoggingConfigurable -from traitlets import Dict, Instance, Float -from ipython_genutils import py3compat - - -class ClusterManager(LoggingConfigurable): - - profiles = Dict() - - delay = Float(1., config=True, - help="delay (in s) between starting the controller and the engines") - - loop = Instance('zmq.eventloop.ioloop.IOLoop') - def _loop_default(self): - from zmq.eventloop.ioloop import IOLoop - return IOLoop.instance() - - def build_launchers(self, profile_dir): - from ipyparallel.apps.ipclusterapp import IPClusterStart - - class DummyIPClusterStart(IPClusterStart): - """Dummy subclass to skip init steps that conflict with global app. - - Instantiating and initializing this class should result in fully configured - launchers, but no other side effects or state. - """ - - def init_signal(self): - pass - def reinit_logging(self): - pass - - starter = DummyIPClusterStart(log=self.log) - starter.initialize(['--profile-dir', profile_dir]) - cl = starter.controller_launcher - esl = starter.engine_launcher - n = starter.n - return cl, esl, n - - def get_profile_dir(self, name, path): - from IPython.core.profiledir import ProfileDir - p = ProfileDir.find_profile_dir_by_name(path,name=name) - return p.location - - def update_profiles(self): - """List all profiles in the ipython_dir and cwd. - """ - try: - from IPython.paths import get_ipython_dir - from IPython.core.profileapp import list_profiles_in - except ImportError as e: - self.log.info("IPython not available: %s", e) - return - stale = set(self.profiles) - for path in [get_ipython_dir(), py3compat.getcwd()]: - if not os.path.isdir(path): - continue - 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.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(profile) - - def list_profiles(self): - try: - self.update_profiles() - except ImportError: - return [] - # sorted list, but ensure that 'default' always comes first - default_first = lambda name: name if name != 'default' else '' - result = [self.profile_info(p) for p in sorted(self.profiles, key=default_first)] - return result - - def check_profile(self, profile): - if profile not in self.profiles: - raise web.HTTPError(404, u'profile not found') - - def profile_info(self, profile): - self.check_profile(profile) - result = {} - data = self.profiles.get(profile) - result['profile'] = profile - result['profile_dir'] = data['profile_dir'] - result['status'] = data['status'] - if 'n' in data: - result['n'] = data['n'] - return result - - def start_cluster(self, profile, n=None): - """Start a cluster for a given profile.""" - self.check_profile(profile) - data = self.profiles[profile] - if data['status'] == 'running': - raise web.HTTPError(409, u'cluster already running') - cl, esl, default_n = self.build_launchers(data['profile_dir']) - n = n if n is not None else default_n - def clean_data(): - data.pop('controller_launcher',None) - data.pop('engine_set_launcher',None) - data.pop('n',None) - data['status'] = 'stopped' - def engines_stopped(r): - self.log.debug('Engines stopped') - if cl.running: - cl.stop() - clean_data() - esl.on_stop(engines_stopped) - def controller_stopped(r): - self.log.debug('Controller stopped') - if esl.running: - esl.stop() - clean_data() - cl.on_stop(controller_stopped) - loop = self.loop - - def start(): - """start the controller, then the engines after a delay""" - cl.start() - loop.add_timeout(self.loop.time() + self.delay, lambda : esl.start(n)) - self.loop.add_callback(start) - - self.log.debug('Cluster started') - data['controller_launcher'] = cl - data['engine_set_launcher'] = esl - data['n'] = n - data['status'] = 'running' - return self.profile_info(profile) - - def stop_cluster(self, profile): - """Stop a cluster for a given profile.""" - self.check_profile(profile) - data = self.profiles[profile] - if data['status'] == 'stopped': - raise web.HTTPError(409, u'cluster not running') - data = self.profiles[profile] - cl = data['controller_launcher'] - esl = data['engine_set_launcher'] - if cl.running: - cl.stop() - if esl.running: - esl.stop() - # Return a temp info dict, the real one is updated in the on_stop - # logic above. - result = { - 'profile': data['profile'], - 'profile_dir': data['profile_dir'], - 'status': 'stopped' - } - return result - - def stop_all_clusters(self): - for p in self.profiles.keys(): - self.stop_cluster(p) diff --git a/notebook/services/clusters/handlers.py b/notebook/services/clusters/handlers.py deleted file mode 100644 index a9447b66f2..0000000000 --- a/notebook/services/clusters/handlers.py +++ /dev/null @@ -1,59 +0,0 @@ -"""Tornado handlers for cluster web service.""" - -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -import json - -from tornado import web - -from ...base.handlers import IPythonHandler - -#----------------------------------------------------------------------------- -# Cluster handlers -#----------------------------------------------------------------------------- - - -class MainClusterHandler(IPythonHandler): - - @web.authenticated - def get(self): - self.finish(json.dumps(self.cluster_manager.list_profiles())) - - -class ClusterProfileHandler(IPythonHandler): - - @web.authenticated - def get(self, profile): - self.finish(json.dumps(self.cluster_manager.profile_info(profile))) - - -class ClusterActionHandler(IPythonHandler): - - @web.authenticated - def post(self, profile, action): - cm = self.cluster_manager - if action == 'start': - n = self.get_argument('n', default=None) - if not n: - data = cm.start_cluster(profile) - else: - data = cm.start_cluster(profile, int(n)) - if action == 'stop': - data = cm.stop_cluster(profile) - self.finish(json.dumps(data)) - - -#----------------------------------------------------------------------------- -# URL to handler mappings -#----------------------------------------------------------------------------- - - -_cluster_action_regex = r"(?Pstart|stop)" -_profile_regex = r"(?P[^\/]+)" # there is almost no text that is invalid - -default_handlers = [ - (r"/clusters", MainClusterHandler), - (r"/clusters/%s/%s" % (_profile_regex, _cluster_action_regex), ClusterActionHandler), - (r"/clusters/%s" % _profile_regex, ClusterProfileHandler), -] diff --git a/notebook/static/tree/js/clusterlist.js b/notebook/static/tree/js/clusterlist.js deleted file mode 100644 index d60149f97d..0000000000 --- a/notebook/static/tree/js/clusterlist.js +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) Jupyter Development Team. -// Distributed under the terms of the Modified BSD License. - -define([ - 'jquery', - 'base/js/utils', -], function($, utils) { - "use strict"; - - var ClusterList = function (selector, options) { - this.selector = selector; - if (this.selector !== undefined) { - this.element = $(selector); - this.style(); - this.bind_events(); - } - options = options || {}; - this.options = options; - this.base_url = options.base_url || utils.get_body_data("baseUrl"); - this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath"); - }; - - ClusterList.prototype.style = function () { - $('#cluster_list').addClass('list_container'); - $('#cluster_toolbar').addClass('list_toolbar'); - $('#cluster_list_info').addClass('toolbar_info'); - $('#cluster_buttons').addClass('toolbar_buttons'); - }; - - - ClusterList.prototype.bind_events = function () { - var that = this; - $('#refresh_cluster_list').click(function () { - that.load_list(); - }); - }; - - - ClusterList.prototype.load_list = function () { - var settings = { - processData : false, - cache : false, - type : "GET", - dataType : "json", - success : $.proxy(this.load_list_success, this), - error : utils.log_ajax_error, - }; - var url = utils.url_join_encode(this.base_url, 'clusters'); - $.ajax(url, settings); - }; - - - ClusterList.prototype.clear_list = function () { - this.element.children('.list_item').remove(); - }; - - ClusterList.prototype.load_list_success = function (data, status, xhr) { - this.clear_list(); - var len = data.length; - for (var i=0; i'); - var item = new ClusterItem(element, this.options); - item.update_state(data[i]); - element.data('item', item); - this.element.append(element); - } - }; - - - var ClusterItem = function (element, options) { - this.element = $(element); - this.base_url = options.base_url || utils.get_body_data("baseUrl"); - this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath"); - this.data = null; - this.style(); - }; - - ClusterItem.prototype.style = function () { - this.element.addClass('list_item').addClass("row"); - }; - - ClusterItem.prototype.update_state = function (data) { - this.data = data; - if (data.status === 'running') { - this.state_running(); - } else if (data.status === 'stopped') { - this.state_stopped(); - } - }; - - - ClusterItem.prototype.state_stopped = function () { - var that = this; - var profile_col = $('
').addClass('profile_col col-xs-4').text(this.data.profile); - var status_col = $('
').addClass('status_col col-xs-3').text('stopped'); - var engines_col = $('
').addClass('engine_col col-xs-3'); - var input = $('').attr('type','number') - .attr('min',1) - .attr('size',3) - .addClass('engine_num_input form-control'); - engines_col.append(input); - var start_button = $('
-
+
-
-
- IPython parallel computing clusters -
-
- - - -
-
-
-
-
profile
-
status
-
# of engines
-
action
-
-
+ Clusters tab is now provided by IPython parallel. + See IPython parallel for installation details.
diff --git a/notebook/tree/handlers.py b/notebook/tree/handlers.py index a1ad1354b5..f199ffaa44 100644 --- a/notebook/tree/handlers.py +++ b/notebook/tree/handlers.py @@ -9,7 +9,7 @@ class TreeHandler(IPythonHandler): - """Render the tree view, listing notebooks, clusters, etc.""" + """Render the tree view, listing notebooks, etc.""" def generate_breadcrumbs(self, path): breadcrumbs = [(url_escape(url_path_join(self.base_url, 'tree')), '')]