`jupyter-server-make-instance` is from another branch.
* ob-jupyter.el: Remove `jupyter-server-make-instance` declaration.
(org-babel-jupyter-initiate-client): Replace its use with `jupyter-server`.
The `jupyter-kill-kernel` of a kernel manager serves no purpose, just
use `jupyter-shutdown-kernel`.
* jupyter-kernel-manager.el
(jupyter-kill-kernel) [jupyter-kernel-manager]: Remove.
* jupyter-server.el (jupyter-kill-kernel) [jupyter-server-kernel-manager]: Remove.
This commit adds the function `org-babel-jupyter--babel-map` and some
auxiliary functions to simplify the code for source block
overriding. The old implementation was very hard to follow, these
changes should hopefully make the code more readable.
* ob-jupyter.el (org-babel-jupyter--override-restore-header-args)
(org-babel-jupyter--override-restore-src-block): Remove.
(org-babel-jupyter--babel-vars): New variable.
(org-babel-jupyter--babel-op-symbol)
(org-babel-jupyter--babel-var-symbol)
(org-babel-jupyter--babel-map): New functions.
(org-babel-jupyter-override-src-block)
(org-babel-jupyter-restore-src-block)
(org-babel-jupyter-make-language-alias): Use them.
The implementations are really aliases of `jupyter-comm-alive-p` so
keep that one instead. The `jupyter-channels-running-p` method is a
remnant of an older design, still used by `jupyter-kernel-client'
though.
* jupyter-channel-ioloop-comm.el: Do it.
* jupyter-server.el: Do it.
This groups the DATA and METADATA argument of `jupyter-org-result`
into a CONTENT argument to finish up a change made in a previous
commit that removed `jupyter-loop-over-mime`. The METADATA argument
is rarely if every used, so it doesn't make sense to have all those
method implementations have to provide it.
* jupyter-org-client.el
(jupyter-org--image-result): Change group DATA and METADATA into a
CONTENT argument. Change argument ordering. Update all callers.
Cleanup the documentation to reflect the changes.
(jupyter-org-result): Similarly, group those two arguments into the
one argument. Update all callers in this file, also...
* README.org: ...here
* jupyter-R.el: ...here
* jupyter-python.el: ...and here
It is replaced with `jupyter-map-mime-bundle` which is a function.
* jupyter-base.el (jupyter-loop-over-mime): Remove.
(jupyter-map-mime-bundle): New function. Update call sites of the
removed function, with calls to this function.
(jupyter-normalize-data): Return a mime bundle, a property list with
:data and :metadata keys. Update all callers.
* jupyter-mime.el (jupyter-insert): Updated to take into account the
previously mentioned changes.
* jupyter-org-client.el (jupyter-org-result): Ditto.
* test/jupyter-test.el (jupyter-loop-over-mime): Rename to
`jupyter-map-mime-bundle` and update the test to consider it.
The `jupyter-zmq-channel-comm.el` file was more of an experiment and
is unused. It also causes failures on Emacs 27 due to missing
`thread-alive-p` function in 27.
* jupyter-zmq-channel-comm.el: Remove.
* test/jupyter-test.el: Remove the related `require`. Re-work tests
that used `jupyter-zmq-channel-comm` to not use it.
In `org-babel-jupyter-initiate-session-by-key`, the function to
disassociate a client from a :session was added to the
`current-buffer`s value of `kill-buffer-hook` but it should be added
to the REPL buffer's value of that hook.
fixes#240
* ob-jupyter.el
(org-babel-jupyter-initiate-session-by-key): Add to the local value of
`kill-buffer-hook` in the REPL's buffer.
* test/jupyter-test.el
(org-babel-jupyter-initiate-session-by-key): New test.
Converting to lowercase was done arbitrarily. So that one could write
`(jupyter-lang wolfram-language)` instead of
`(jupyter-lang Wolfram-Language)`.
fixes#241
* CHANGELOG.org: Add note.
* README.org: Update relevant sections.
* jupyter-base.el (jupyter-canonicalize-language-string): Do it.
* ob-jupyter.el (org-babel-jupyter-aliases-from-kernelspecs):
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`.