Commit graph

1834 commits

Author SHA1 Message Date
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
Nathaniel Nicandro
f4c03e71d1 Add jupyter-format-time-low-res 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
bf6e9014f3 Use filename component of url when retrieving cookies 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
0240edf7bb jupyter-server-ioloop: Wait while receiving websocket messages
Previously the waiting was done in `zmq-poller-wait-all` which wouldn't allow
websocket messages to get handled.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
7d3de9e6b2 Implement jupyter-comm-(start|stop) methods for a jupyter-server-kernel-manager
These are wrappers around calls to the same method for the `comm` slot of a
`jupyter-server-kernel-manager`.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
bed724f2fe jupyter-server: Symmetrize (dis)connect channel events 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
46e4e6c40e jupyter-start-kernel (jupyter-server-kernel-manager): Also start the comm 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
900016d398 Include session ID when connecting websockets 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
df7071eac9 Add jupyter-gc-servers 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
b955f6a40b Add README section on notebook server support 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
1658cd0454 jupyter-kill-kernel (jupyter-server-kernel): Do nothing
There is no need to forcibly kill a kernel since the notebook handles this
already.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
5bd164c224 Error when trying to read a notebook through a server
We can't do much with a JSON representation of a notebook right now.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
9241296b45 jupyter-api-request: Ask for authorization on next request after an un-authorized one
What is a better solution?
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
194df39643 Separate tests that use a notebook server from the main tests 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
de320f83d2 jupyter-current-server: Also consider a remote default-directory 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
4a87d35f76 Jupyter notebook contents API integration with TRAMP 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
e8edd4d5cc Promote time encoding/decoding functions to public
Also use `parse-iso8601-time-string` when decoding
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
1d282c948a Support kernel servers via org-mode source blocks 2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
67831c08fa Support Jupyter kernel servers
* jupyter-client.el (jupyter-initialize-connection): Elevate NOTE to FIXME.
(jupyter-kernel-info): Extend timeout.

* jupyter-kernel-manager.el (jupyter-shutdown-kernel):
(jupyter-interrupt-kernel): Allow any number of arguments.

* jupyter-kernelspec.el (jupyter-find-kernelspecs): Optionally allow specs.

* jupyter-messages.el (jupyter-encode-raw-message): New function.

* jupyter-rest-api.el (jupyter-api-auth-headers): New function.

* jupyter-server-ioloop.el: New file.

* jupyter-server.el: New file.

* test/jupyter-test.el (jupyter-server):
(jupyter-server-kernel-manager):
(jupyter-server-start-new-kernel): New tests.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
9df340bd0f Add REST API
* jupyter-rest-api.el: New file.

* test/jupyter-test.el (jupyter-rest-api):
(jupyter-api--copy-cookies, jupyter-api--password-login):
(jupyter-api-kernel-ws): New tests.

* test/test-helper.el (jupyter-test-rest-api): New macro.
2019-07-24 16:59:04 -05:00
Nathaniel Nicandro
6650dd3588 Bump version 2019-07-24 16:03:22 -05:00
Nathaniel Nicandro
27f7c25bfa Update CHANGELOG 2019-07-24 16:03:22 -05:00
Nathaniel Nicandro
e0531d040c jupyter-repl-ret: Suppress all handlers except :is-complete-reply
Fixes #153.
2019-07-24 14:59:47 -05:00
Nathaniel Nicandro
1e10e161b7 jupyter-ioloop-timeout: Add documentation 2019-07-24 14:40:55 -05:00
Nathaniel Nicandro
1e6e83c12e Preserve outline visibility
* jupyter-org-extensions.el (jupyter-org-closest-jupyter-language)
(jupyter-org-between-block-end-and-result-p):
(jupyter-org-next-busy-src-block):
(jupyter-org-move-src-block): Do it.
2019-07-24 14:40:55 -05:00
Ruslan
7918293c41 Added warning to README.org about possible conflicts with ob-ipython (#135) 2019-07-24 12:50:41 -05:00