Skip to content

Commit

Permalink
Add support for AsyncMappingKernelManager
Browse files Browse the repository at this point in the history
Supports running against incompatible jupyter_client so long as the
desired kernel_manager_class is not `AsyncMappingKernelManager`.
  • Loading branch information
kevin-bates committed Mar 14, 2019
1 parent a77b05a commit 2db718a
Show file tree
Hide file tree
Showing 4 changed files with 318 additions and 98 deletions.
11 changes: 9 additions & 2 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
except ImportError: #PY2
from base64 import encodestring as encodebytes


from jinja2 import Environment, FileSystemLoader

from notebook.transutils import trans, _
Expand Down Expand Up @@ -78,7 +77,7 @@

from .base.handlers import Template404, RedirectWithParams
from .log import log_request
from .services.kernels.kernelmanager import MappingKernelManager
from .services.kernels.kernelmanager import MappingKernelManager, AsyncMappingKernelManager, MappingKernelManagerBase
from .services.config import ConfigManager
from .services.contents.manager import ContentsManager
from .services.contents.filemanager import FileContentsManager
Expand Down Expand Up @@ -1138,6 +1137,7 @@ def _update_mathjax_config(self, change):

kernel_manager_class = Type(
default_value=MappingKernelManager,
klass=MappingKernelManagerBase,
config=True,
help=_('The kernel manager class to use.')
)
Expand Down Expand Up @@ -1349,6 +1349,13 @@ def init_configurables(self):
connection_dir=self.runtime_dir,
kernel_spec_manager=self.kernel_spec_manager,
)
# Ensure the appropriate jupyter_client is in place.
# TODO: remove once dependencies are updated.
if isinstance(self.kernel_manager, AsyncMappingKernelManager):
if not hasattr(self.kernel_manager, 'list_kernel_ids'):
raise RuntimeError("Using `AsyncMappingKernelManager` without an appropriate "
"jupyter_client installed! Upgrade jupyter_client and try again.")

self.contents_manager = self.contents_manager_class(
parent=self,
log=self.log,
Expand Down
Loading

0 comments on commit 2db718a

Please sign in to comment.