Commit graph

444 commits

Author SHA1 Message Date
Nathaniel Nicandro
dfd1d1e02d Remove the kernel slot of a client
`jupyter-websocket-io` now returns, in addition to an IO function, a
kernel action subscriber.  A client now sends messages to the
subscriber to interrupt or shutdown a kernel instead of doing so using
a `kernel` slot.

Also add the `jupyter-kernel-action` convenience function for
evaluating arbitrary code on a client's kernel.
2023-02-13 20:25:05 -06:00
Nathaniel Nicandro
e10efe4274 Remove no longer used functions 2023-02-13 20:25:05 -06:00
Nathaniel Nicandro
e03cedea10 Fix jupyter-shutdown-kernel
Sending a shutdown request actually restarts a kernel behind a Jupyter
notebook, so shutdown using the kernel's method.

Disconnect the client after shutting down so that
`jupyter-connected-p` returns nil after shutdown.
2023-02-13 20:25:05 -06:00
Nathaniel Nicandro
dc336ae638 Fix input_request client handler 2023-02-13 20:25:05 -06:00
Nathaniel Nicandro
134167e65e Remove keyword message types 2023-02-13 20:25:05 -06:00
Nathaniel Nicandro
a430f4f0e1 Remove jupyter-channels-running-p 2023-02-13 20:25:05 -06:00
Nathaniel Nicandro
436329ee50 Fix wrong slot name 2023-02-13 20:25:05 -06:00
Nathaniel Nicandro
a23f8fe864 Use jupyter-generate-request in jupyter-request 2023-02-13 20:25:05 -06:00
Nathaniel Nicandro
1323feb33f Simplify jupyter-websocket-io 2023-02-13 20:25:05 -06:00
Nathaniel Nicandro
2b668f755e Have a client keep a reference to the kernel its connected to 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
b84e1320c6 Add jupyter-connected-p 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
3b8865d222 Remove kernel manager related code 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
ab4e53c1bf Set IO slot after making client instance
Apparently this is needed.
2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
17460f8b7c Use jupyter-*-request functions 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
e133c34707 Add do prefix to launch,shutdown,interrupt functions of a kernel
launch,shutdown,interrupt are now monadic functions.
2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
dcf2e2ef6e Remove jupyter-finalized-object 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
162a0969b9 jupyter-shutdown-kernel 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
e19140fa94 Flush out how a client connects to a kernel 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
f28c1c649a Make jupyter-request pure 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
ee0446ccaa Take into account the changes in a kernel's I/O publisher
Messages received by a kernel's I/O publisher are solely message
property lists.
2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
c12a519ac0 Add TODO 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
550ced27bc jupyter-client.el: Introduce io slot 2023-02-13 20:22:50 -06:00
Nathaniel Nicandro
bd7a49fec6 jupyter-after -> jupyter-then 2023-02-13 20:22:49 -06:00
Nathaniel Nicandro
d6b6bd60ce Monad things 2023-02-13 20:22:49 -06:00
Nathaniel Nicandro
1191153ca4 Fix use of jupyter--merge-message-defaults 2023-02-13 20:22:49 -06:00
Nathaniel Nicandro
2d807d8670 Replace uses of jupyter-clients
This function is used elsewhere.
2023-02-13 20:22:49 -06:00
Nathaniel Nicandro
f627175f57 Update jupyter-client to get rid off jupyter-connection-hb 2023-02-13 20:22:49 -06:00
Nathaniel Nicandro
7fa06ca5f9 Doc and comments 2023-02-13 20:22:49 -06:00
Nathaniel Nicandro
31409cf449 Remove document duplication 2023-02-13 20:22:49 -06:00
Nathaniel Nicandro
f32cd090e1 Start using the new interface in jupyter-client.el 2023-02-13 20:22:49 -06:00
Nathaniel Nicandro
9ab2762323 Remove ref to jupyter-connection-hb 2023-02-13 20:22:49 -06:00
Nathaniel Nicandro
2d8018b7f3 Remove jupyter-event-handler 2023-02-13 20:22:45 -06:00
Nathaniel Nicandro
58f281c7fc Remove conn slot of a client and clients slot of a kernel 2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
4abf0d0714 Cleanup whitespace 2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
73955c2d14 Clarify the name of some internally used functions 2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
9b2a66868a IO function and connections 2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
6ca11d695d Add a special case to the jupyter-send method of a client
This is to handle message relaying in `jupyter-widget-client`.

* jupyter-client.el (jupyter-send): Do it.  Update doc.

