@@ -6,22 +6,13 @@ const _TEST_KEY = "a0436f6c-1916-498b-8eb9-e81ab9368e84"
66
77# How to update the precompilation workload:
88# 1. Uncomment the `@show` expressions in `recv_ipython()` in msg.jl.
9- # 2. Copy this workload into tests/kernel.jl and update as desired:
10- #
11- # Kernel(profile; capture_stdout=false, capture_stderr=false) do kernel
12- # jupyter_client(profile) do client
13- # kernel_info(client)
14- # execute(client, "42")
15- # execute(client, "?import")
16- # execute(client, """error("foo")""")
17- # end
18- # end
19- #
20- # 3. When the above runs it will print out the contents of the received messages
21- # as strings. You can copy these verbatim into the precompilation workload
22- # below. Note that if you modify any step of the workload you will need to
23- # update *all* the messages to ensure they have the right parent
24- # headers/signatures.
9+ # 2. Uncomment the call to `run_precompile()` in tests/kernel.jl (and comment
10+ # out the rest of the tests if you like).
11+ # 3. When the `run_precompile()` runs it will print out the contents of the
12+ # received messages as strings. You can copy these verbatim into the
13+ # precompilation workload below. Note that if you modify any step of the
14+ # workload you will need to update *all* the messages to ensure they have the
15+ # right parent headers/signatures.
2516@compile_workload begin
2617 local profile = create_profile (45_000 ; key= _TEST_KEY)
2718
@@ -38,21 +29,32 @@ const _TEST_KEY = "a0436f6c-1916-498b-8eb9-e81ab9368e84"
3829 port = profile[" shell_port" ]
3930 ZMQ. connect (requests_socket, " tcp://$(ip) :$(port) " )
4031
41- # kernel_info
42- idents = [" a1cd3a77-85e3881309b0cc3701e51156 " ]
43- signature = " af03588308cec89e76d0568134c0eaf24e9fe869aac729d5b9aed6baac6d369b "
44- header = " {\" msg_id\" : \" a1cd3a77-85e3881309b0cc3701e51156_1694526_0 \" , \" msg_type\" : \" kernel_info_request\" , \" username\" : \" james\" , \" session\" : \" a1cd3a77-85e3881309b0cc3701e51156 \" , \" date\" : \" 2025-08-29T09:54:47.389494Z \" , \" version\" : \" 5.4\" }"
32+ # Kernel info
33+ idents = [" 626c4427-479d61edd6b98ccca470f2d6 " ]
34+ signature = " 306b616a72292e9a736fe42b3c7d6fd51e10653ea2c5bc8f33810a06d33df8b5 "
35+ header = " {\" msg_id\" : \" 626c4427-479d61edd6b98ccca470f2d6_3346283_0 \" , \" msg_type\" : \" kernel_info_request\" , \" username\" : \" james\" , \" session\" : \" 626c4427-479d61edd6b98ccca470f2d6 \" , \" date\" : \" 2025-11-02T18:59:07.097698Z \" , \" version\" : \" 5.4\" }"
4536 parent_header = " {}"
4637 metadata = " {}"
4738 content = " {}"
4839
4940 ZMQ. send_multipart (requests_socket, [only (idents), " <IDS|MSG>" , signature, header, parent_header, metadata, content])
5041 ZMQ. recv_multipart (requests_socket, String)
5142
43+ # Completion request
44+ idents = [" 626c4427-479d61edd6b98ccca470f2d6" ]
45+ signature = " 721d3988d167417f9f0f03a823d3870470a5d924184a9a07dff422d8993eefa8"
46+ header = " {\" msg_id\" : \" 626c4427-479d61edd6b98ccca470f2d6_3346283_1\" , \" msg_type\" : \" complete_request\" , \" username\" : \" james\" , \" session\" : \" 626c4427-479d61edd6b98ccca470f2d6\" , \" date\" : \" 2025-11-02T18:59:07.587641Z\" , \" version\" : \" 5.4\" }"
47+ parent_header = " {}"
48+ metadata = " {}"
49+ content = " {\" code\" : \" mk\" , \" cursor_pos\" : 2}"
50+
51+ ZMQ. send_multipart (requests_socket, [only (idents), " <IDS|MSG>" , signature, header, parent_header, metadata, content])
52+ ZMQ. recv_multipart (requests_socket, String)
53+
5254 # Execute `42`
53- idents = [" a1cd3a77-85e3881309b0cc3701e51156 " ]
54- signature = " 23df4f581ab69b5b249caced71fc0a77bcb8f5c1f4eeb88d44ca49456db16e0d "
55- header = " {\" msg_id\" : \" a1cd3a77-85e3881309b0cc3701e51156_1694526_1 \" , \" msg_type\" : \" execute_request\" , \" username\" : \" james\" , \" session\" : \" a1cd3a77-85e3881309b0cc3701e51156 \" , \" date\" : \" 2025-08-29T09:54:49.546467Z \" , \" version\" : \" 5.4\" }"
55+ idents = [" 626c4427-479d61edd6b98ccca470f2d6 " ]
56+ signature = " 01e135a939f00a11708ca906c6a16ce1226ad07669b7dad49c12c4b792ef6242 "
57+ header = " {\" msg_id\" : \" 626c4427-479d61edd6b98ccca470f2d6_3346283_2 \" , \" msg_type\" : \" execute_request\" , \" username\" : \" james\" , \" session\" : \" 626c4427-479d61edd6b98ccca470f2d6 \" , \" date\" : \" 2025-11-02T18:59:14.947227Z \" , \" version\" : \" 5.4\" }"
5658 parent_header = " {}"
5759 metadata = " {}"
5860 content = " {\" code\" : \" 42\" , \" silent\" : false, \" store_history\" : true, \" user_expressions\" : {}, \" allow_stdin\" : true, \" stop_on_error\" : true}"
@@ -61,9 +63,9 @@ const _TEST_KEY = "a0436f6c-1916-498b-8eb9-e81ab9368e84"
6163 ZMQ. recv_multipart (requests_socket, String)
6264
6365 # Execute `?import`
64- idents = [" a1cd3a77-85e3881309b0cc3701e51156 " ]
65- signature = " 8f2b31cc4751d17bbd4d1216180e129b0759fdc9f05e0de1e91ca03db85fc5e1 "
66- header = " {\" msg_id\" : \" a1cd3a77-85e3881309b0cc3701e51156_1694526_2 \" , \" msg_type\" : \" execute_request\" , \" username\" : \" james\" , \" session\" : \" a1cd3a77-85e3881309b0cc3701e51156 \" , \" date\" : \" 2025-08-29T09:54:49.951328Z \" , \" version\" : \" 5.4\" }"
66+ idents = [" 626c4427-479d61edd6b98ccca470f2d6 " ]
67+ signature = " a0fc54c9ed7250e8a151a766c7293843a1b8f91b1d766579a4761c18f34862df "
68+ header = " {\" msg_id\" : \" 626c4427-479d61edd6b98ccca470f2d6_3346283_3 \" , \" msg_type\" : \" execute_request\" , \" username\" : \" james\" , \" session\" : \" 626c4427-479d61edd6b98ccca470f2d6 \" , \" date\" : \" 2025-11-02T18:59:15.621963Z \" , \" version\" : \" 5.4\" }"
6769 parent_header = " {}"
6870 metadata = " {}"
6971 content = " {\" code\" : \" ?import\" , \" silent\" : false, \" store_history\" : true, \" user_expressions\" : {}, \" allow_stdin\" : true, \" stop_on_error\" : true}"
@@ -72,25 +74,52 @@ const _TEST_KEY = "a0436f6c-1916-498b-8eb9-e81ab9368e84"
7274 ZMQ. recv_multipart (requests_socket, String)
7375
7476 # Execute `error("foo")`
75- idents = [" a1cd3a77-85e3881309b0cc3701e51156 " ]
76- signature = " c8415a60d32d231b582128a8f85ecce0996ee76734ab6aecf93af850d7e19e4a "
77- header = " {\" msg_id\" : \" a1cd3a77-85e3881309b0cc3701e51156_1694526_3 \" , \" msg_type\" : \" execute_request\" , \" username\" : \" james\" , \" session\" : \" a1cd3a77-85e3881309b0cc3701e51156 \" , \" date\" : \" 2025-08-29T09:54:50.755285Z \" , \" version\" : \" 5.4\" }"
77+ idents = [" 626c4427-479d61edd6b98ccca470f2d6 " ]
78+ signature = " 7c7810bce6ff448c3ad8b0c928822d03ad8baf838e417ea5c29ec620a2cc36a7 "
79+ header = " {\" msg_id\" : \" 626c4427-479d61edd6b98ccca470f2d6_3346283_4 \" , \" msg_type\" : \" execute_request\" , \" username\" : \" james\" , \" session\" : \" 626c4427-479d61edd6b98ccca470f2d6 \" , \" date\" : \" 2025-11-02T18:59:18.648766Z \" , \" version\" : \" 5.4\" }"
7880 parent_header = " {}"
7981 metadata = " {}"
8082 content = " {\" code\" : \" error(\\\" foo\\\" )\" , \" silent\" : false, \" store_history\" : true, \" user_expressions\" : {}, \" allow_stdin\" : true, \" stop_on_error\" : true}"
8183
8284 ZMQ. send_multipart (requests_socket, [only (idents), " <IDS|MSG>" , signature, header, parent_header, metadata, content])
8385 ZMQ. recv_multipart (requests_socket, String)
8486
87+ # Get history
88+ idents = [" 626c4427-479d61edd6b98ccca470f2d6" ]
89+ signature = " 1d4bc84a2efb28efa0e8efe8eba32bc6b84decfd55d95e765b062a1adae2ae62"
90+ header = " {\" msg_id\" : \" 626c4427-479d61edd6b98ccca470f2d6_3346283_5\" , \" msg_type\" : \" history_request\" , \" username\" : \" james\" , \" session\" : \" 626c4427-479d61edd6b98ccca470f2d6\" , \" date\" : \" 2025-11-02T18:59:18.813677Z\" , \" version\" : \" 5.4\" }"
91+ parent_header = " {}"
92+ metadata = " {}"
93+ content = " {\" raw\" : true, \" output\" : false, \" hist_access_type\" : \" range\" , \" session\" : 0, \" start\" : 0}"
94+
95+ ZMQ. send_multipart (requests_socket, [only (idents), " <IDS|MSG>" , signature, header, parent_header, metadata, content])
96+ ZMQ. recv_multipart (requests_socket, String)
97+
98+ # Get comm info
99+ idents = [" 626c4427-479d61edd6b98ccca470f2d6" ]
100+ signature = " ff8e9a57a81f5cbdebd12a34a09aad953d63e24e0c866fc3af936a4ef764a181"
101+ header = " {\" msg_id\" : \" 626c4427-479d61edd6b98ccca470f2d6_3346283_6\" , \" msg_type\" : \" comm_info_request\" , \" username\" : \" james\" , \" session\" : \" 626c4427-479d61edd6b98ccca470f2d6\" , \" date\" : \" 2025-11-02T18:59:18.953835Z\" , \" version\" : \" 5.4\" }"
102+ parent_header = " {}"
103+ metadata = " {}"
104+ content = " {}"
105+
106+ ZMQ. send_multipart (requests_socket, [only (idents), " <IDS|MSG>" , signature, header, parent_header, metadata, content])
107+ ZMQ. recv_multipart (requests_socket, String)
108+
85109 close (requests_socket)
86110 end
87111 end
112+
113+ # Clear global variables
114+ empty! (_preexecute_hooks)
115+ empty! (_postexecute_hooks)
116+ empty! (_posterror_hooks)
88117end
89118
90119# This function is executed by Jupyter so make sure that it's precompiled
91120precompile (run_kernel, ())
92121
93122# Precompile all the handlers
94- for f in handlers
123+ for f in values ( handlers)
95124 precompile (f, (ZMQ. Socket, Kernel, Msg))
96125end
0 commit comments