Fix detection of unsupported config, prevent async on 3.5

This commit is contained in:
Kevin Bates 2020-04-01 16:39:29 -07:00
parent 99b0afd16e
commit 53d4d08813
No known key found for this signature in database
GPG Key ID: ADCCD5840EE5145F
4 changed files with 27 additions and 19 deletions

View File

@ -1390,14 +1390,16 @@ class NotebookApp(JupyterApp):
connection_dir=self.runtime_dir,
kernel_spec_manager=self.kernel_spec_manager,
)
# Ensure the appropriate jupyter_client is in place.
# Ensure the appropriate version of Python and jupyter_client is available.
if isinstance(self.kernel_manager, AsyncMappingKernelManager):
if sys.version_info < (3, 6):
raise ValueError("You are using `AsyncMappingKernelManager` in Python 3.5 (or lower) "
"which is not supported. Please upgrade Python to 3.6+ or change kernel managers.")
if not async_kernel_mgmt_available:
raise ValueError("You are using `AsyncMappingKernelManager` without an appropriate "
"jupyter_client installed! Upgrade jupyter_client or change kernel managers.")
else:
self.log.info("Asynchronous kernel management has been configured to use '{}'.".
format(self.kernel_manager.__class__.__name__))
"jupyter_client installed! Please upgrade jupyter_client or change kernel managers.")
self.log.info("Asynchronous kernel management has been configured to use '{}'.".
format(self.kernel_manager.__class__.__name__))
self.contents_manager = self.contents_manager_class(
parent=self,

View File

@ -35,7 +35,8 @@ try:
except ImportError:
class AsyncMultiKernelManager(object):
"""Empty class to satisfy unused reference by AsyncMappingKernelManager."""
pass
def __init__(self, **kwargs):
pass
class MappingKernelManager(MultiKernelManager):

View File

@ -1,6 +1,7 @@
"""Test the kernels service API."""
import json
import sys
import time
from traitlets.config import Config
@ -198,6 +199,14 @@ class KernelAPITest(NotebookTestBase):
class AsyncKernelAPITest(KernelAPITest):
"""Test the kernels web service API using the AsyncMappingKernelManager"""
@classmethod
def setup_class(cls):
if not async_testing_enabled:
raise SkipTest("AsyncKernelAPITest tests skipped due to down-level jupyter_client!")
if sys.version_info < (3, 6):
raise SkipTest("AsyncKernelAPITest tests skipped due to Python < 3.6!")
super(AsyncKernelAPITest, cls).setup_class()
@classmethod
def get_argv(cls):
argv = super(AsyncKernelAPITest, cls).get_argv()
@ -209,12 +218,6 @@ class AsyncKernelAPITest(KernelAPITest):
'notebook.services.kernels.kernelmanager.AsyncMappingKernelManager'])
return argv
def setUp(self):
if not async_testing_enabled:
raise SkipTest("AsyncKernelAPITest.{test_method} skipped due to down-level jupyter_client!".
format(test_method=self._testMethodName))
super(AsyncKernelAPITest, self).setUp()
class KernelFilterTest(NotebookTestBase):

View File

@ -5,8 +5,8 @@ from functools import partial
import io
import os
import json
import requests
import shutil
import sys
import time
from unittest import SkipTest
@ -269,6 +269,14 @@ class SessionAPITest(NotebookTestBase):
class AsyncSessionAPITest(SessionAPITest):
"""Test the sessions web service API using the AsyncMappingKernelManager"""
@classmethod
def setup_class(cls):
if not async_testing_enabled:
raise SkipTest("AsyncSessionAPITest tests skipped due to down-level jupyter_client!")
if sys.version_info < (3, 6):
raise SkipTest("AsyncSessionAPITest tests skipped due to Python < 3.6!")
super(AsyncSessionAPITest, cls).setup_class()
@classmethod
def get_argv(cls):
argv = super(AsyncSessionAPITest, cls).get_argv()
@ -280,9 +288,3 @@ class AsyncSessionAPITest(SessionAPITest):
'notebook.services.kernels.kernelmanager.AsyncMappingKernelManager'])
return argv
def setUp(self):
if not async_testing_enabled:
raise SkipTest("AsyncSessionAPITest.{test_method} skipped due to down-level jupyter_client!".
format(test_method=self._testMethodName))
super(AsyncSessionAPITest, self).setUp()