* jupyter-widget-client.el (jupyter-widgets-on-message): Change
  argument order of `jupyter-send` call.
2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
e111aba096 Move jupyter-(dis)?connect into the jupyter-connection interface
The former pair of methods were only used to connect clients and
kernels.
2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
348df7feb5 Remove jupyter-send-* methods
These methods were not used much internally.
2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
0c6d90cc7e Undo a client connection when a kernel doesn't respond
* jupyter-client.el (jupyter-client): Do it.
2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
b814e05223 Formalize jupyter-disconnect and jupyter-connect 2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
39c30fff11 Fix kernel-alive-p predicate 2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
a33231b4d3 Rename many methods 2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
0521bca637 Add shutdown and interrupt functions to a client
Somehow this was not done until now.  I had in my mind that shutting
down and interrupting a kernel was part of the responsibility of the
manager class.  This is how it is done in the reference
jupyter/jupyter_client implementation, I think.

* jupyter-client.el (jupyter-shutdown-kernel)
(jupyter-interrupt-kernel): New functions.

* jupyter-repl.el
(jupyter-repl-restart-kernel): Use the `jupyter-shutdown-kernel`
method to restart a client's kernel.
2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
20c1c80bc0 Remove jupyter-client-has-manager-p
* jupyter-client.el (jupyter-client-has-manager-p): Do it.
(initialize-instance)
* jupyter-repl.el
(jupyter-repl-kill-buffer-query-function)
* test/jupyter-test.el (jupyter-repl-client-predicates): Update all callers.
2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
bdb8488bf3 Remove comm-layer and related
Remove `jupyter-channel-ioloop-comm.el`, `jupyter-comm-layer.el`, `jupyter-ioloop-comm.el`.
Remove the kcomm slot of a client, replace it with a kernel slot.
jupyter-server.el: Remove kernel communication related code.
Remove `jupyter-kernel-lifetime`.

* jupyter-kernel-manager.el (jupyter-kernel-lifetime): Do it. Update
  all subclasses. All methods it defined no longer take a type.  This
  is in preparation of removing most of them altogether.
(jupyter-kernel-manager): Update doc.

* jupyter-kernel-process-manager.el
(jupyter-kernel-process): Update documentation.
(jupyter--kernel-died-process-sentinel): Remove type check.

* test/jupyter-test.el (jupyter-local-tcp-conn-info): Remove.
(jupyter-kernel-lifetime): Remove.

[conn] Have `jupyter-kernel-manager.el` re-direct to the new interface

* jupyter-kernel-manager.el
(jupyter-kernel-alive-p): Check that the kernel is
live, not an Emacs connection to it.
(jupyter-start-kernel)
[jupyter-kernel, jupyter-kernel-manager]: Use `jupyter-launch`.
(jupyter-shutdown-kernel) [jupyter-kernel-manager]: Use `jupyer-shutdown`.
(jupyter-kill-kernel) [jupyter-kernel]: Ditto. Remove a method
definition.
(jupyter-make-client): Use `jupyter-client`.
(jupyter-interrupt-kernel) [jupyter-kernel-manager]: Use `jupyer-interrupt`.

* jupyter-kernel-process-manager.el: Remove.

Don't add finalizer to cleanup process.

Cleanup is done in other ways, e.g. in
`jupyter--gc-kernel-processes`.  Also it doesn't make sense to delete
a general kernel because the object that represents it in Emacs is no
longer accessible.
2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
707ebd189f Add jupyter-client method 2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
4164f13bdc Remove jupyter-hb-comm
* jupyter-channel-ioloop-comm.el
(jupyter-channel-ioloop-comm): Remove it from the super-class list.
Add a `hb` slot to compensate.
(jupyter-hb-beating-p, jupyter-hb-pause)
(jupyter-hb-unpause): Relocated from...

* jupyter-comm-layer.el: ...here.

* jupyter-client.el (jupyter-hb-beating-p, jupyter-hb-pause)
(jupyter-hb-unpause): Check for a `hb` slot instead of it.
2023-02-13 20:21:14 -06:00
Nathaniel Nicandro
2e8689227f Add a way to debug the message stream from a kernel
Previously it was hard to step through the code whenever messages were
coming in live from a kernel due to the asynchronous nature of
handling process output in Emacs.
2023-02-03 20:12:32 -06:00
Nathaniel Nicandro
b87ecf0cd3 Scroll to bottom of window on new stream output
See #244
2021-11-17 19:36:46 -06:00