danielballan / remotekernel

15 stars 2 forks source link

The 'loop' trait of a RemoteIOLoopKernelManager instance must be a ZMQIOLoop #5

Open ianhinder opened 4 years ago

ianhinder commented 4 years ago

I get the error

The 'loop' trait of a RemoteIOLoopKernelManager instance must be a ZMQIOLoop

when trying to launch a remote kernel.

kernel.json:

{
 "argv": ["source",  "/path/to/venv/bin/activate", "&&",
  "python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 on XXX",
 "language": "python",
 "host": "xxx.yyy.zzz"
}

Jupyter notebook launch:

$ jupyter-notebook --MappingKernelManager.kernel_manager_class=remotekernel.manager.RemoteIOLoopKernelManager --KernelSpecManager.kernel_spec_class=remotekernel.kernelspec.RemoteKernelSpec
[I 00:34:31.977 NotebookApp] The port 8888 is already in use, trying another port.
[I 00:34:31.978 NotebookApp] The port 8889 is already in use, trying another port.
[I 00:34:32.002 NotebookApp] Loading IPython parallel extension
[I 00:34:32.490 NotebookApp] JupyterLab extension loaded from /usr/local/lib/python3.8/site-packages/jupyterlab
[I 00:34:32.490 NotebookApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 00:34:32.793 NotebookApp] [Jupytext Server Extension] Deriving a JupytextContentsManager from LargeFileManager
[I 00:34:32.795 NotebookApp] Serving notebooks from local directory: /XXX
[I 00:34:32.795 NotebookApp] The Jupyter Notebook is running at:
[I 00:34:32.795 NotebookApp] http://localhost:8890/?token=3fafd1cd8245ba213745f9e67c783cd0b2e48eaf7149999c
[I 00:34:32.795 NotebookApp]  or http://127.0.0.1:8890/?token=3fafd1cd8245ba213745f9e67c783cd0b2e48eaf7149999c
[I 00:34:32.795 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 00:34:32.809 NotebookApp] 

    To access the notebook, open this file in a browser:
        file:///Users/XXX/Library/Jupyter/runtime/nbserver-19488-open.html
    Or copy and paste one of these URLs:
        http://localhost:8890/?token=3fafd1cd8245ba213745f9e67c783cd0b2e48eaf7149999c
     or http://127.0.0.1:8890/?token=3fafd1cd8245ba213745f9e67c783cd0b2e48eaf7149999c
kernel-9884fe66-7b14-40f9-b4ea-73126c60f299.json                                                                                                                                                  100%  278     9.7KB/s   00:00    
[E 00:34:45.793 NotebookApp] Uncaught exception POST /api/sessions (::1)
    HTTPServerRequest(protocol='http', host='localhost:8890', method='POST', uri='/api/sessions', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/site-packages/traitlets/traitlets.py", line 528, in get
        value = obj._trait_values[self.name]
    KeyError: 'loop'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1703, in _execute
        result = await result
      File "/usr/local/lib/python3.8/site-packages/tornado/gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "/usr/local/lib/python3.8/site-packages/notebook/services/sessions/handlers.py", line 69, in post
        model = yield maybe_future(
      File "/usr/local/lib/python3.8/site-packages/tornado/gen.py", line 735, in run
        value = future.result()
      File "/usr/local/lib/python3.8/site-packages/tornado/gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "/usr/local/lib/python3.8/site-packages/notebook/services/sessions/sessionmanager.py", line 88, in create_session
        kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
      File "/usr/local/lib/python3.8/site-packages/tornado/gen.py", line 735, in run
        value = future.result()
      File "/usr/local/lib/python3.8/site-packages/tornado/gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "/usr/local/lib/python3.8/site-packages/notebook/services/sessions/sessionmanager.py", line 100, in start_kernel_for_session
        kernel_id = yield maybe_future(
      File "/usr/local/lib/python3.8/site-packages/tornado/gen.py", line 735, in run
        value = future.result()
      File "/usr/local/lib/python3.8/site-packages/tornado/gen.py", line 748, in run
        yielded = self.gen.send(value)
      File "/usr/local/lib/python3.8/site-packages/notebook/services/kernels/kernelmanager.py", line 171, in start_kernel
        self.start_watching_activity(kernel_id)
      File "/usr/local/lib/python3.8/site-packages/notebook/services/kernels/kernelmanager.py", line 401, in start_watching_activity
        kernel._activity_stream = kernel.connect_iopub()
      File "/usr/local/lib/python3.8/site-packages/remotekernel/manager.py", line 37, in wrapped
        return ZMQStream(socket, self.loop)
      File "/usr/local/lib/python3.8/site-packages/traitlets/traitlets.py", line 556, in __get__
        return self.get(obj, cls)
      File "/usr/local/lib/python3.8/site-packages/traitlets/traitlets.py", line 535, in get
        value = self._validate(obj, dynamic_default())
      File "/usr/local/lib/python3.8/site-packages/traitlets/traitlets.py", line 591, in _validate
        value = self.validate(obj, value)
      File "/usr/local/lib/python3.8/site-packages/traitlets/traitlets.py", line 1677, in validate
        self.error(obj, value)
      File "/usr/local/lib/python3.8/site-packages/traitlets/traitlets.py", line 1524, in error
        raise TraitError(e)
    traitlets.traitlets.TraitError: The 'loop' trait of a RemoteIOLoopKernelManager instance must be a ZMQIOLoop, but a value of class 'tornado.platform.asyncio.AsyncIOMainLoop' (i.e. <tornado.platform.asyncio.AsyncIOMainLoop object at 0x10a5b97f0>) was specified.
[W 00:34:45.803 NotebookApp] Unhandled error
[E 00:34:45.803 NotebookApp] {
      "Host": "localhost:8890",
      "Accept": "application/json, text/javascript, */*; q=0.01",
      "X-Requested-With": "XMLHttpRequest",
      "X-Xsrftoken": "2|962c81f6|b1e6e6eae1a00f20fc3ab382b26f87c7|1597876875",
      "Accept-Language": "en-gb",
      "Accept-Encoding": "gzip, deflate",
      "Content-Type": "application/json",
      "Origin": "http://localhost:8890",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15",
      "Referer": "http://localhost:8890/notebooks/Untitled.ipynb",
      "Content-Length": "96",
      "Connection": "keep-alive",
      "Cookie": "username-localhost-8890=\"2|1:0|10:1597880075|23:username-localhost-8890|44:OTMyZmFjODliNTViNGFhMjg3NGQ2ZjE1YTBmOWRiODg=|dbe482e6f8ab2b97e883e13b4d74875f72797014168c35e01adafb09f7beab52\"; _xsrf=2|962c81f6|b1e6e6eae1a00f20fc3ab382b26f87c7|1597876875; screenResolution=1440x900; JSESSIONID.cf6b7038=node0exc4sgii76i816rfb0733fzga2.node0; JSESSIONID.9bb5aae2=node01okltd0up5gqz3rab5yriqd9p2.node0; JSESSIONID.3e6ef274=node0c94t0jodu8vu299sjyb44ubr6.node0; username-localhost-8888=\"2|1:0|10:1596808881|23:username-localhost-8888|44:M2E0Yjc5NGMyOWVmNDgxZmEyOTAzOTQzZTAxNWQ3NGM=|de575feea3f611f22dd01046ad19289537c3ce738cf8ccb9f952e797e6037914\"; username-localhost-8889=\"2|1:0|10:1596099882|23:username-localhost-8889|44:MWM3ZTE1ZDNiMGU5NDFmYmJmNjRlZWExYjE1YzI0YWM=|e45c19fa1235e606ff9accb1394787d9a879726fd31b7d75a105a9d6744a7d05\""
    }
[E 00:34:45.803 NotebookApp] 500 POST /api/sessions (::1) 3679.42ms referer=http://localhost:8890/notebooks/Untitled.ipynb
danielballan commented 4 years ago

Thanks for the report, @ianhinder. It's possible a change to our of remotekernel's dependencies has caused this. To start, what version of notebook are you running?

ianhinder commented 4 years ago

Here are all my package versions:

$ pip3 list
Package            Version
------------------ ---------
apipkg             1.5
appnope            0.1.0
attrs              19.3.0
backcall           0.2.0
bcrypt             3.1.7
bleach             3.1.5
botocore           1.17.23
certifi            2020.6.20
cffi               1.14.0
chardet            3.0.4
click              7.1.2
configobj          5.0.6
cryptography       2.9.2
cycler             0.10.0
decorator          4.4.2
defusedxml         0.6.0
docutils           0.15.2
entrypoints        0.3
execnet            1.7.1
fsspec             0.7.4
gitdb              4.0.5
GitPython          3.1.7
h5py               2.10.0
idna               2.10
ipykernel          5.3.2
ipyparallel        6.3.0
ipython            7.16.1
ipython-genutils   0.2.0
ipywidgets         7.5.1
jedi               0.17.1
Jinja2             2.11.2
jmespath           0.10.0
json5              0.9.5
jsonschema         3.2.0
jupyter-client     6.1.6
jupyter-core       4.6.3
jupyterlab         2.2.0
jupyterlab-server  1.2.0
jupytext           1.5.1
kiwisolver         1.2.0
MarkupSafe         1.1.1
matplotlib         3.2.2
mistune            0.8.4
more-itertools     8.4.0
nbconvert          5.6.1
nbformat           5.0.7
nbopen             0.6
notebook           6.0.3
numpy              1.19.0
packaging          20.4
pandas             1.0.5
pandocfilters      1.4.2
paramiko           2.7.1
parso              0.7.0
pexpect            4.8.0
pickleshare        0.7.5
pip                20.1.1
pluggy             0.13.1
prometheus-client  0.8.0
prompt-toolkit     3.0.5
ptyprocess         0.6.0
py                 1.9.0
pybind11           2.5.0
pycparser          2.20
Pygments           2.6.1
PyNaCl             1.4.0
pyparsing          2.4.7
pyrsistent         0.16.0
pytest             5.4.3
python-dateutil    2.8.1
pytz               2020.1
PyYAML             5.3.1
pyzmq              19.0.1
remotekernel       0.2.4
requests           2.24.0
rk                 0.3b1
s3fs               0.4.2
scipy              1.5.1
semver             2.10.2
Send2Trash         1.5.0
setuptools         49.2.0
six                1.15.0
smmap              3.0.4
terminado          0.8.3
testpath           0.4.4
toml               0.10.1
tornado            6.0.4
traitlets          4.3.3
urllib3            1.25.9
wcwidth            0.2.5
webencodings       0.5.1
wheel              0.34.2
widgetsnbextension 3.5.1
danielballan commented 4 years ago

My first guess is that ZMQ's intergration with asyncio has changed under us and requires a corresponding change to remotekernel. I have made a note to look at this, but won't be able to dig in until September.