Commit graph

1809 commits

Author SHA1 Message Date
Nathaniel Nicandro
39974d1841 jupyter-repl-restart-kernel: Use a kernel manager to restart if possible
* jupyter-repl.el (jupyter-repl-restart-kernel):
Call the `jupyter-shutdown-kernel` method of the client's kernel manager if
available.
Remove code that started a kernel when restarting if a manager was available,
this is already handled by `jupyter-shutdown-kernel`.
2019-08-08 22:04:27 -05:00
Nathaniel Nicandro
7a1c91eef4 Add the jupyter-kernel-process-manager class
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`.
2019-08-08 22:04:27 -05:00
Nathaniel Nicandro
23f41cf86c Add jupyter-kernel-alive-p method for a jupyter-kernel-client
* jupyter-client.el (jupyter-kernel-alive-p): Do it.

* jupyter-repl.el (jupyter-repl-connected-p): Use it.
2019-08-08 21:55:22 -05:00
Nathaniel Nicandro
8c711dd3ce jupyter-repl-client-has-manager-p -> jupyter-client-has-manager-p
* jupyter-client.el (jupyter-client-has-manager-p): New function.

* jupyter-repl.el (jupyter-repl-client-has-manager-p): Remove function.
(jupyter-repl-connected-p, jupyter-repl-kill-buffer-query-function):
(jupyter-repl-restart-kernel, jupyter-repl-display-kernel-buffer):
Rename calls to `jupyter-repl-client-has-manager-p` to
`jupyter-client-has-manager-p`.

* test/jupyter-test.el (jupyter-repl-client-predicates):
Rename calls to `jupyter-repl-client-has-manager-p` to
`jupyter-client-has-manager-p`.
2019-08-08 21:55:22 -05:00
Nathaniel Nicandro
3beb736853 Add jupyter-repl-completing-read-repl-buffer
* jupyter-repl.el (jupyter-repl-completing-read-repl-buffer): Do it.
(jupyter-repl-restart-kernel, jupyter-repl-associate-buffer): Use it.
2019-08-08 18:22:59 -05:00
Nathaniel Nicandro
7e4b24288b jupyter-add-callback: Mention behavior for multiple callbacks 2019-08-08 17:51:35 -05:00
Nathaniel Nicandro
f4aa755126 Add jupyter-server--refresh-comm 2019-08-08 17:51:20 -05:00
Nathaniel Nicandro
388d7b923c Add Gitter badge 2019-08-02 13:58:41 -05:00
Nathaniel Nicandro
5b34e99bbf jupyter-hb-channel: Increase timeouts
See #141 and #164.

* jupyter-zmq-channel.el (jupyter-hb-max-failures): Reduce to 3.
(jupyter-hb-channel): Increase `time-to-dead` slot to 10 s.
2019-08-02 11:48:28 -05:00
Nathaniel Nicandro
6b1baf1fde jupyter-api-with-subprocess-setup: Set url-cookie-file to its parent process value 2019-08-01 16:26:43 -05:00
Nathaniel Nicandro
4e3a8d4dc2 README.org: Mention jupyter-api-authentication-method 2019-07-31 14:28:01 -05:00
Nathaniel Nicandro
8f35f135d7 jupyter-gc-servers: Delete cookies when cleaning up servers
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.
2019-07-31 14:19:15 -05:00
Nathaniel Nicandro
f7f8bfa52c jupyter-api-url-request: Don't override a user customizable variable 2019-07-30 10:24:31 -05:00
Nathaniel Nicandro
bcc438bc1f Add FUNDING.yml 2019-07-29 18:18:32 -05:00
Nathaniel Nicandro
98adac6d31 Fix definitions of jupyter-tramp-file-name(-method)?-p
Fixes #155.

* jupyter-tramp.el (jupyter-tramp-file-name-method-p):
(jupyter-tramp-file-name-p): Adhere to documentation.

* test/jupyter-tramp-test.el (jupyter-tramp-file-name-p): Add test.
2019-07-27 12:22:47 -05:00
Nathaniel Nicandro
a0b33a5861 jupyter-org--fixed-width-to-example-block: Preserve blank lines 2019-07-27 00:06:18 -05:00
Nathaniel Nicandro
c91861cef9 jupyter-org--delete-element -> jupyter-org-delete-element
* jupyter-org-client.el (jupyter-org--delete-element):
Do it and also adhere to documentation. Update all callers.
2019-07-27 00:04:34 -05:00
Nathaniel Nicandro
93f21b077b jupyter-org--do-insert-result: Handle control codes in stream output
* jupyter-org-client.el (jupyter-handle-stream): Remove control code handling.
(jupyter-org--handle-control-codes): New function.
(jupyter-org--do-insert-result): Do it.
2019-07-26 23:16:05 -05:00
Nathaniel Nicandro
dd4b4e3a82 jupyter-server-mode-set-client: Increase timeout in test
There are often failures on Appveyor.
2019-07-25 10:23:23 -05:00
Nathaniel Nicandro
11b293438d jupyter-generate-request (jupyter-org-client): Consider babel-call org elements
Fixes #154.
2019-07-25 03:48:18 -05:00
Nathaniel Nicandro
66c794964c org-babel-jupyter-src-block-session: Consider babel-call org elements 2019-07-25 03:48:18 -05:00
Nathaniel Nicandro
d11aa3f10d Fix byte compile warning 2019-07-24 17:28:25 -05:00
Nathaniel Nicandro
a54aa03010 Update CHANGELOG 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
a7da89eae4 README.org: Mention naming notebook server kernels 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
4b55a29726 org-babel-jupyter--server-repl: Associate session name with kernel ID
So that `M-x jupyter-server-list-kernels` will show which kernel corresponds to
an Org mode source block session.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
6f97c958da Add jupyter-server-kernel-names variable and associated functions
Used to associate names to kernel IDs.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
ea22bd512d Re-authenticate after "Access Forbidden" 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
e8540667c7 jupyter-api-login: Mark response buffer as dead 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
c711562207 jupyter-gc-servers: Only stop server comm if it is alive
Bug found by @dcherian, see
https://github.com/dzop/emacs-jupyter/issues/131#issuecomment-510920312
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
81797ccbb5 Mention server kernel list keybindings in README
Co-Authored-By: Deepak Cherian <dcherian@users.noreply.github.com>
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
388f593955 jupyter-kernel-alive-p (jupyter-server-kernel): Handle non-existent server 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
6d7b07333f Add jupyter-api-server-exists-p 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
36b9edc31e jupyter-server-find-manager: Don't check if the kernel is alive
Delay any errors, e.g. if the server is no longer alive, to where they would be
more useful.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
5efa64ff19 jupyter-server-list-kernels: Better documentation 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
3aa889b25c org-babel-jupyter--server-repl: Make language aliases if necessary
* 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`.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
816a30f5a7 jupyter-api-copy-cookies-for-websocket: Ensure cookies have expiration date 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
36aec72814 jupyter-api-copy-cookies-for-websocket: Ensure modified cookies will be written to file 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
239715919f Move server slot of jupyter-server-kernel-manager to the kernel object 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
9fe99744fd jupyter-api-construct-endpoint: No need to encode components of endpoint
This is already handled by `url-encode-url` when creating the HTTP request.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
fa3f7c8b31 Handle encoding when making REST API requests
* 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.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
dd4332a7cc jupyter-rest-client: Raise an error when GnuTLS unavailable for HTTPS connections 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
933e5c65a6 Cache file model contents in a buffer
* 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.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
d018434b4a jupyter-tramp-get-file-model: Break up into more functions 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
59c2e88ae6 jupyter-api-content-path: Drop local drive letter on Windows 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
8d45a0242d Refactor notebook server related tests
* 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
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
0e34e73cae jupyter-api-request: Don't reset auth state on an unauthorized request 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
248dc34117 Define jupyter-api-request-(headers|method|data)
So as to make it easier to transition away from `url-retrieve` if necessary in
the future.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
e35981d147 jupyter-rest-api.el: Refactor login and authentication 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
a4aaa7d1db jupyter-api-request: Refactor
* 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
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
e53973095c jupyter-api-parse-response: Handle url-max-redirects error 2019-07-24 16:59:04 -05:00