* 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.
`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`.
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.
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`.
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.
* 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.
* 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`.
* 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`.
This is needed because `org-mode` merges many sources of source block params so
its not enough to just re-compute the parameters in `jupyter-generate-request`
using `org-babel-get-src-block-info` or `org-babel-log-get-info`.
* ob-jupyter.el (org-babel-jupyter--server-repl): Do it.
(org-babel-jupyter-make-language-alias): Set `org-babel-tangle-lang-exts` and
`org-src-lang-modes` also.
(org-babel-jupyter-aliases-from-kernelspecs): Accept an optional `specs`
argument. Move setting of `org-babel-tangle-lang-exts` and `org-src-lang-modes`
to `org-babel-jupyter-make-language-alias`.
The normal way of loading `ob-jupyter` is through `org-babel-do-load-languages`
so a users `exec-path` should be enabled by that time and so there is a higher
chance that it is setup correctly. See #151.
* jupyter-org-client.el (jupyter-org-request-at-point): Do it.
(org-babel-jupyter-src-block-session): New declare.
* ob-jupyter.el (org-babel-jupyter-session-clients): Add doc about keys.
* test/jupyter-test.el (jupyter-org-request-at-point): New test.
* jupyter-env.el (jupyter-runtime-directory): Remove custom status.
New function definition.
* jupyter-kernel-manager.el (jupyter-write-connection-file):
Use new function.
* ob-jupyter.el (org-babel-jupyter--run-repl):
Remove setting of `jupyter-runtime-directory`.
* test/jupyter-test.el (jupyter-runtime-directory): New test.
Fixes#137
* jupyter-base.el (jupyter-kernelspec): Un-require.
(jupyter-command, jupyter-locate-python)
(jupyter-runtime-directory): Move to new file `jupyter-env.el`
(jupyter-include-other-output, jupyter-iopub-message-hook)
(jupyter-shell-message-hook)
(jupyter-stdin-message-hook): Move to `jupyter-client.el`
(jupyter-sha256, jupyter-hmac-sha256):
(jupytern-new-uuid): Move to `jupyter-messages.el`. Add declaration of
`jupyter-new-uuid` to account for its removal.
(jupyter-create-connection-info)
(jupyter-write-connection-file): Move to `jupyter-kernel-manager.el`
(jupyter-connect-endpoint, jupyter-connect-channel): Move to `jupyter-channels.el`
* jupyter-channels.el: Accept moved functions.
* jupyter-client.el: Accept moved variables.
* jupyter-kernel-manager.el: Accept moved functions.
(jupyter-env, jupyter-kernelspec): New requires.
* jupyter-kernelspec (jupyter-env): New require.
(jupyter-command): Remove declaration.
(jupyter-read-plist-from-string): New declaration.
* jupyter-messages.el: Accept moved functions.
(hmac-def, json): New requires.
* jupyter-org-extensions.el (jupyter-kernelspec): New require.
* jupyter-repl.el (jupyter-kernelspec): New require.
* jupyter-env.el: New file.
* ob-jupyter.el (jupyter-env, jupyter-kernelspec): New requires.
* test/jupyter-test.el (jupyter-env): New require.