Commit 3c2884bc authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

Add (jupyter servers).

* guix-kernel/jupyter-client.scm: Rename to...
* jupyter/servers.scm: ... this.
(KERNEL-INFO, guile-version): Remove.
(json->kernel): Rename to...
(connection-file->kernel): ... this.
* guix-jupyter-container.scm: Adjust accordingly.
* guix-jupyter-kernel.scm (KERNEL-INFO): New variable.
(kernel): Use new 'connection-file->kernel' name.
* Makefile.am (SOURCES): Adjust file list accordingly.
parent 1abf4098
......@@ -23,9 +23,9 @@ godir=@guileobjectdir@
SOURCES = \
jupyter/messages.scm \
jupyter/kernels.scm \
jupyter/servers.scm \
guix-kernel/environ.scm \
guix-kernel/magic.scm \
guix-kernel/jupyter-client.scm \
guix-jupyter-kernel.scm \
guix-jupyter-container.scm
......
......@@ -28,8 +28,7 @@
(sxml simple)
(jupyter messages)
(jupyter kernels)
(guix-kernel magic)
(guix-kernel jupyter-client))
(guix-kernel magic))
;;
;; Kernel information.
......
......@@ -33,9 +33,9 @@
(guix build utils)
(jupyter messages)
(jupyter kernels)
(jupyter servers)
(guix-kernel magic)
(guix-kernel environ)
(guix-kernel jupyter-client))
(guix-kernel environ))
(define session-id (random (* 255 255)
(seed->random-state
......@@ -104,10 +104,26 @@ acts as a proxy to an actual kernel."
(define (ignore-request kernel message containers count)
(values containers count))
(define KERNEL-INFO
`(("protocol_version" . "5.3.0")
("implementation" . "Guix Jupyter kernel")
("implementation_version" . "0.0.2")
("language_info" .
(("name" . "guile")
("version" . ,(effective-version))
("mimetype" . "application/x-scheme")
("file_extension" . ".scm")
("pygments_lexer" . "scheme")
("codemirror_mode" . "scheme")))
("banner" . "Guix kernel")
("help_links" .
(("Gitlab Inria" .
"https://gitlab.inria.fr/guix-hpc/guix-kernel")))))
;; Send kernel-info.
(define (reply-kernel-info-request kernel message containers count)
(send-message kernel (reply message "kernel_info_reply"
(scm->json-string KERNEL-INFO)))
(scm->json-string KERNEL-INFO)))
(values containers count))
(define (reply-execute-request kernel message containers count)
......@@ -285,7 +301,7 @@ MESSAGE."
;; Start!
(let ((kernel (call-with-input-file (car (last-pair (command-line)))
json->kernel)))
connection-file->kernel)))
(sigaction SIGTERM (exit-handler kernel))
(sigaction SIGINT (exit-handler kernel))
(start-kernel (start-container kernel "default" '())
......
......@@ -15,23 +15,23 @@
;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(define-module (guix-kernel jupyter-client)
#:use-module (jupyter messages)
(define-module (jupyter servers)
#:use-module (jupyter kernels)
#:use-module (simple-zmq)
#:use-module (json)
#:use-module (rnrs bytevectors)
#:use-module (ice-9 match)
#:export (guile-version
KERNEL-INFO
#:export (connection-file->kernel))
json->kernel))
;;
;; Kernel information.
;;
;;; Commentary:
;;;
;;; This module provides support for implementing Jupyter kernels, as
;;; described at
;;; <https://jupyter-client.readthedocs.io/en/latest/kernels.html>.
;;;
;;; Code:
(define* (json->kernel port #:key (name "guix"))
(define* (connection-file->kernel port #:key (name "guix"))
"Read the contents of a Jupyter \"connection file\" from PORT and return a
<kernel> record."
;; See <https://jupyter-client.readthedocs.io/en/stable/kernels.html#connection-files>.
......@@ -62,22 +62,3 @@
(make-socket ZMQ_REP (assoc-ref table "hb_port"))
#:iosub
(make-socket ZMQ_PUB (assoc-ref table "iopub_port")))))
(define guile-version (effective-version))
(define KERNEL-INFO
`(("protocol_version" . "5.3.0")
("implementation" . "Guix Jupyter kernel")
("implementation_version" . "0.0.2")
("language_info" .
(("name" . "guile")
("version" . ,guile-version)
("mimetype" . "application/x-scheme")
("file_extension" . ".scm")
("pygments_lexer" . "scheme")
("codemirror_mode" . "scheme")))
("banner" . "Guix kernel")
("help_links" .
(("Gitlab Inria" .
"https://gitlab.inria.fr/guix-hpc/guix-kernel")))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment