Show More
@@ -45,7 +45,8 b' class SessionRootHandler(IPythonHandler):' | |||||
45 | try: |
|
45 | try: | |
46 | kernel_name = model['kernel']['name'] |
|
46 | kernel_name = model['kernel']['name'] | |
47 | except KeyError: |
|
47 | except KeyError: | |
48 | raise web.HTTPError(400, "Missing field in JSON data: kernel.name") |
|
48 | self.log.debug("No kernel name specified, using default kernel") | |
|
49 | kernel_name = None | |||
49 |
|
50 | |||
50 | # Check to see if session exists |
|
51 | # Check to see if session exists | |
51 | if sm.session_exists(name=name, path=path): |
|
52 | if sm.session_exists(name=name, path=path): |
@@ -1,20 +1,7 b'' | |||||
1 | """A base class session manager. |
|
1 | """A base class session manager.""" | |
2 |
|
2 | |||
3 | Authors: |
|
3 | # Copyright (c) IPython Development Team. | |
4 |
|
4 | # Distributed under the terms of the Modified BSD License. | ||
5 | * Zach Sailer |
|
|||
6 | """ |
|
|||
7 |
|
||||
8 | #----------------------------------------------------------------------------- |
|
|||
9 | # Copyright (C) 2013 The IPython Development Team |
|
|||
10 | # |
|
|||
11 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
12 | # the file COPYING, distributed as part of this software. |
|
|||
13 | #----------------------------------------------------------------------------- |
|
|||
14 |
|
||||
15 | #----------------------------------------------------------------------------- |
|
|||
16 | # Imports |
|
|||
17 | #----------------------------------------------------------------------------- |
|
|||
18 |
|
5 | |||
19 | import uuid |
|
6 | import uuid | |
20 | import sqlite3 |
|
7 | import sqlite3 | |
@@ -25,9 +12,6 b' from IPython.config.configurable import LoggingConfigurable' | |||||
25 | from IPython.utils.py3compat import unicode_type |
|
12 | from IPython.utils.py3compat import unicode_type | |
26 | from IPython.utils.traitlets import Instance |
|
13 | from IPython.utils.traitlets import Instance | |
27 |
|
14 | |||
28 | #----------------------------------------------------------------------------- |
|
|||
29 | # Classes |
|
|||
30 | #----------------------------------------------------------------------------- |
|
|||
31 |
|
15 | |||
32 | class SessionManager(LoggingConfigurable): |
|
16 | class SessionManager(LoggingConfigurable): | |
33 |
|
17 | |||
@@ -73,7 +57,7 b' class SessionManager(LoggingConfigurable):' | |||||
73 | "Create a uuid for a new session" |
|
57 | "Create a uuid for a new session" | |
74 | return unicode_type(uuid.uuid4()) |
|
58 | return unicode_type(uuid.uuid4()) | |
75 |
|
59 | |||
76 |
def create_session(self, name=None, path=None, kernel_name= |
|
60 | def create_session(self, name=None, path=None, kernel_name=None): | |
77 | """Creates a session and returns its model""" |
|
61 | """Creates a session and returns its model""" | |
78 | session_id = self.new_session_id() |
|
62 | session_id = self.new_session_id() | |
79 | # allow nbm to specify kernels cwd |
|
63 | # allow nbm to specify kernels cwd |
@@ -12,7 +12,7 b' define([' | |||||
12 | this.selector = selector; |
|
12 | this.selector = selector; | |
13 | this.notebook = notebook; |
|
13 | this.notebook = notebook; | |
14 | this.events = notebook.events; |
|
14 | this.events = notebook.events; | |
15 |
this.current_selection = n |
|
15 | this.current_selection = null; | |
16 | this.kernelspecs = {}; |
|
16 | this.kernelspecs = {}; | |
17 | if (this.selector !== undefined) { |
|
17 | if (this.selector !== undefined) { | |
18 | this.element = $(selector); |
|
18 | this.element = $(selector); |
@@ -70,9 +70,6 b' define([' | |||||
70 | // Create default scroll manager. |
|
70 | // Create default scroll manager. | |
71 | this.scroll_manager = new scrollmanager.ScrollManager(this); |
|
71 | this.scroll_manager = new scrollmanager.ScrollManager(this); | |
72 |
|
72 | |||
73 | // default_kernel_name is a temporary measure while we implement proper |
|
|||
74 | // kernel selection and delayed start. Do not rely on it. |
|
|||
75 | this.default_kernel_name = 'python'; |
|
|||
76 | // TODO: This code smells (and the other `= this` line a couple lines down) |
|
73 | // TODO: This code smells (and the other `= this` line a couple lines down) | |
77 | // We need a better way to deal with circular instance references. |
|
74 | // We need a better way to deal with circular instance references. | |
78 | this.keyboard_manager.notebook = this; |
|
75 | this.keyboard_manager.notebook = this; | |
@@ -1563,9 +1560,6 b' define([' | |||||
1563 | */ |
|
1560 | */ | |
1564 | Notebook.prototype.start_session = function (kernel_name) { |
|
1561 | Notebook.prototype.start_session = function (kernel_name) { | |
1565 | var that = this; |
|
1562 | var that = this; | |
1566 | if (kernel_name === undefined) { |
|
|||
1567 | kernel_name = this.default_kernel_name; |
|
|||
1568 | } |
|
|||
1569 | if (this._session_starting) { |
|
1563 | if (this._session_starting) { | |
1570 | throw new session.SessionAlreadyStarting(); |
|
1564 | throw new session.SessionAlreadyStarting(); | |
1571 | } |
|
1565 | } | |
@@ -2330,7 +2324,7 b' define([' | |||||
2330 | // code execution upon loading, which is a security risk. |
|
2324 | // code execution upon loading, which is a security risk. | |
2331 | if (this.session === null) { |
|
2325 | if (this.session === null) { | |
2332 | var kernelspec = this.metadata.kernelspec || {}; |
|
2326 | var kernelspec = this.metadata.kernelspec || {}; | |
2333 |
var kernel_name = kernelspec.name |
|
2327 | var kernel_name = kernelspec.name; | |
2334 |
|
2328 | |||
2335 | this.start_session(kernel_name); |
|
2329 | this.start_session(kernel_name); | |
2336 | } |
|
2330 | } |
@@ -1,20 +1,7 b'' | |||||
1 | """A kernel manager for multiple kernels |
|
1 | """A kernel manager for multiple kernels""" | |
2 |
|
2 | |||
3 | Authors: |
|
3 | # Copyright (c) IPython Development Team. | |
4 |
|
4 | # Distributed under the terms of the Modified BSD License. | ||
5 | * Brian Granger |
|
|||
6 | """ |
|
|||
7 |
|
||||
8 | #----------------------------------------------------------------------------- |
|
|||
9 | # Copyright (C) 2013 The IPython Development Team |
|
|||
10 | # |
|
|||
11 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
12 | # the file COPYING, distributed as part of this software. |
|
|||
13 | #----------------------------------------------------------------------------- |
|
|||
14 |
|
||||
15 | #----------------------------------------------------------------------------- |
|
|||
16 | # Imports |
|
|||
17 | #----------------------------------------------------------------------------- |
|
|||
18 |
|
5 | |||
19 | from __future__ import absolute_import |
|
6 | from __future__ import absolute_import | |
20 |
|
7 | |||
@@ -30,15 +17,12 b' from IPython.utils.traitlets import (' | |||||
30 | ) |
|
17 | ) | |
31 | from IPython.utils.py3compat import unicode_type |
|
18 | from IPython.utils.py3compat import unicode_type | |
32 |
|
19 | |||
33 | #----------------------------------------------------------------------------- |
|
20 | from .kernelspec import NATIVE_KERNEL_NAME | |
34 | # Classes |
|
|||
35 | #----------------------------------------------------------------------------- |
|
|||
36 |
|
21 | |||
37 | class DuplicateKernelError(Exception): |
|
22 | class DuplicateKernelError(Exception): | |
38 | pass |
|
23 | pass | |
39 |
|
24 | |||
40 |
|
25 | |||
41 |
|
||||
42 | def kernel_method(f): |
|
26 | def kernel_method(f): | |
43 | """decorator for proxying MKM.method(kernel_id) to individual KMs by ID""" |
|
27 | """decorator for proxying MKM.method(kernel_id) to individual KMs by ID""" | |
44 | def wrapped(self, kernel_id, *args, **kwargs): |
|
28 | def wrapped(self, kernel_id, *args, **kwargs): | |
@@ -58,6 +42,10 b' def kernel_method(f):' | |||||
58 | class MultiKernelManager(LoggingConfigurable): |
|
42 | class MultiKernelManager(LoggingConfigurable): | |
59 | """A class for managing multiple kernels.""" |
|
43 | """A class for managing multiple kernels.""" | |
60 |
|
44 | |||
|
45 | default_kernel_name = Unicode(NATIVE_KERNEL_NAME, config=True, | |||
|
46 | help="The name of the default kernel to start" | |||
|
47 | ) | |||
|
48 | ||||
61 | kernel_manager_class = DottedObjectName( |
|
49 | kernel_manager_class = DottedObjectName( | |
62 | "IPython.kernel.ioloop.IOLoopKernelManager", config=True, |
|
50 | "IPython.kernel.ioloop.IOLoopKernelManager", config=True, | |
63 | help="""The kernel manager class. This is configurable to allow |
|
51 | help="""The kernel manager class. This is configurable to allow | |
@@ -92,7 +80,7 b' class MultiKernelManager(LoggingConfigurable):' | |||||
92 | def __contains__(self, kernel_id): |
|
80 | def __contains__(self, kernel_id): | |
93 | return kernel_id in self._kernels |
|
81 | return kernel_id in self._kernels | |
94 |
|
82 | |||
95 |
def start_kernel(self, kernel_name= |
|
83 | def start_kernel(self, kernel_name=None, **kwargs): | |
96 | """Start a new kernel. |
|
84 | """Start a new kernel. | |
97 |
|
85 | |||
98 | The caller can pick a kernel_id by passing one in as a keyword arg, |
|
86 | The caller can pick a kernel_id by passing one in as a keyword arg, | |
@@ -106,6 +94,9 b' class MultiKernelManager(LoggingConfigurable):' | |||||
106 | kernel_id = kwargs.pop('kernel_id', unicode_type(uuid.uuid4())) |
|
94 | kernel_id = kwargs.pop('kernel_id', unicode_type(uuid.uuid4())) | |
107 | if kernel_id in self: |
|
95 | if kernel_id in self: | |
108 | raise DuplicateKernelError('Kernel already exists: %s' % kernel_id) |
|
96 | raise DuplicateKernelError('Kernel already exists: %s' % kernel_id) | |
|
97 | ||||
|
98 | if kernel_name is None: | |||
|
99 | kernel_name = self.default_kernel_name | |||
109 | # kernel_manager_factory is the constructor for the KernelManager |
|
100 | # kernel_manager_factory is the constructor for the KernelManager | |
110 | # subclass we are using. It can be configured as any Configurable, |
|
101 | # subclass we are using. It can be configured as any Configurable, | |
111 | # including things like its transport and ip. |
|
102 | # including things like its transport and ip. |
General Comments 0
You need to be logged in to leave comments.
Login now