takluyver / jupyter_kernel_mgmt

Experimental new kernel management framework for Jupyter
https://jupyter-kernel-mgmt.readthedocs.io/en/latest/
Other
15 stars 8 forks source link

Test suite failures #48

Open Apteryks opened 2 years ago

Apteryks commented 2 years ago

Hi,

I've trying to update this package to 0.5.1 in Guix, and I have 8 failures that I'm having some difficulty to interpret/understand:

============================= test session starts ==============================
platform linux -- Python 3.9.9, pytest-6.2.5, py-1.10.0, pluggy-0.13.1 -- /gnu/store/j3cx0yaqdpw0mxizp5bayx93pya44dhn-python-wrapper-3.9.9/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1/.hypothesis/examples')
rootdir: /tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1
plugins: hypothesis-6.0.2, asyncio-0.17.2
asyncio: mode=legacy
collecting ... collected 38 items

jupyter_kernel_mgmt/tests/test_async_manager.py::test_get_connect_info PASSED [  2%]
jupyter_kernel_mgmt/tests/test_client_blocking.py::test_execute_interactive PASSED [  5%]
jupyter_kernel_mgmt/tests/test_client_blocking.py::test_history PASSED   [  7%]
jupyter_kernel_mgmt/tests/test_client_blocking.py::test_inspect PASSED   [ 10%]
jupyter_kernel_mgmt/tests/test_client_blocking.py::test_complete PASSED  [ 13%]
jupyter_kernel_mgmt/tests/test_client_blocking.py::test_kernel_info PASSED [ 15%]
jupyter_kernel_mgmt/tests/test_client_blocking.py::test_comm_info PASSED [ 18%]
jupyter_kernel_mgmt/tests/test_client_blocking.py::test_shutdown PASSED  [ 21%]
jupyter_kernel_mgmt/tests/test_client_blocking.py::test_shutdown ERROR   [ 21%]
jupyter_kernel_mgmt/tests/test_client_loop.py::test_history FAILED       [ 23%]
jupyter_kernel_mgmt/tests/test_client_loop.py::test_inspect FAILED       [ 26%]
jupyter_kernel_mgmt/tests/test_client_loop.py::test_complete FAILED      [ 28%]
jupyter_kernel_mgmt/tests/test_client_loop.py::test_kernel_info FAILED   [ 31%]
jupyter_kernel_mgmt/tests/test_client_loop.py::test_comm_info FAILED     [ 34%]
jupyter_kernel_mgmt/tests/test_client_loop.py::test_shutdown FAILED      [ 36%]
jupyter_kernel_mgmt/tests/test_discovery.py::test_ipykernel_provider PASSED [ 39%]
jupyter_kernel_mgmt/tests/test_discovery.py::test_meta_kernel_finder PASSED [ 42%]
jupyter_kernel_mgmt/tests/test_discovery.py::test_kernel_spec_provider PASSED [ 44%]
jupyter_kernel_mgmt/tests/test_discovery.py::test_kernel_spec_provider_subclass PASSED [ 47%]
jupyter_kernel_mgmt/tests/test_discovery.py::test_kernel_launch_params PASSED [ 50%]
jupyter_kernel_mgmt/tests/test_discovery.py::test_load_config FAILED     [ 52%]
jupyter_kernel_mgmt/tests/test_discovery.py::test_discovery_main PASSED  [ 55%]
jupyter_kernel_mgmt/tests/test_kernelapp.py::test_kernelapp_lifecycle PASSED [ 57%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_find_kernel_specs PASSED [ 60%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_get_kernel_spec PASSED [ 63%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_find_all_specs PASSED [ 65%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_kernel_spec_priority PASSED [ 68%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_install_kernel_spec PASSED [ 71%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_install_kernel_spec_prefix PASSED [ 73%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_cant_install_kernel_spec PASSED [ 76%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_remove_kernel_spec PASSED [ 78%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_remove_kernel_spec_app PASSED [ 81%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_validate_kernel_name PASSED [ 84%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_provider_find_kernel_specs PASSED [ 86%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_provider_get_kernel_spec PASSED [ 89%]
jupyter_kernel_mgmt/tests/test_kernelspec.py::test_provider_find_all_specs PASSED [ 92%]
jupyter_kernel_mgmt/tests/test_localinterfaces.py::test_load_ips PASSED  [ 94%]
jupyter_kernel_mgmt/tests/test_manager.py::test_signal_kernel_subprocesses FAILED [ 97%]
jupyter_kernel_mgmt/tests/test_restarter.py::test_reinstantiate PASSED   [100%]

==================================== ERRORS ====================================
______________________ ERROR at teardown of test_shutdown ______________________

self = <jupyter_kernel_mgmt.client.IOLoopKernelClient object at 0x7ffff3aaa460>
timeout = 5.0

    @gen.coroutine
    def shutdown_or_terminate(self, timeout=5.0):
        """Ask the kernel to shut down, and terminate it if it takes too long.

        The kernel will be given up to timeout seconds to respond to the
        shutdown message, then the same timeout to terminate.
        """
        if not self.manager:
            raise RuntimeError(
                "Cannot terminate a kernel without a KernelManager")
        try:
>           yield gen.with_timeout(timedelta(seconds=timeout), self.shutdown())

jupyter_kernel_mgmt/client.py:286: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tornado.gen.Runner object at 0x7ffff2a335b0>

    def run(self):
        """Starts or resumes the generator, running until it reaches a
        yield point that is not ready.
        """
        if self.running or self.finished:
            return
        try:
            self.running = True
            while True:
                future = self.future
                if not future.done():
                    return
                self.future = None
                try:
                    orig_stack_contexts = stack_context._state.contexts
                    exc_info = None

                    try:
>                       value = future.result()
E                       tornado.util.TimeoutError: Timeout

/gnu/store/3i7wwfpmlvr8f6158cgjc8x3y4ybhj3q-python-tornado-5.1.1/lib/python3.9/site-packages/tornado/gen.py:1133: TimeoutError

During handling of the above exception, another exception occurred:

setup_env = None

    @pytest.fixture
    def kernel_client(setup_env):
        # Instantiate KernelFinder directly, so tests aren't affected by entrypoints
        # from other installed packages
        finder = KernelFinder([IPykernelProvider()])
        with run_kernel_blocking('pyimport/kernel', finder=finder) as kc:
>           yield kc

jupyter_kernel_mgmt/tests/test_client_blocking.py:21: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/gnu/store/b6j1qw1a5rkbfvcy7lc9fm95abbzpa4x-python-3.9.9/lib/python3.9/contextlib.py:126: in __exit__
    next(self.gen)
jupyter_kernel_mgmt/hl.py:78: in run_kernel_blocking
    kc.shutdown_or_terminate()
jupyter_kernel_mgmt/client.py:347: in wrapped
    return loop.run_sync(lambda: method(self.loop_client, *args, **kwargs),
/gnu/store/3i7wwfpmlvr8f6158cgjc8x3y4ybhj3q-python-tornado-5.1.1/lib/python3.9/site-packages/tornado/ioloop.py:576: in run_sync
    return future_cell[0].result()
/gnu/store/3i7wwfpmlvr8f6158cgjc8x3y4ybhj3q-python-tornado-5.1.1/lib/python3.9/site-packages/tornado/gen.py:1141: in run
    yielded = self.gen.throw(*exc_info)
jupyter_kernel_mgmt/client.py:290: in shutdown_or_terminate
    yield self.manager.kill()
/gnu/store/3i7wwfpmlvr8f6158cgjc8x3y4ybhj3q-python-tornado-5.1.1/lib/python3.9/site-packages/tornado/gen.py:1133: in run
    value = future.result()
jupyter_kernel_mgmt/subproc/manager.py:83: in kill
    self.kernel.kill()
/gnu/store/b6j1qw1a5rkbfvcy7lc9fm95abbzpa4x-python-3.9.9/lib/python3.9/asyncio/subprocess.py:144: in kill
    self._transport.kill()
/gnu/store/b6j1qw1a5rkbfvcy7lc9fm95abbzpa4x-python-3.9.9/lib/python3.9/asyncio/base_subprocess.py:153: in kill
    self._check_proc()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_UnixSubprocessTransport closed pid=138 returncode=0 stdin=<_UnixWritePipeTransport closed fd=23 closed>>

    def _check_proc(self):
        if self._proc is None:
>           raise ProcessLookupError()
E           ProcessLookupError

/gnu/store/b6j1qw1a5rkbfvcy7lc9fm95abbzpa4x-python-3.9.9/lib/python3.9/asyncio/base_subprocess.py:142: ProcessLookupError
=================================== FAILURES ===================================
_________________________________ test_history _________________________________

kernel_client = <async_generator._impl.AsyncGenerator object at 0x7ffff2740040>

    async def test_history(kernel_client):
>       reply = await kernel_client.history(session=0)
E       AttributeError: 'AsyncGenerator' object has no attribute 'history'

jupyter_kernel_mgmt/tests/test_client_loop.py:35: AttributeError
_________________________________ test_inspect _________________________________

kernel_client = <async_generator._impl.AsyncGenerator object at 0x7ffff29b5850>

    async def test_inspect(kernel_client):
>       reply = await kernel_client.inspect('who cares')
E       AttributeError: 'AsyncGenerator' object has no attribute 'inspect'

jupyter_kernel_mgmt/tests/test_client_loop.py:40: AttributeError
________________________________ test_complete _________________________________

kernel_client = <async_generator._impl.AsyncGenerator object at 0x7ffff273f460>

    async def test_complete(kernel_client):
>       reply = await kernel_client.complete('who cares')
E       AttributeError: 'AsyncGenerator' object has no attribute 'complete'

jupyter_kernel_mgmt/tests/test_client_loop.py:45: AttributeError
_______________________________ test_kernel_info _______________________________

kernel_client = <async_generator._impl.AsyncGenerator object at 0x7ffff29b6880>

    async def test_kernel_info(kernel_client):
>       reply = await kernel_client.kernel_info()
E       AttributeError: 'AsyncGenerator' object has no attribute 'kernel_info'

jupyter_kernel_mgmt/tests/test_client_loop.py:50: AttributeError
________________________________ test_comm_info ________________________________

kernel_client = <async_generator._impl.AsyncGenerator object at 0x7ffff27404c0>

    async def test_comm_info(kernel_client):
>       reply = await kernel_client.comm_info()
E       AttributeError: 'AsyncGenerator' object has no attribute 'comm_info'

jupyter_kernel_mgmt/tests/test_client_loop.py:55: AttributeError
________________________________ test_shutdown _________________________________

kernel_client = <async_generator._impl.AsyncGenerator object at 0x7ffff29b5820>

    async def test_shutdown(kernel_client):
>       reply = await kernel_client.shutdown()
E       AttributeError: 'AsyncGenerator' object has no attribute 'shutdown'

jupyter_kernel_mgmt/tests/test_client_loop.py:60: AttributeError
_______________________________ test_load_config _______________________________

setup_test = None

    async def test_load_config(setup_test):
        # create fake application
        app = ProviderApplication()
        app.launch_instance(argv=["--ProviderConfig.my_argv=['xxx','yyy']"])

        kf = discovery.KernelFinder(providers=[TestConfigKernelProvider()])
        dummy_kspecs = list(kf.find_kernels())

        count = 0
        found_argv = []
        for name, spec in dummy_kspecs:
            if name == 'config/sample':
                found_argv = spec['argv']
                count += 1

        assert count == 1
>       assert found_argv == ['xxx', 'yyy']
E       assert ["['xxx','yyy']"] == ['xxx', 'yyy']
E         At index 0 diff: "['xxx','yyy']" != 'xxx'
E         Right contains one more item: 'yyy'
E         Full diff:
E         - ['xxx', 'yyy']
E         ?        -
E         + ["['xxx','yyy']"]
E         ? ++             ++

jupyter_kernel_mgmt/tests/test_discovery.py:277: AssertionError
_______________________ test_signal_kernel_subprocesses ________________________

signal_kernel_client = <async_generator._impl.AsyncGenerator object at 0x7ffff2998eb0>

    @pytest.mark.skipif(sys.platform.startswith('win'), reason="Windows")
    @pytest.mark.asyncio
    async def test_signal_kernel_subprocesses(signal_kernel_client):
        kc = signal_kernel_client
        async def execute(cmd):
            reply = await kc.execute(cmd)
            content = reply.content
            assert content['status'] == 'ok'
            return content

        N = 5
        for i in range(N):
>           await execute("start")

jupyter_kernel_mgmt/tests/test_manager.py:49: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cmd = 'start'

    async def execute(cmd):
>       reply = await kc.execute(cmd)
E       AttributeError: 'AsyncGenerator' object has no attribute 'execute'

jupyter_kernel_mgmt/tests/test_manager.py:42: AttributeError
=============================== warnings summary ===============================
jupyter_kernel_mgmt/discovery.py:26
  /tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1/jupyter_kernel_mgmt/discovery.py:26: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    def find_kernels(self):

jupyter_kernel_mgmt/discovery.py:72
  /tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1/jupyter_kernel_mgmt/discovery.py:72: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    def find_kernels(self):

jupyter_kernel_mgmt/discovery.py:116
  /tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1/jupyter_kernel_mgmt/discovery.py:116: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    def find_kernels(self):

jupyter_kernel_mgmt/discovery.py:174
  /tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1/jupyter_kernel_mgmt/discovery.py:174: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    def find_kernels(self):

../../../gnu/store/0q70jn8vcyvs40z0bcll80zj3aacsw0x-python-pytest-asyncio-0.17.2/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191
  /gnu/store/0q70jn8vcyvs40z0bcll80zj3aacsw0x-python-pytest-asyncio-0.17.2/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
    config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)

jupyter_kernel_mgmt/tests/test_discovery.py:29
  /tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1/jupyter_kernel_mgmt/tests/test_discovery.py:29: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    def find_kernels(self):

jupyter_kernel_mgmt/tests/test_discovery.py:97
  /tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1/jupyter_kernel_mgmt/tests/test_discovery.py:97: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    def find_kernels(self):

jupyter_kernel_mgmt/tests/test_client_blocking.py::test_execute_interactive
  /gnu/store/0q70jn8vcyvs40z0bcll80zj3aacsw0x-python-pytest-asyncio-0.17.2/lib/python3.9/site-packages/pytest_asyncio/plugin.py:317: DeprecationWarning: '@pytest.fixture' is applied to <fixture monkeypatch, file=/gnu/store/rj9gyaqi2ijkll5495jgp7kbfqh02167-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/monkeypatch.py, line=29> in 'legacy' mode, please replace it with '@pytest_asyncio.fixture' as a preparation for switching to 'strict' mode (or use 'auto' mode to seamlessly handle all these fixtures as asyncio-driven).
    warnings.warn(

jupyter_kernel_mgmt/tests/test_client_blocking.py::test_execute_interactive
  /gnu/store/0q70jn8vcyvs40z0bcll80zj3aacsw0x-python-pytest-asyncio-0.17.2/lib/python3.9/site-packages/pytest_asyncio/plugin.py:317: DeprecationWarning: '@pytest.fixture' is applied to <fixture kernel_client, file=/tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1/jupyter_kernel_mgmt/tests/test_client_blocking.py, line=15> in 'legacy' mode, please replace it with '@pytest_asyncio.fixture' as a preparation for switching to 'strict' mode (or use 'auto' mode to seamlessly handle all these fixtures as asyncio-driven).
    warnings.warn(

jupyter_kernel_mgmt/tests/test_discovery.py::test_kernel_launch_params
  /gnu/store/0q70jn8vcyvs40z0bcll80zj3aacsw0x-python-pytest-asyncio-0.17.2/lib/python3.9/site-packages/pytest_asyncio/plugin.py:317: DeprecationWarning: '@pytest.fixture' is applied to <fixture caplog, file=/gnu/store/rj9gyaqi2ijkll5495jgp7kbfqh02167-python-pytest-6.2.5/lib/python3.9/site-packages/_pytest/logging.py, line=475> in 'legacy' mode, please replace it with '@pytest_asyncio.fixture' as a preparation for switching to 'strict' mode (or use 'auto' mode to seamlessly handle all these fixtures as asyncio-driven).
    warnings.warn(

jupyter_kernel_mgmt/tests/test_kernelspec.py::test_install_kernel_spec
  /gnu/store/0q70jn8vcyvs40z0bcll80zj3aacsw0x-python-pytest-asyncio-0.17.2/lib/python3.9/site-packages/pytest_asyncio/plugin.py:317: DeprecationWarning: '@pytest.fixture' is applied to <fixture installable_kernel, file=/tmp/guix-build-python-jupyter-kernel-mgmt-0.5.1.drv-0/jupyter_kernel_mgmt-0.5.1/jupyter_kernel_mgmt/tests/test_kernelspec.py, line=56> in 'legacy' mode, please replace it with '@pytest_asyncio.fixture' as a preparation for switching to 'strict' mode (or use 'auto' mode to seamlessly handle all these fixtures as asyncio-driven).
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED jupyter_kernel_mgmt/tests/test_client_loop.py::test_history - Attribut...
FAILED jupyter_kernel_mgmt/tests/test_client_loop.py::test_inspect - Attribut...
FAILED jupyter_kernel_mgmt/tests/test_client_loop.py::test_complete - Attribu...
FAILED jupyter_kernel_mgmt/tests/test_client_loop.py::test_kernel_info - Attr...
FAILED jupyter_kernel_mgmt/tests/test_client_loop.py::test_comm_info - Attrib...
FAILED jupyter_kernel_mgmt/tests/test_client_loop.py::test_shutdown - Attribu...
FAILED jupyter_kernel_mgmt/tests/test_discovery.py::test_load_config - assert...
FAILED jupyter_kernel_mgmt/tests/test_manager.py::test_signal_kernel_subprocesses
ERROR jupyter_kernel_mgmt/tests/test_client_blocking.py::test_shutdown - Proc...
============= 8 failed, 30 passed, 11 warnings, 1 error in 12.93s ==============

Any idea what it may have to do with? I'm currently testing with the following direct dependencies (and Python 3.9.9):

$ ./pre-inst-env guix show python-jupyter-kernel-mgmt
name: python-jupyter-kernel-mgmt
version: 0.5.1
outputs: out
systems: x86_64-linux
dependencies: python-async-generator@1.10 python-dateutil@2.8.2 python-entrypoints@0.3
+ python-ipykernel@6.13.0 python-ipython@8.2.0 python-jupyter-core@4.9.2 python-jupyter-protocol@0.2.0
+ python-pytest-asyncio@0.17.2 python-pytest@6.2.5 python-pyzmq@22.3.0 python-tornado@5.1.1
+ python-traitlets@5.1.1
homepage: https://jupyter.org
license: Modified BSD
synopsis: Discover, launch, and communicate with Jupyter kernels  
description: This package is an experimental refactoring of the machinery for launching and using
+ Jupyter kernels.