Replace it with a handler function passed to `jupyter-ioloop-start`.
* jupyter-ioloop-comm.el: Do it.
* jupyter-channel-ioloop-comm.el: Do it.
* jupyter-channel-ioloop-comm.el: Do it.
* jupyter-ioloop.el: Do it. Update comments and doc.
(jupyter-ioloop--delete-process): Remove. It was used to perform
cleanup when the object used for dispatching to a handler method was
garbage collected. Since we no longer rely on having an object for
dispatching, preferring just a function to call, its not needed.
(jupyter-ioloop--make-filter): Fall back to calling handler function
instead of `jupyter-ioloop-handler`. Only handle ioloop start/stop
events internally. This means we can remove the check for those in
`jupyter-ioloop-comm`.
* test/jupyter-test.el: Update tests to take into account above
changes.
* ob-jupyter.el
(org-babel-jupyter-server-session)
(org-babel-jupyter-parse-session): Convert to method and re-implement
with :extra methods.
* test/jupyter-server-test.el
(org-babel-jupyter-server-session): New test.
* test/jupyter-test.el
(org-babel-jupyter-parse-session): Move test of server based sessions
to the new test.
but first...
* jupyter-base.el: ...idle-received-p -> idle-p for jupyter-request objects
* jupyter-client.el: ...then, do it.
* test/jupyter-test.el: Do it.
These will be used in future commits.
* jupyter-client.el (jupyter-idle-sync)
(jupyter-add-idle-sync-hook): New functions.
* test/jupyter-test.el (jupyter-idle-sync): New test.
The following changes are made:
jupyter--run-handler-p -> jupyter--request-allows-handler-p
jupyter--handler-dispatch -> jupyter--run-handler
* jupyter-client.el: Do it.
* test/jupyter-test.el: Do it.
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.
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):
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
* 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 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.
* 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.
Since we are using keyword to represent channels on the client level, use a
plist of channels on the comm layer level instead of channel slots. This allows
us to remove `jupyter-comm-channel` and simplify the relevant code somewhat.
So as to further generalize and separate out the abstract kernel manager class
from its various implementations.
* jupyter-kernel-manager.el (jupyter-meta-kernel): Fix documentation.
(jupyter-kernel-process, jupyter-command-kernel, jupyter-spec-kernel):
Move related functions and methods to `jupyter-kernel-process-manager.el`
(jupyter-kernel-manager-base): Remove class.
(jupyter-kernel-manager): Re-purpose class as the base class of all kernel
managers. The class corresponding to the old functionality is now named
`jupyter-kernel-process-manager`. Move all related functions and methods for
`jupyter-kernel-process-manager` to `jupyter-kernel-process-manager.el`.
* jupyter-kernel-process-manager.el: New file.
* jupyter-repl.el: Require `jupyter-kernel-process-manager` instead of
`jupyter-kernel-manager`.
* jupyter-server.el (jupyter-server-kernel-manager): Inherit from
`jupyter-kernel-manager` instead of `jupyter-kernel-manager-base`.
* test/jupyter-test.el (jupyter-kernel-lifetime)
(jupyter-command-kernel): Use `jupyter-kernel-process-manager` instead of
`jupyter-kernel-manager`.
* test/test-helper.el: Require `jupyter-kernel-process-manager` instead of
`jupyter-kernel-manager`.
See #161
* jupyter-rest-api.el (jupyter-api--delete-cookie):
(jupyter-api-delete-cookies): New functions.
* jupyter-server.el (jupyter-gc-servers): Do it.
* test/jupyter-server-test.el (jupyter-api-delete-cookies): New test.
* jupyter-rest-api.el: Ensure strings are encoded before making HTTP request.
(jupyter-api-http-request): Encode JSON as utf-8.
(jupyter-api-xsrf-header-from-cookies): Ensure header isn't multibyte.
(jupyter-api-authenticate): For the token method, ensure token isn't multibyte.
(jupyter-api-copy-file): Encode string before encoding to base64 for binary content.
(jupyter-api-read-file-content): Decode content as utf-8 when necessary.
* jupyter-tramp.el
(jupyter-tramp-write-region): Ensure only `utf-8` or `binary` coding systems
are used since Jupyter only supports those.
* test/jupyter-tramp-test.el: Update for above changes.
* jupyter-rest-api.el (jupyter-api-content-buffer): New function.
(jupyter-api-insert-model-content): Use it.
* jupyter-tramp.el (jupyter-tramp-file-local-copy): Use it.
* Start notebook on-demand during tests
* Do cleanup of sockets/processes when killing Emacs
* This should work around intermittent core dumps on Travis due to epoll
reconnect attempts.
* Simplify tests by creating and using setup/teardown macros
* jupyter-rest-api.el (jupyter-api-url): Remove.
(jupyter-api--request): Remove. Work moved into `jupyter-api-request`.
(jupyter-api--url-request): Rename to `jupyter-api-url-request`.
Update all callers.
(jupyter-api-add-websocket-headers)
(jupyter-api-construct-endpoint): New functions.
(jupyter-api-request): Use them.
Don't assume "api" prefixes endpoint, update all callers.
(jupyter-api-get-file-model)
(jupyter-api-get-kernel-ws):
Update to account for how query parameters are
passed in `jupyter-api-request`.
* jupyter-server-test: Update tests for changes to `jupyter-api-request`.
(jupyter-api-add-websocket-headers)
(jupyter-api-construct-endpoint): New tests.
squash! jupyter-api-request: Refactor