Commit 591d5814 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

messages: Add <execute-request>.

* jupyter/messages.scm (<execute-request>): New record type.
* guix-jupyter-kernel.scm (reply-execute-request): Use it.
* tests/kernels.scm ("execute_request"): Likewise.
parent b23ee453
...@@ -229,8 +229,8 @@ stripped." ...@@ -229,8 +229,8 @@ stripped."
,@(alist-delete "code" content)))))) ,@(alist-delete "code" content))))))
(define (reply-execute-request kernel kind message state) (define (reply-execute-request kernel kind message state)
(let* ((content (message-content message)) (let* ((request (json->execute-request (message-content message)))
(code (assoc-ref (json-string->scm content) "code")) (code (execute-request-code request))
(line (string-take code (line (string-take code
(or (string-index code #\newline) (or (string-index code #\newline)
(string-length code)))) (string-length code))))
......
...@@ -78,7 +78,17 @@ ...@@ -78,7 +78,17 @@
kernel-status kernel-status
kernel-status-execution-state kernel-status-execution-state
json->kernel-status json->kernel-status
kernel-status->json)) kernel-status->json
execute-request?
execute-request
execute-request-code
execute-request-silent?
execute-request-store-history?
execute-request-allow-stdin?
execute-request-stop-on-error?
json->execute-request
execute-request->json))
;;; Commentary: ;;; Commentary:
;;; ;;;
...@@ -309,3 +319,18 @@ This is a low-level procedure for internal use." ...@@ -309,3 +319,18 @@ This is a low-level procedure for internal use."
(execution-state kernel-status-execution-state (execution-state kernel-status-execution-state
(json "execution_state" string->symbol symbol->string) (json "execution_state" string->symbol symbol->string)
(default 'idle))) (default 'idle)))
(define-json-mapping <execute-request> execute-request
make-execute-request
execute-request?
json->execute-request <=> execute-request->json
(code execute-request-code)
(silent? execute-request-silent?
(json "silent") (default #f))
(store-history? execute-request-store-history?
(json "store_history") (default #t))
;; TODO: Add "user_expressions" dictionary.
(allow-stdin? execute-request-allow-stdin?
(json "allow_stdin") (default #t))
(stop-on-error? execute-request-stop-on-error?
(json "stop_on_error") (default #f)))
...@@ -100,8 +100,8 @@ ...@@ -100,8 +100,8 @@
42 42
(let ((request (message (header "execute_request" "luser" "12345") (let ((request (message (header "execute_request" "luser" "12345")
(scm->json-string (scm->json-string
'((code . "40 + 2\n") (execute-request->json
(silent . #f)))))) (execute-request (code "40 + 2\n")))))))
(send-message %kernel request) (send-message %kernel request)
;; As noted at ;; As noted at
......
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