That function should just create the function aliases and define the necessary
variables if not already defined. It should not also set the :kernel header
argument if it isn't present in the org-babel-default-header-args:jupyter-LANG
variable.
* ob-jupyter.el (org-babel-jupyter-make-language-alias): Remove setting of :kernel.
(org-babel-jupyter-aliases-from-kernelspecs): Set :kernel after creating a
language alias.
* ob-jupyter.el (org-babel-prep-session:jupyter)
(org-babel-load-session:jupyter): Fix number of arguments to
`org-babel-jupyter--insert-variable-assignments`.
* jupyter-kernel-process-manager.el
(jupyter--after-kernel-process-ready): New macro.
(jupyter-start-kernel [jupyter-command-kernel, jupyter-spec-kernel]): Use it.
(jupyter--block-until-conn-file-access): Remove.
The function writes to `jupyter-runtime-directory` and does not depend on
anything in`jupyter-kernel-process-manager.el` so it is more appropriate in
`jupyter-env.el`.
* jupyter-env.el (jupyter-write-connection-file): New function.
* jupyter-kernel-process-manager.el (jupyter-write-connection-file): Remove.
The test for #219 isn't really testing the root cause of the bug, only a
symptom. And it doesn't catch anything on Emacs < 27.
* test/jupyter-test.el (jupyter-repl-issue-219): Skip on Emacs < 27
If a Jupyter TRAMP remote file contains a .json suffix do not treat it as a
kernel connection file. The connection information is already contained in the
TRAMP method!
* ob-jupyter.el (org-babel-jupyter-parse-session): Do it.
It's main purpose was to not forget to add the `read-only` property to text
that needed it. The code base is stable enough to where this is not an issue
anymore.
* jupyter-repl.el (jupyter-repl-insert): Remove. Update all callers.
* jupyter-python.el (jupyter-handle-error): Ditto.
* ob-jupyter.el (org-babel-jupyter-session-clients)
(org-babel-jupyter-session-key)
(org-babel-edit-prep:jupyter)
(org-babel-jupyter-aliases-from-kernelspecs): Do it.
Introduce the `org-babel-jupyter-initiate-client` generic. Method
implementations return a `jupyter-org-client` depending on the type of :session
as returned by `org-babel-jupyter-parse-session`.
* ob-jupyter.el
(org-babel-jupyter--run-repl)
(org-babel-jupyter--server-repl): Remove.
(org-babel-jupyter-session, org-babel-jupyter-remote-session)
(org-babel-jupyter-server-session): New struct types.
(org-babel-jupyter-parse-session): New function.
(org-babel-jupyter-initiate-client): New generic. Implement a method for each
new struct type based on the removed functions, with some tidying up.
(org-babel-jupyter-initiate-session-by-key): Replace client setting logic with
a call to `org-babel-jupyter-initiate-client`. Move REPL buffer rename code to
an :around method of `org-babel-jupyter-initiate-client`.
* ob-jupyter.el
(org-babel-jupyter--insert-variable-assignments): New function.
(org-babel-prep-session:jupyter, org-babel-load-session:jupyter): Use it.
(org-babel-prep-session:jupyter): Remove DELAY-EVAL argument.
The :file result-parameter of source block interferes with how async result
insertion works, namely how an indicator is inserted to signify that the
results are pending. The parameter is removed in cases where it would
interfere.
* ob-jupyter.el (org-babel-execute:jupyter): Do it.
This variable is `let` bound by `org-babel-execute:jupyter` and its value reset
after that function has completed and therefore does not need to be set to
`nil` by `jupyter-drop-request`.
fixes#234fixes#235
* jupyter-org-client.el: Remove duplicated `defvar` of
`org-babel-jupyter-current-src-block-params`.
(jupyter-drop-request): Remove use of
`org-babel-jupyter-current-src-block-params`.
* jupyter-server.el (jupyter-ioloop, jupyter-server-ioloop): Remove requires.
(jupyter-server): Don't subclass `jupyter-ioloop-comm`.
(jupyter-server--connect-channels, jupyter-server--refresh-comm): Only do
something when the SERVER argument is a `jupyter-comm-layer`, i.e. a
`jupyter-server-ioloop-comm`. We don't check for that class directly since we
would end up requiring ZMQ.
(jupyter-comm-start) [jupyter-server-kernel-manager]: Use the right subclass of
`jupyter-server-abstract-kcomm` depending on if the `jupyter-server` object is
using ZMQ for communication.
(jupyter-server-make-instance): New function. Returns a `jupyter-server`
instance (a `jupyter-server-ioloop-comm`) that uses ZMQ if
`jupyter-server-use-zmq` is non-nil, and a plain old `jupyter-server` instance
otherwise.
(jupyter-current-server): `jupyter-server` -> `jupyter-server-make-instance`.
* ob-jupyter.el (org-babel-jupyter--server-repl): `jupyter-server` ->
`jupyter-server-make-instance`.
* test/test-helper.el (jupyter-test-with-notebook): `jupyter-server` ->
`jupyter-server-make-instance`.
* test/jupyter-test.el: Move all zmq related tests (and code) to
`test/jupyter-zmq-test.el`, add a `zmq` tag to the tests.
* test/test-helper.el (zmq, jupyter-zmq-channel-ioloop)
(jupyter-zmq-channel-ioloop-comm): Remove requires.
(jupyter-test-ioloop-eval-event, jupyter-test-channel-ioloop)
(initialize-instance) [jupyter-echo-client]: Remove uses of ZMQ by using
a `jupyter-mock-comm-layer` for the `kcomm` slot.
(jupyter-test-zmq-sockets): Move to `test/jupyter-zmq-test.el` along with all
related code.
* test/jupyter-zmq-test.el: Add tests moved from `test/jupyter-test.el` and all
related code.
* test/jupyter-server-test.el (jupyter-server): Replace test with one that
takes into account a `jupyter-server`s changed implementation. Before, in
addition to talking to a kernel via the REST API, it managed a set of websocket
connections in a separate process. Now, those websocket connections live in
the current Emacs process.
Ensure that `jupyter-test-with-notebook` uses a `jupyter-server` object by
let binding `jupyter-server-use-zmq` around its call.
(jupyter-server-ioloop-comm): New test with the same body as `jupyter-server`
had before this commit. Skip the test unless `jupyter-server-use-zmq` is
non-nil. Rename `jupyter-server-kernel-comm` to
`jupyter-server-ioloop-kernel-comm`.
The `jupyter-server-kernel-comm` class is re-purposed for this, as mentioned in
the previous commit.
* jupyter-server.el (jupyter-server--ws-on-message): New function.
(jupyter-comm-start, jupyter-comm-stop, jupyter-comm-alive-p, jupyter-send)
[jupyter-server-kernel-comm]: New methods.
In the following, accept means moved from `jupyter-server.el` and move means
moved to `jupyter-server-ioloop-comm.el`. A label like [class] means the
references that appear before the label are actually methods of class.
* jupyter-server.el: Move all `jupyter-event-handler` methods.
(jupyter-server-kernel-comm): Add `ws` slot. The class has
been repurposed for communication using a websocket in the current Emacs
instance. The old behavior has been assigned to the
`jupyter-server-ioloop-kernel-comm` class.
(jupyter-comm-id, jupyter-server-name-client-kernel)
(jupyter-channel-alive-p, jupyter-channels-running-p)
(jupyter-server-kernel-manager, jupyter-current-server): Rename
`jupyter-server-kernel-comm` to `jupyter-server-abstract-kcomm`.
(jupyter-server-kernel-connected-p): Redefine as a generic function. Move the
method body.
(jupyter-comm-start, jupyter-connect-client)
(jupyter-disconnect-client) [jupyter-server]: Move.
(jupyter-comm-start, jupyter-comm-stop)
(jupyter-send, jupyter-comm-alive-p) [jupyter-server-kernel-comm]: Move.
* jupyter-server-ioloop-comm.el: Accept moved `jupyter-event-handler`
methods. Rename `jupyter-server` to `jupyter-server-ioloop-comm`. Rename
`jupyter-server-kernel-comm` to `jupyter-server-ioloop-kernel-comm`.
(jupyter-server-kernel-connected-p)
(jupyter-comm-start, jupyter-connect-client)
(jupyter-disconnect-client) [jupyter-server]: Accept.
(jupyter-comm-start, jupyter-comm-stop)
(jupyter-comm-alive-p, jupyter-send) [jupyter-server-kernel-comm]: Accept.
* jupyter-server-ioloop-comm.el: New file.
* jupyter-server.el (jupyter-server-use-zmq): New variable.
(jupyter-server-abstract-kcomm): New class.
(jupyter-server-kernel-comm): Inherit from it. This is in preparation of
re-purposing the class in a future commit.
* jupyter-repl.el
(jupyter-repl-inhibit-continuation-prompts): New variable.
(jupyter-repl-without-continuation-prompts)
(jupyter-repl-insert-continuation-prompts): Use it.
The following changes are made:
`jupyter-initialize-connection` -> `jupyter-comm-initialize`
`jupyter-connect-client` -> `jupyter-comm-add-handler`
`jupyter-disconnect-client` -> `jupyter-comm-remove-handler`
`jupyter-comm-client-loop` -> `jupyter-comm-handler-loop`
* README.org: Do it.
* jupyter-channel-ioloop-comm: Do it.
* jupyter-client.el: Do it.
* jupyter-comm-layer.el: Do it.
(jupyter-comm-layer): Rename `clients` slot to `handlers`. Update all uses.
* jupyter-kernel-process-manager.el: Do it.
* jupyter-repl.el: Do it.
* jupyter-server.el: Do it.
* jupyter-zmq-channel-comm.el: Do it.
* test/jupyter-server-test.el: Do it.
* test/jupyter-test.el: Do it.
That also happens to use a ZMQ function.
* jupyter-rest-api.el (jupyter-api-upload-large-file): Do it.
* jupyter-tramp.el: Remove mention of `jupyter-api-upload-large-file` in a
comment.
* README.org: Add notes on behavior when a kernel's language name has spaces
and uppercase characters.
* jupyter-base.el (jupyter-canonicalize-language-string): New function.
* jupyter-client.el (jupyter-kernel-info): Use it.
* jupyter-kernelspec.el (jupyter-available-kernelspecs): Use it.
* ob-jupyter.el (org-babel-jupyter-aliases-from-kernelspecs): Use it.
* test/jupyter-test.el (jupyter-canonicalize-language-string): New test.
`jupyter-wait-until-idle` can return immediately if an idle message has already
been received, but the function `jupyter-wait-until` will eventually raise an
error in that case. Avoid the error by checking
`jupyter-request-idle-received-p` before calling `jupyter-wait-until`.
* jupyter-client.el (jupyter-wait-until-idle): Do it.
* ob-jupyter.el (org-babel-execute:jupyter): Account for changes in
`jupyter-wait-until-idle`.
* jupyter-widget-client.el (jupyter-widgets-start-websocket-server)
(jupyter-widgets--initialize-client): New functions.
(jupyter-handle-comm-open): Use them.