millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 123 forks source link

Compatibility with Jupyter 3.0 #803

Closed nakkaya closed 2 years ago

nakkaya commented 3 years ago

In issue #783 there was talk of lab not working with ein however I used to have a docker container running jupyter lab that I could connect to using ein without any issues. The other day I rebuilt the container which installed the latest version of jupyter 3.X that is causing the api error. I am guessing this is not related to running lab or notebook but new version has changed the api.

danielfleischer commented 3 years ago

I get

error in process sentinel: if: Api 1 unsupported error in process sentinel: Api 1 unsupported

Jupyter lab version 3.1.4 (dev), 3.0.16 (app)

kendatsuba commented 2 years ago

It seems that ein is picking jupyter_server version (1.11.1 as of now) as the notebook/kernel api version. This gives ein the impression that the api version is lower than 2 and since versions lower than 1 are not supported it fails with that error. The jupyter messaging api however is substantially unchanged:

https://jupyter-client.readthedocs.io/en/stable/messaging.html

If you change this line:

https://github.com/millejoh/emacs-ipython-notebook/blob/0600c286bd7b0812f4908d7df1be279b6b65923f/lisp/ein-kernel.el#L64

to

:api-version 5

it should work as a workaround.

martin-liu commented 2 years ago

It's actually calling <URL>/api which return something like {"version": "6.4.4"} to get the version https://github.com/millejoh/emacs-ipython-notebook/blob/0600c286bd7b0812f4908d7df1be279b6b65923f/lisp/ein-query.el#L166-L172

This version is not accurate, the better way is to call <URL>/api/spec.yaml which return a yaml spec like below:

swagger: '2.0'
info:
  title: Jupyter Notebook API
  description: Notebook API
  version: "5"
  contact:
    name: Jupyter Project
    url: https://jupyter.org
# will be prefixed to all paths
basePath: /
produces:
  - application/json
consumes:
  - application/json
parameters:
...

And we can see version: "5" which is the real api version

dickmao commented 2 years ago

Damn, @martin-liu is dropping truth bombs.

dickmao commented 2 years ago

I tested d17c443 against a server instantiated via jupyter lab and it did not fail immediately.

martin-liu commented 2 years ago

@dickmao Wow, thanks for quick action! But I tried several different Jupyter lab versions and some of them have different description (from jupyter-server) which will fail the regexp check.

Created a simple PR https://github.com/millejoh/emacs-ipython-notebook/pull/811 to fix that, can you have a check?