Description
First of all: great work on this. I'm impressed by how well this all works and I'm happy to see Kotlin compete with Python's dominance in data science.
I have set up Jupyter integration for a (closed source) Kotlin library. It generally works well, but I'm seeing some issues where sometimes the kernel seems to stop responding, or possibly delivering malformed responses. It always goes wrong on the re-evaluation of a cell whose response is HTML. Restarting the kernel and re-evaluating everything yields correct results.
On re-evaluation of such cells, I get console errors such as:
Uncaught SyntaxError: Kernel message validation error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
t http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
l http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
_onWSMessage http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
_createSocket http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
setTimeout handler*_reconnect http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
reconnect http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
restart http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
restartKernel http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
restart http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
execute http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
execute http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
execute http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
execute http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
m http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
s http://localhost:8889/static/lab/jlab_core.33f047ff2ca794a7104f.js?v=33f047ff2ca794a7104f:1
Ue http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
Qe http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
je http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
al http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
ul http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
dl http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
Os http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
De http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
dl http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
lt http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
tt http://localhost:8889/static/lab/3935.905285b8e22c337968ed.js?v=905285b8e22c337968ed:2
jlab_core.33f047ff2ca794a7104f.js:1:1262200
The Jupyter server log shows nothing irregular in my eyes. Looks to me like the proper response is composed:
176533 [main] DEBUG o.j.k.j.protocol.SocketWrapper - [SHELL] >rcv: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"date":"2024-05-02T11:28:11.008Z","msg_id":"6cdbbdb7-146e-4722-b784-e053640e2499","msg_type":"execute_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2"},"parent_header":null,"metadata":{"ExecuteTime":{"end_time":"2024-05-02T08:03:29.181632246Z","start_time":"2024-05-02T08:03:29.011641910Z"},"trusted":true,"editable":true,"slideshow":{"slide_type":""},"tags":[],"deletedCells":[],"recordTiming":false,"cellId":"6b85c575454723c4"},"content":{"silent":false,"store_history":true,"user_expressions":{},"allow_stdin":true,"stop_on_error":true,"code":"import tno.algebra.*\n\nval grid = BoundedGrid(BoundingBox(-31, -30, 30, 30), Grid(5))\n\nval access = (square(6, 6, -3, -3)) or square(3, 3, 2, 2) or square(3, 3, -5, -5)\n\nAccessMap(grid, access)"}}
176534 [main] DEBUG o.j.k.j.protocol.SocketWrapper - [IOPUB] snd>: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"msg_id":"db658db6-8d4f-4405-b1ab-29f28b4a81f3","msg_type":"status","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.3","date":"2024-05-02T13:28:11.010735361+02:00[Europe/Amsterdam]"},"parent_header":{"msg_id":"6cdbbdb7-146e-4722-b784-e053640e2499","msg_type":"execute_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2","date":"2024-05-02T11:28:11.008Z"},"metadata":null,"content":{"execution_state":"busy"}}
176535 [main] DEBUG o.j.k.j.protocol.SocketWrapper - [IOPUB] snd>: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"msg_id":"af64b574-3672-4e90-a5b9-d608916ba95b","msg_type":"execute_input","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.3","date":"2024-05-02T13:28:11.011577066+02:00[Europe/Amsterdam]"},"parent_header":{"msg_id":"6cdbbdb7-146e-4722-b784-e053640e2499","msg_type":"execute_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2","date":"2024-05-02T11:28:11.008Z"},"metadata":null,"content":{"code":"import tno.algebra.*\n\nval grid = BoundedGrid(BoundingBox(-31, -30, 30, 30), Grid(5))\n\nval access = (square(6, 6, -3, -3)) or square(3, 3, 2, 2) or square(3, 3, -5, -5)\n\nAccessMap(grid, access)","execution_count":8}}
176537 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.r.impl.ReplForJupyterImpl - Current cell id: 8
176537 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.repl.impl.CellExecutorImpl - Executing code:
import tno.algebra.*
val grid = BoundedGrid(BoundingBox(-31, -30, 30, 30), Grid(5))
val access = (square(6, 6, -3, -3)) or square(3, 3, 2, 2) or square(3, 3, -5, -5)
AccessMap(grid, access)
176538 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.repl.impl.CellExecutorImpl - Adding 0 libraries
176692 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.libraries.LibrariesScanner - Acceptance result for tno.choreograph.ChoreographJupyterIntegration: null
176692 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.libraries.LibrariesScanner - Acceptance result for org.jetbrains.kotlinx.dataframe.jupyter.Integration: null
176692 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.libraries.LibrariesScanner - Acceptance result for org.jetbrains.kotlinx.kandy.letsplot.jupyter.Integration: null
176692 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.libraries.LibrariesScanner - Acceptance result for org.jetbrains.kotlinx.kandy.Integration: null
176692 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.libraries.LibrariesScanner - Acceptance result for org.jetbrains.kotlinx.statistics.jupyter.Integration: null
176692 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.libraries.LibrariesScanner - Scanning for libraries is done. Detected FQNs: {}
176692 [Execution of code 'import tno.algebra.*...'] DEBUG o.j.k.j.libraries.LibrariesScanner - Number of detected definitions: 0
176699 [main] DEBUG o.j.k.j.protocol.SocketWrapper - [IOPUB] snd>: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"msg_id":"3c788b2f-d08b-464e-b3b1-b31d5becf3f2","msg_type":"execute_result","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.3","date":"2024-05-02T13:28:11.175025146+02:00[Europe/Amsterdam]"},"parent_header":{"msg_id":"6cdbbdb7-146e-4722-b784-e053640e2499","msg_type":"execute_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2","date":"2024-05-02T11:28:11.008Z"},"metadata":null,"content":{"data":{"text/html":"<div id=\"accessmap-1362665863\" style=\"width: 750px; height: 750px;\"></div>\n<script>\n window.choreograph.createAccessMap(\n document.getElementById('accessmap-1362665863'),\n JSON.parse('{\"grid\":{\"bounds\":{\"topLeft\":[-31,-30],\"bottomRight\":[30,30]},\"grid\":{\"cellSize\":5,\"origin\":[0,0]},\"localOrigin\":[-30,-30]},\"access\":[[false,false,false,false,false,false,false,false,false,false,false,false],[false,true,true,true,false,false,false,false,false,false,false,false],[false,true,true,true,false,false,false,false,false,false,false,false],[false,true,true,true,true,true,true,true,true,false,false,false],[false,false,false,true,true,true,true,true,true,false,false,false],[false,false,false,true,true,true,true,true,true,false,false,false],[false,false,false,true,true,true,true,true,true,false,false,false],[false,false,false,true,true,true,true,true,true,false,false,false],[false,false,false,true,true,true,true,true,true,true,true,false],[false,false,false,false,false,false,false,false,true,true,true,false],[false,false,false,false,false,false,false,false,true,true,true,false],[false,false,false,false,false,false,false,false,false,false,false,false]]}')\n )\n</script>"},"metadata":{},"execution_count":8}}
176700 [main] DEBUG o.j.k.j.protocol.SocketWrapper - [SHELL] snd>: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"msg_id":"52d31e2a-181d-4fe9-a43d-aede000ff7ff","msg_type":"execute_reply","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.3","date":"2024-05-02T13:28:11.176090353+02:00[Europe/Amsterdam]"},"parent_header":{"msg_id":"6cdbbdb7-146e-4722-b784-e053640e2499","msg_type":"execute_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2","date":"2024-05-02T11:28:11.008Z"},"metadata":{"engine":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","status":"ok","started":"2024-05-02T13:28:11.010541059+02:00[Europe/Amsterdam]","eval_metadata":{"newClasspath":[],"newSources":[],"compiledData":{"scripts":[],"sources":[]},"newImports":["tno.algebra.*","tno.algebra.*"],"evaluatedVariablesState":{"access":"","grid":"","history":"","initial":"","trails":"","world":"","dataFrameConfig":"","kandyConfig":"","coverage":""}}},"content":{"status":"ok","execution_count":8}}
176701 [main] DEBUG o.j.k.j.protocol.SocketWrapper - [IOPUB] snd>: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"msg_id":"5c5873a8-6707-43c6-9508-2da5916a0c28","msg_type":"status","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.3","date":"2024-05-02T13:28:11.177187359+02:00[Europe/Amsterdam]"},"parent_header":{"msg_id":"6cdbbdb7-146e-4722-b784-e053640e2499","msg_type":"execute_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2","date":"2024-05-02T11:28:11.008Z"},"metadata":null,"content":{"execution_state":"idle"}}
176702 [main] DEBUG o.j.k.j.protocol.SocketWrapper - [SHELL] >rcv: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"date":"2024-05-02T11:28:11.011Z","msg_id":"96b2485e-2dc7-4a98-a141-22eea86b7aff","msg_type":"complete_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2"},"parent_header":null,"metadata":null,"content":{"code":"import tno.algebra.*\n\nval grid = BoundedGrid(BoundingBox(-31, -30, 30, 30), Grid(5))\n\nval access = (square(6, 6, -3, -3)) or square(3, 3, 2, 2) or square(3, 3, -5, -5)\n\nAccessMap(grid, access)","cursor_pos":192}}
176783 [DefaultDispatcher-worker-4] DEBUG o.j.k.j.protocol.SocketWrapper - [IOPUB] snd>: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"msg_id":"a2f62176-d119-40e7-9cb7-574b3ef7a3b2","msg_type":"status","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.3","date":"2024-05-02T13:28:11.259605954+02:00[Europe/Amsterdam]"},"parent_header":{"msg_id":"96b2485e-2dc7-4a98-a141-22eea86b7aff","msg_type":"complete_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2","date":"2024-05-02T11:28:11.011Z"},"metadata":null,"content":{"execution_state":"busy"}}
176785 [DefaultDispatcher-worker-4] DEBUG o.j.k.j.protocol.SocketWrapper - [SHELL] snd>: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"msg_id":"dff115f7-1449-4ffa-bcce-4970a350000b","msg_type":"complete_reply","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.3","date":"2024-05-02T13:28:11.259403652+02:00[Europe/Amsterdam]"},"parent_header":{"msg_id":"96b2485e-2dc7-4a98-a141-22eea86b7aff","msg_type":"complete_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2","date":"2024-05-02T11:28:11.011Z"},"metadata":null,"content":{"status":"ok","matches":[],"cursor_start":192,"cursor_end":192,"paragraph":{"cursor":192,"text":"import tno.algebra.*\n\nval grid = BoundedGrid(BoundingBox(-31, -30, 30, 30), Grid(5))\n\nval access = (square(6, 6, -3, -3)) or square(3, 3, 2, 2) or square(3, 3, -5, -5)\n\nAccessMap(grid, access)"},"metadata":{"_jupyter_types_experimental":[],"_jupyter_extended_metadata":[]}}}
176786 [DefaultDispatcher-worker-4] DEBUG o.j.k.j.protocol.SocketWrapper - [IOPUB] snd>: msg[ZTViYmY1M2QtYTI3My00ZWM1LWIwZmItZWM3YTY2YTA5MTFm] {"header":{"msg_id":"2dc59f2a-e82c-4e6a-bae2-744b79dce366","msg_type":"status","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.3","date":"2024-05-02T13:28:11.261740566+02:00[Europe/Amsterdam]"},"parent_header":{"msg_id":"96b2485e-2dc7-4a98-a141-22eea86b7aff","msg_type":"complete_request","session":"e5bbf53d-a273-4ec5-b0fb-ec7a66a0911f","username":"","version":"5.2","date":"2024-05-02T11:28:11.011Z"},"metadata":null,"content":{"execution_state":"idle"}}
Perhaps I'm also barking up the wrong tree here: I have no strong indication that this is coming from the Kotlin kernel, but I'm suspicious because first evaluation goes correct and because the error seems to surface on some re-evaluations, but not every.
The errors happen both in Jupyterlab frontend and the classic notebooks.
I'd be happy to supply more information if you can tell me how to obtain it.