From 1914e27cff6a9e7701353fa001c0f2cec588cd02 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 17 Nov 2014 11:17:08 -0800 Subject: [PATCH 1/2] Don't pass IPython-specific args to non-IPython kernels add a few FIXME notes that the IPython-kernel special treatment will probably want to be removed in the Jupyter explosion. --- IPython/html/notebookapp.py | 9 +++--- .../html/services/kernels/kernelmanager.py | 28 +++---------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index e76bda80d..b216eca78 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -324,7 +324,7 @@ class NotebookApp(BaseIPythonApplication): list=(NbserverListApp, NbserverListApp.description.splitlines()[0]), ) - kernel_argv = List(Unicode) + ipython_kernel_argv = List(Unicode) _log_formatter_cls = LogFormatter @@ -683,16 +683,17 @@ class NotebookApp(BaseIPythonApplication): self.update_config(c) def init_kernel_argv(self): - """construct the kernel arguments""" + """add the profile-dir to arguments to be passed to IPython kernels""" + # FIXME: remove special treatment of IPython kernels # Kernel should get *absolute* path to profile directory - self.kernel_argv = ["--profile-dir", self.profile_dir.location] + self.ipython_kernel_argv = ["--profile-dir", self.profile_dir.location] def init_configurables(self): # force Session default to be secure default_secure(self.config) kls = import_item(self.kernel_manager_class) self.kernel_manager = kls( - parent=self, log=self.log, kernel_argv=self.kernel_argv, + parent=self, log=self.log, ipython_kernel_argv=self.ipython_kernel_argv, connection_dir = self.profile_dir.security_dir, ) kls = import_item(self.contents_manager_class) diff --git a/IPython/html/services/kernels/kernelmanager.py b/IPython/html/services/kernels/kernelmanager.py index 3132efb6c..22d1a075c 100644 --- a/IPython/html/services/kernels/kernelmanager.py +++ b/IPython/html/services/kernels/kernelmanager.py @@ -1,35 +1,18 @@ -"""A kernel manager relating notebooks and kernels +"""A kernel manager relating notebooks and kernels""" -Authors: - -* Brian Granger -""" - -#----------------------------------------------------------------------------- -# Copyright (C) 2013 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. import os from tornado import web from IPython.kernel.multikernelmanager import MultiKernelManager -from IPython.utils.traitlets import List, Unicode, TraitError +from IPython.utils.traitlets import Unicode, TraitError from IPython.html.utils import to_os_path from IPython.utils.py3compat import getcwd -#----------------------------------------------------------------------------- -# Classes -#----------------------------------------------------------------------------- - class MappingKernelManager(MultiKernelManager): """A KernelManager that handles notebook mapping and HTTP error handling""" @@ -37,8 +20,6 @@ class MappingKernelManager(MultiKernelManager): def _kernel_manager_class_default(self): return "IPython.kernel.ioloop.IOLoopKernelManager" - kernel_argv = List(Unicode) - root_dir = Unicode(getcwd(), config=True) def _root_dir_changed(self, name, old, new): @@ -89,7 +70,6 @@ class MappingKernelManager(MultiKernelManager): an existing kernel is returned, but it may be checked in the future. """ if kernel_id is None: - kwargs['extra_arguments'] = self.kernel_argv if path is not None: kwargs['cwd'] = self.cwd_for_path(path) kernel_id = super(MappingKernelManager, self).start_kernel( From a62a9abdefe445fc1b51e490e3a721a98a207ba6 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 18 Nov 2014 13:29:44 -0800 Subject: [PATCH 2/2] update MappingKernelManager module docstring --- IPython/html/services/kernels/kernelmanager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IPython/html/services/kernels/kernelmanager.py b/IPython/html/services/kernels/kernelmanager.py index 22d1a075c..d135b1373 100644 --- a/IPython/html/services/kernels/kernelmanager.py +++ b/IPython/html/services/kernels/kernelmanager.py @@ -1,4 +1,8 @@ -"""A kernel manager relating notebooks and kernels""" +"""A MultiKernelManager for use in the notebook webserver + +- raises HTTPErrors +- creates REST API models +""" # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License.