Subject: guix-jupyter fails a test

From: Ricardo Wurmus <[email-masked]>
Date: Wed, 14 Sep 2022 22:34:06 +0200

Unfortunately, guix-jupyter still fails to build for me as of commit
29d52a56f2d254781b65dbec0f1009db0b9d06e6.

--8<---------------cut here---------------start------------->8---
==========================================
   Guix-Jupyter 0.2.2: ./test-suite.log
==========================================

# TOTAL: 36
# PASS:  33
# SKIP:  0
# XFAIL: 0
# FAIL:  3
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: tests/kernels
===================

/gnu/store/msd98spsahl2vxc2g2z2wgyai10dyr14-python-ipython-8.2.0/lib/python3.9/site-packages/IPython/paths.py:70: UserWarning: IPython parent '/homeless-shelter' is not a writable location, using a temp directory.
  warn("IPython parent '{0}' is not a writable location,"
NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see https://github.com/ipython/ipython/issues/2049

To connect another client to this kernel, use:
    --existing /tmp/guix-build-guix-jupyter-0.2.2.drv-0/guix-jupyter-kernel.U55aZ4/conn/2031766281046451459.json
test-name: run-kernel python3
location: /tmp/guix-build-guix-jupyter-0.2.2.drv-0/source/tests/kernels.scm:44
source:
+ (test-assert
+   "run-kernel python3"
+   (let ((kernel
+           (run-kernel %context %python3-specs %kernel-key)))
+     (set! %kernel kernel)
+     (and (kernel? (pk 'kernel kernel))
+          (begin
+            (kill (kernel-pid kernel) 0)
+            (let ((greetings (read-message %kernel 5000)))
+              (or (not greetings)
+                  (list (message-type greetings)
+                        (kernel-status-execution-state
+                          (json->kernel-status
+                            (message-content greetings))))))))))

;;; (kernel #<<kernel> name: "Python 3 (ipykernel)" pid: 884 key: "secretkey" control: #<zmq-socket type: 5 7ffff3ec1cc0> shell: #<zmq-socket type: 5 7ffff3ec1cb0> stdin: #<zmq-socket type: 5 7ffff3ec1ca0> heartbeat: #<zmq-socket type: 3 7ffff3ec1c80> iosub: #<zmq-socket type: 2 7ffff3ec1c60> properties: ()>)
actual-value: #f
actual-error:
+ (wrong-type-arg
+   "string->symbol"
+   "Wrong type argument in position ~A (expecting ~A): ~S"
+   (1 "string" #f)
+   (#f))
result: FAIL

test-name: kernel_info_request
location: /tmp/guix-build-guix-jupyter-0.2.2.drv-0/source/tests/kernels.scm:61
source:
+ (test-equal
+   "kernel_info_request"
+   "python"
+   (let ((request
+           (message
+             (header "kernel_info_request" "luser" "12345")
+             "{}")))
+     (send-message %kernel request)
+     (let* ((replies
+              (unfold
+                (cut > <> 2)
+                (lambda (_) (read-message %kernel 10000))
+                #{1+}#
+                0)))
+       (define (type-predicate type)
+         (lambda (message)
+           (string=? (message-type message) type)))
+       (and (every message? (pk 'replies replies))
+            (match (filter (type-predicate "status") replies)
+                   ((busy idle)
+                    (and (eq? 'busy
+                              (kernel-status-execution-state
+                                (json->kernel-status (message-content busy))))
+                         (eq? 'idle
+                              (kernel-status-execution-state
+                                (json->kernel-status (message-content idle))))
+                         (equal?
+                           (message-parent-header busy)
+                           (message-header request))
+                         (equal?
+                           (message-parent-header idle)
+                           (message-header request)))))
+            (let ((reply (find (type-predicate "kernel_info_reply")
+                               replies)))
+              (and (equal?
+                     (message-parent-header reply)
+                     (message-header request))
+                   (let ((reply (json->kernel-info-reply
+                                  (message-content reply))))
+                     (language-info-name
+                       (kernel-info-reply-language-info reply)))))))))

;;; (replies (#<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_1" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.486528Z" type: "status" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 115 116 97 116 117 115)> parent-header: #f metadata: "{}" content: "{\"execution_state\": \"starting\"}" buffers: ()> #<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_2" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.505955Z" type: "status" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 115 116 97 116 117 115)> parent-header: #<<header> id: "7b136e32ddcbe2e226edffb116a4fca9" user: "luser" session: "12345" date: "2022-09-14T16:03:05.503986000" type: "kernel_info_request" version: "5.0" sender: #f> metadata: "{}" content: "{\"execution_state\": \"busy\"}" buffers: ()> #<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_4" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.507374Z" type: "status" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 115 116 97 116 117 115)> parent-header: #<<header> id: "7b136e32ddcbe2e226edffb116a4fca9" user: "luser" session: "12345" date: "2022-09-14T16:03:05.503986000" type: "kernel_info_request" version: "5.0" sender: #f> metadata: "{}" content: "{\"execution_state\": \"idle\"}" buffers: ()>))
expected-value: "python"
actual-value: #f
actual-error:
+ (match-error
+   "match"
+   "no matching pattern"
+   (#<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_1" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.486528Z" type: "status" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 115 116 97 116 117 115)> parent-header: #f metadata: "{}" content: "{\"execution_state\": \"starting\"}" buffers: ()>
+    #<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_2" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.505955Z" type: "status" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 115 116 97 116 117 115)> parent-header: #<<header> id: "7b136e32ddcbe2e226edffb116a4fca9" user: "luser" session: "12345" date: "2022-09-14T16:03:05.503986000" type: "kernel_info_request" version: "5.0" sender: #f> metadata: "{}" content: "{\"execution_state\": \"busy\"}" buffers: ()>
+    #<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_4" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.507374Z" type: "status" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 115 116 97 116 117 115)> parent-header: #<<header> id: "7b136e32ddcbe2e226edffb116a4fca9" user: "luser" session: "12345" date: "2022-09-14T16:03:05.503986000" type: "kernel_info_request" version: "5.0" sender: #f> metadata: "{}" content: "{\"execution_state\": \"idle\"}" buffers: ()>))
result: FAIL

test-name: execute_request
location: /tmp/guix-build-guix-jupyter-0.2.2.drv-0/source/tests/kernels.scm:100
source:
+ (test-equal
+   "execute_request"
+   42
+   (let ((request
+           (message
+             (header "execute_request" "luser" "12345")
+             (scm->json-string
+               (execute-request->json
+                 (execute-request (code "40 + 2\n")))))))
+     (send-message %kernel request)
+     (let* ((replies
+              (unfold
+                (cut > <> 4)
+                (lambda (_) (read-message %kernel 10000))
+                #{1+}#
+                0)))
+       (define (type-predicate type)
+         (lambda (message)
+           (string=? (message-type message) type)))
+       (and (every message? (pk 'replies replies))
+            (match (filter (type-predicate "status") replies)
+                   ((busy idle)
+                    (and (eq? 'busy
+                              (kernel-status-execution-state
+                                (json->kernel-status (message-content busy))))
+                         (eq? 'idle
+                              (kernel-status-execution-state
+                                (json->kernel-status (message-content idle))))
+                         (equal?
+                           (message-parent-header busy)
+                           (message-header request))
+                         (equal?
+                           (message-parent-header idle)
+                           (message-header request)))))
+            (let ((input (find (type-predicate "execute_input") replies)))
+              (equal?
+                (message-parent-header input)
+                (message-header request)))
+            (let ((reply (find (type-predicate "execute_reply") replies)))
+              (equal?
+                (message-parent-header reply)
+                (message-header request)))
+            (let ((result
+                    (find (type-predicate "execute_result") replies)))
+              (and (equal?
+                     (message-parent-header result)
+                     (message-header request))
+                   (let* ((content
+                            (json-string->scm (message-content result)))
+                          (data (assoc-ref content "data"))
+                          (text (assoc-ref data "text/plain")))
+                     (string->number text))))))))

;;; (replies (#<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_3" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.506350Z" type: "kernel_info_reply" version: "5.3" sender: #f> parent-header: #<<header> id: "7b136e32ddcbe2e226edffb116a4fca9" user: "luser" session: "12345" date: "2022-09-14T16:03:05.503986000" type: "kernel_info_request" version: "5.0" sender: #f> metadata: "{}" content: "{\"status\": \"ok\", \"protocol_version\": \"5.3\", \"implementation\": \"ipython\", \"implementation_version\": \"8.2.0\", \"language_info\": {\"name\": \"python\", \"version\": \"3.9.9\", \"mimetype\": \"text/x-python\", \"codemirror_mode\": {\"name\": \"ipython\", \"version\": 3}, \"pygments_lexer\": \"ipython3\", \"nbconvert_exporter\": \"python\", \"file_extension\": \".py\"}, \"banner\": \"Python 3.9.9 (main, Jan  1 1970, 00:00:01) \\nType 'copyright', 'credits' or 'license' for more information\\nIPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help.\\n\", \"help_links\": [{\"text\": \"Python Reference\", \"url\": \"https://docs.python.org/3.9\"}, {\"text\": \"IPython Reference\", \"url\": \"https://ipython.org/documentation.html\"}, {\"text\": \"NumPy Reference\", \"url\": \"https://docs.scipy.org/doc/numpy/reference/\"}, {\"text\": \"SciPy Reference\", \"url\": \"https://docs.scipy.org/doc/scipy/reference/\"}, {\"text\": \"Matplotlib Reference\", \"url\": \"https://matplotlib.org/contents.html\"}, {\"text\": \"SymPy Reference\", \"url\": \"http://docs.sympy.org/latest/index.html\"}, {\"text\": \"pandas Reference\", \"url\": \"https://pandas.pydata.org/pandas-docs/stable/\"}]}" buffers: ()> #<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_5" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.524608Z" type: "status" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 115 116 97 116 117 115)> parent-header: #<<header> id: "b101b0c27f41055fc03178fdce86a4f6" user: "luser" session: "12345" date: "2022-09-14T16:03:05.523517000" type: "execute_request" version: "5.0" sender: #f> metadata: "{}" content: "{\"execution_state\": \"busy\"}" buffers: ()> #<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_6" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.524906Z" type: "execute_input" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 101 120 101 99 117 116 101 95 105 110 112 117 116)> parent-header: #<<header> id: "b101b0c27f41055fc03178fdce86a4f6" user: "luser" session: "12345" date: "2022-09-14T16:03:05.523517000" type: "execute_request" version: "5.0" sender: #f> metadata: "{}" content: "{\"code\": \"40 + 2\\n\", \"execution_count\": 1}" buffers: ()> #<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_7" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.531062Z" type: "execute_result" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 101 120 101 99 117 116 101 95 114 101 115 117 108 116)> parent-header: #<<header> id: "b101b0c27f41055fc03178fdce86a4f6" user: "luser" session: "12345" date: "2022-09-14T16:03:05.523517000" type: "execute_request" version: "5.0" sender: #f> metadata: "{}" content: "{\"data\": {\"text/plain\": \"42\"}, \"metadata\": {}, \"execution_count\": 1}" buffers: ()> #<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_8" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.540033Z" type: "execute_reply" version: "5.3" sender: #f> parent-header: #<<header> id: "b101b0c27f41055fc03178fdce86a4f6" user: "luser" session: "12345" date: "2022-09-14T16:03:05.523517000" type: "execute_request" version: "5.0" sender: #f> metadata: "{\"started\": \"2022-09-14T16:03:05.524836Z\", \"dependencies_met\": true, \"engine\": \"a57c1f56-41bd-4cbb-bea9-939faca877f4\", \"status\": \"ok\"}" content: "{\"status\": \"ok\", \"execution_count\": 1, \"user_expressions\": {}, \"payload\": []}" buffers: ()>))
expected-value: 42
actual-value: #f
actual-error:
+ (match-error
+   "match"
+   "no matching pattern"
+   (#<<message> header: #<<header> id: "377e5f0c-c85d2027900218a7a09c8021_884_5" user: "username" session: "377e5f0c-c85d2027900218a7a09c8021" date: "2022-09-14T16:03:05.524608Z" type: "status" version: "5.3" sender: #vu8(107 101 114 110 101 108 46 97 53 55 99 49 102 53 54 45 52 49 98 100 45 52 99 98 98 45 98 101 97 57 45 57 51 57 102 97 99 97 56 55 55 102 52 46 115 116 97 116 117 115)> parent-header: #<<header> id: "b101b0c27f41055fc03178fdce86a4f6" user: "luser" session: "12345" date: "2022-09-14T16:03:05.523517000" type: "execute_request" version: "5.0" sender: #f> metadata: "{}" content: "{\"execution_state\": \"busy\"}" buffers: ()>))
result: FAIL
--8<---------------cut here---------------end--------------->8---

-- 
Ricardo