##// END OF EJS Templates
Rename KernelBase & Kernel to Kernel & IPythonKernel
Thomas Kluyver -
Show More
@@ -45,7 +45,7 b' class InProcessKernelClient(KernelClient):'
45 stdin_channel_class = Type(InProcessStdInChannel)
45 stdin_channel_class = Type(InProcessStdInChannel)
46 hb_channel_class = Type(InProcessHBChannel)
46 hb_channel_class = Type(InProcessHBChannel)
47
47
48 kernel = Instance('IPython.kernel.inprocess.ipkernel.Kernel')
48 kernel = Instance('IPython.kernel.inprocess.ipkernel.InProcessKernel')
49
49
50 #--------------------------------------------------------------------------
50 #--------------------------------------------------------------------------
51 # Channel management methods
51 # Channel management methods
@@ -10,7 +10,7 b' import sys'
10 from IPython.core.interactiveshell import InteractiveShellABC
10 from IPython.core.interactiveshell import InteractiveShellABC
11 from IPython.utils.jsonutil import json_clean
11 from IPython.utils.jsonutil import json_clean
12 from IPython.utils.traitlets import Any, Enum, Instance, List, Type
12 from IPython.utils.traitlets import Any, Enum, Instance, List, Type
13 from IPython.kernel.zmq.ipkernel import Kernel
13 from IPython.kernel.zmq.ipkernel import IPythonKernel
14 from IPython.kernel.zmq.zmqshell import ZMQInteractiveShell
14 from IPython.kernel.zmq.zmqshell import ZMQInteractiveShell
15
15
16 from .socket import DummySocket
16 from .socket import DummySocket
@@ -19,7 +19,7 b' from .socket import DummySocket'
19 # Main kernel class
19 # Main kernel class
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21
21
22 class InProcessKernel(Kernel):
22 class InProcessKernel(IPythonKernel):
23
23
24 #-------------------------------------------------------------------------
24 #-------------------------------------------------------------------------
25 # InProcessKernel interface
25 # InProcessKernel interface
@@ -8,12 +8,13 b' from IPython.core import release'
8 from IPython.utils.py3compat import builtin_mod, PY3
8 from IPython.utils.py3compat import builtin_mod, PY3
9 from IPython.utils.tokenutil import token_at_cursor
9 from IPython.utils.tokenutil import token_at_cursor
10 from IPython.utils.traitlets import Instance, Type, Any
10 from IPython.utils.traitlets import Instance, Type, Any
11 from IPython.utils.decorators import undoc
11
12
12 from .kernelbase import KernelBase
13 from .kernelbase import Kernel as KernelBase
13 from .serialize import serialize_object, unpack_apply_message
14 from .serialize import serialize_object, unpack_apply_message
14 from .zmqshell import ZMQInteractiveShell
15 from .zmqshell import ZMQInteractiveShell
15
16
16 class Kernel(KernelBase):
17 class IPythonKernel(KernelBase):
17 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
18 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
18 shell_class = Type(ZMQInteractiveShell)
19 shell_class = Type(ZMQInteractiveShell)
19
20
@@ -34,7 +35,7 b' class Kernel(KernelBase):'
34 _sys_eval_input = Any()
35 _sys_eval_input = Any()
35
36
36 def __init__(self, **kwargs):
37 def __init__(self, **kwargs):
37 super(Kernel, self).__init__(**kwargs)
38 super(IPythonKernel, self).__init__(**kwargs)
38
39
39 # Initialize the InteractiveShell subclass
40 # Initialize the InteractiveShell subclass
40 self.shell = self.shell_class.instance(parent=self,
41 self.shell = self.shell_class.instance(parent=self,
@@ -70,13 +71,13 b' class Kernel(KernelBase):'
70
71
71 def start(self):
72 def start(self):
72 self.shell.exit_now = False
73 self.shell.exit_now = False
73 super(Kernel, self).start()
74 super(IPythonKernel, self).start()
74
75
75 def set_parent(self, ident, parent):
76 def set_parent(self, ident, parent):
76 """Overridden from parent to tell the display hook and output streams
77 """Overridden from parent to tell the display hook and output streams
77 about the parent message.
78 about the parent message.
78 """
79 """
79 super(Kernel, self).set_parent(ident, parent)
80 super(IPythonKernel, self).set_parent(ident, parent)
80 self.shell.set_parent(parent)
81 self.shell.set_parent(parent)
81
82
82 def _forward_input(self, allow_stdin=False):
83 def _forward_input(self, allow_stdin=False):
@@ -288,3 +289,14 b' class Kernel(KernelBase):'
288 def do_clear(self):
289 def do_clear(self):
289 self.shell.reset(False)
290 self.shell.reset(False)
290 return dict(status='ok')
291 return dict(status='ok')
292
293
294 # This exists only for backwards compatibility - use IPythonKernel instead
295
296 @undoc
297 class Kernel(IPythonKernel):
298 def __init__(self, *args, **kwargs):
299 import warnings
300 warnings.warn('Kernel is a deprecated alias of IPython.kernel.zmq.ipkernel.IPythonKernel',
301 DeprecationWarning)
302 super(Kernel, self).__init__(*args, **kwargs) No newline at end of file
@@ -33,7 +33,7 b' from IPython.kernel.connect import ConnectionFileMixin'
33
33
34 # local imports
34 # local imports
35 from .heartbeat import Heartbeat
35 from .heartbeat import Heartbeat
36 from .ipkernel import Kernel
36 from .ipkernel import IPythonKernel
37 from .parentpoller import ParentPollerUnix, ParentPollerWindows
37 from .parentpoller import ParentPollerUnix, ParentPollerWindows
38 from .session import (
38 from .session import (
39 Session, session_flags, session_aliases, default_secure,
39 Session, session_flags, session_aliases, default_secure,
@@ -100,10 +100,10 b' class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,'
100 name='ipkernel'
100 name='ipkernel'
101 aliases = Dict(kernel_aliases)
101 aliases = Dict(kernel_aliases)
102 flags = Dict(kernel_flags)
102 flags = Dict(kernel_flags)
103 classes = [Kernel, ZMQInteractiveShell, ProfileDir, Session]
103 classes = [IPythonKernel, ZMQInteractiveShell, ProfileDir, Session]
104 # the kernel class, as an importstring
104 # the kernel class, as an importstring
105 kernel_class = Type('IPython.kernel.zmq.ipkernel.Kernel', config=True,
105 kernel_class = Type('IPython.kernel.zmq.ipkernel.IPythonKernel', config=True,
106 klass='IPython.kernel.zmq.kernelbase.KernelBase',
106 klass='IPython.kernel.zmq.kernelbase.Kernel',
107 help="""The Kernel subclass to be used.
107 help="""The Kernel subclass to be used.
108
108
109 This should allow easy re-use of the IPKernelApp entry point
109 This should allow easy re-use of the IPKernelApp entry point
@@ -32,11 +32,7 b' from IPython.utils.traitlets import ('
32 from .session import Session
32 from .session import Session
33
33
34
34
35 #-----------------------------------------------------------------------------
35 class Kernel(Configurable):
36 # Main kernel class
37 #-----------------------------------------------------------------------------
38
39 class KernelBase(Configurable):
40
36
41 #---------------------------------------------------------------------------
37 #---------------------------------------------------------------------------
42 # Kernel interface
38 # Kernel interface
@@ -111,7 +107,7 b' class KernelBase(Configurable):'
111
107
112
108
113 def __init__(self, **kwargs):
109 def __init__(self, **kwargs):
114 super(KernelBase, self).__init__(**kwargs)
110 super(Kernel, self).__init__(**kwargs)
115
111
116 # Build dict of handlers for message types
112 # Build dict of handlers for message types
117 msg_types = [ 'execute_request', 'complete_request',
113 msg_types = [ 'execute_request', 'complete_request',
@@ -37,7 +37,7 b' from IPython.parallel.apps.baseapp import ('
37 catch_config_error,
37 catch_config_error,
38 )
38 )
39 from IPython.kernel.zmq.log import EnginePUBHandler
39 from IPython.kernel.zmq.log import EnginePUBHandler
40 from IPython.kernel.zmq.ipkernel import Kernel
40 from IPython.kernel.zmq.ipkernel import IPythonKernel as Kernel
41 from IPython.kernel.zmq.kernelapp import IPKernelApp
41 from IPython.kernel.zmq.kernelapp import IPKernelApp
42 from IPython.kernel.zmq.session import (
42 from IPython.kernel.zmq.session import (
43 Session, session_aliases, session_flags
43 Session, session_aliases, session_flags
@@ -27,7 +27,7 b' from IPython.parallel.factory import RegistrationFactory'
27 from IPython.parallel.util import disambiguate_url
27 from IPython.parallel.util import disambiguate_url
28
28
29 from IPython.kernel.zmq.session import Message
29 from IPython.kernel.zmq.session import Message
30 from IPython.kernel.zmq.ipkernel import Kernel
30 from IPython.kernel.zmq.ipkernel import IPythonKernel as Kernel
31 from IPython.kernel.zmq.kernelapp import IPKernelApp
31 from IPython.kernel.zmq.kernelapp import IPKernelApp
32
32
33 class EngineFactory(RegistrationFactory):
33 class EngineFactory(RegistrationFactory):
@@ -13,7 +13,7 b' such as bash.'
13 Required steps
13 Required steps
14 --------------
14 --------------
15
15
16 Subclass :class:`IPython.kernel.zmq.kernelbase.KernelBase`, and implement the
16 Subclass :class:`IPython.kernel.zmq.kernelbase.Kernel`, and implement the
17 following methods and attributes:
17 following methods and attributes:
18
18
19 .. class:: MyKernel
19 .. class:: MyKernel
@@ -45,7 +45,7 b' following methods and attributes:'
45
45
46 Your method should return a dict containing the fields described in
46 Your method should return a dict containing the fields described in
47 :ref:`execution_results`. To display output, it can send messages
47 :ref:`execution_results`. To display output, it can send messages
48 using :meth:`~IPython.kernel.zmq.kernelbase.KernelBase.send_response`.
48 using :meth:`~IPython.kernel.zmq.kernelbase.Kernel.send_response`.
49 See :doc:`messaging` for details of the different message types.
49 See :doc:`messaging` for details of the different message types.
50
50
51 To launch your kernel, add this at the end of your module::
51 To launch your kernel, add this at the end of your module::
@@ -59,9 +59,9 b' Example'
59
59
60 ``echokernel.py`` will simply echo any input it's given to stdout::
60 ``echokernel.py`` will simply echo any input it's given to stdout::
61
61
62 from IPython.kernel.zmq.kernelbase import KernelBase
62 from IPython.kernel.zmq.kernelbase import Kernel
63
63
64 class EchoKernel(KernelBase):
64 class EchoKernel(Kernel):
65 implementation = 'Echo'
65 implementation = 'Echo'
66 implementation_version = '1.0'
66 implementation_version = '1.0'
67 language = 'no-op'
67 language = 'no-op'
General Comments 0
You need to be logged in to leave comments. Login now