##// END OF EJS Templates
Merge pull request #5469 from dalejung/nbm_kernel_path...
Min RK -
r16424:0c3f033a merge
parent child Browse files
Show More
@@ -40,7 +40,7 b' class MappingKernelManager(MultiKernelManager):'
40 40 return "IPython.kernel.ioloop.IOLoopKernelManager"
41 41
42 42 kernel_argv = List(Unicode)
43
43
44 44 root_dir = Unicode(getcwd(), config=True)
45 45
46 46 def _root_dir_changed(self, name, old, new):
@@ -60,9 +60,13 b' class MappingKernelManager(MultiKernelManager):'
60 60 """notice that a kernel died"""
61 61 self.log.warn("Kernel %s died, removing from map.", kernel_id)
62 62 self.remove_kernel(kernel_id)
63
63
64 64 def cwd_for_path(self, path):
65 65 """Turn API path into absolute OS path."""
66 # short circuit for NotebookManagers that pass in absolute paths
67 if os.path.exists(path):
68 return path
69
66 70 os_path = to_os_path(path, self.root_dir)
67 71 # in the case of notebooks and kernels not being on the same filesystem,
68 72 # walk up to root_dir if the paths don't exist
@@ -77,7 +81,7 b' class MappingKernelManager(MultiKernelManager):'
77 81 ----------
78 82 kernel_id : uuid
79 83 The uuid to associate the new kernel with. If this
80 is not None, this kernel will be persistent whenever it is
84 is not None, this kernel will be persistent whenever it is
81 85 requested.
82 86 path : API path
83 87 The API path (unicode, '/' delimited) for the cwd.
@@ -492,3 +492,7 b' class FileNotebookManager(NotebookManager):'
492 492
493 493 def info_string(self):
494 494 return "Serving notebooks from local directory: %s" % self.notebook_dir
495
496 def get_kernel_path(self, name, path='', model=None):
497 """ Return the path to start kernel in """
498 return os.path.join(self.notebook_dir, path)
@@ -168,6 +168,10 b' class NotebookManager(LoggingConfigurable):'
168 168 # NotebookManager API part 2: methods that have useable default
169 169 # implementations, but can be overridden in subclasses.
170 170
171 def get_kernel_path(self, name, path='', model=None):
172 """ Return the path to start kernel in """
173 return path
174
171 175 def increment_filename(self, basename, path=''):
172 176 """Increment a notebook filename without the .ipynb to make it unique.
173 177
@@ -42,7 +42,7 b' class SessionRootHandler(IPythonHandler):'
42 42 @web.authenticated
43 43 @json_errors
44 44 def post(self):
45 # Creates a new session
45 # Creates a new session
46 46 #(unless a session already exists for the named nb)
47 47 sm = self.session_manager
48 48 nbm = self.notebook_manager
@@ -62,7 +62,9 b' class SessionRootHandler(IPythonHandler):'
62 62 if sm.session_exists(name=name, path=path):
63 63 model = sm.get_session(name=name, path=path)
64 64 else:
65 kernel_id = km.start_kernel(path=path)
65 # allow nbm to specify kernels cwd
66 kernel_path = nbm.get_kernel_path(name=name, path=path)
67 kernel_id = km.start_kernel(path=kernel_path)
66 68 model = sm.create_session(name=name, path=path, kernel_id=kernel_id)
67 69 location = url_path_join(self.base_url, 'api', 'sessions', model['id'])
68 70 self.set_header('Location', url_escape(location))
General Comments 0
You need to be logged in to leave comments. Login now