Skip to content

Commit

Permalink
remove defunct discovery code
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg1969 committed Mar 6, 2024
1 parent 2a2aeb0 commit c4013e3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 45 deletions.
28 changes: 0 additions & 28 deletions nb_conda_kernels/discovery.py

This file was deleted.

14 changes: 3 additions & 11 deletions nb_conda_kernels/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
CKSM = "nb_conda_kernels.CondaKernelSpecManager"
JKSM = "jupyter_client.kernelspec.KernelSpecManager"
KSMC = "kernel_spec_manager_class"
JCKP = "jupyter_client.kernel_providers"
NCKDCKP = "nb_conda_kernels.discovery:CondaKernelProvider"
JC = "jupyter_config"
JNC = "jupyter_notebook_config"
ENDIS = ['disabled', 'enabled']
Expand Down Expand Up @@ -121,7 +119,7 @@ def install(enable=False, disable=False, status=None, prefix=None, path=None, ve
if status or path_g != path:
# No changes in status mode, or if we're not in the target path
expected = spec
elif enable and fbase == JC and key == JA and not is_enabled_entry:
elif enable and fbase == JC and key == JA:
# Add the spec if we are enabling, the entry point is not active,
# and we're using the new file (jupyter_config.json) and key (JupyterApp)
expected = CKSM
Expand Down Expand Up @@ -156,14 +154,9 @@ def install(enable=False, disable=False, status=None, prefix=None, path=None, ve
is_enabled_all = bool(is_enabled_all.get(NBA, is_enabled_all.get(JA)))
is_enabled_local = bool(is_enabled_local.get(NBA, is_enabled_local.get(JA)))

if is_enabled_all != is_enabled_local or (is_enabled_entry and disable):
if is_enabled_all != is_enabled_local:
sev = 'WARNING' if status else 'ERROR'
if is_enabled_entry and disable:
msg = ['{}: the entrypoint mechanism cannot be disabled'.format(sev),
'with changes to jupyter_config.json. To disable it,',
'remove the nb_conda_kernels package.']
fpaths = []
elif path not in all_paths:
if path not in all_paths:
msg = fpaths = []
elif status:
msg = ['{}: the local configuration of nb_conda_kernels'.format(sev),
Expand All @@ -182,7 +175,6 @@ def install(enable=False, disable=False, status=None, prefix=None, path=None, ve
if msg:
(log.warning if status else log.error)('\n'.join(msg))

is_enabled_all = is_enabled_all or is_enabled_entry
log.info('Status: {}'.format(ENDIS[is_enabled_all]))
return 0 if status or is_enabled_all == is_enabled_local else 1

Expand Down
16 changes: 10 additions & 6 deletions tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@
import time
import pytest

from nb_conda_kernels.discovery import CondaKernelProvider
from nb_conda_kernels.manager import RUNNER_COMMAND
from jupyter_client.manager import KernelManager
from nb_conda_kernels.manager import RUNNER_COMMAND, CondaKernelSpecManager

START_TIMEOUT = 10
CMD_TIMEOUT = 3
NUM_RETRIES = 10
is_win = sys.platform.startswith('win')
is_py2 = sys.version_info[0] < 3
CKSM = None


provider = CondaKernelProvider()
def _cksm():
global CKSM
if CKSM is None:
CKSM = CondaKernelSpecManager(conda_only=True)
return CKSM


old_print = print
Expand Down Expand Up @@ -61,7 +65,7 @@ def find_test_keys():
os.environ['PATH'] = os.pathsep.join(path_list)
print('AFTER: {}'.format(os.environ['PATH']))
keys = []
for key, _ in provider.find_kernels():
for key in _cksm().get_all_specs():
assert key.startswith('conda-')
if key.endswith('-py') or key.endswith('-r'):
keys.append(key)
Expand Down Expand Up @@ -127,7 +131,7 @@ def call_kernel(kernel_manager, **kw):
def test_runner(key):
if sys.platform.startswith("darwin") and key.endswith('-r'):
pytest.xfail("R kernels on macos are failing for now")
kernel_manager = provider.make_manager(key)
kernel_manager = KernelManager(kernel_spec_manager=_cksm(), kernel_name=key)
if kernel_manager.kernel_spec.argv[:3] == RUNNER_COMMAND:
env_path = kernel_manager.kernel_spec.argv[4]
else:
Expand Down

0 comments on commit c4013e3

Please sign in to comment.