From 90c1909af4b3653faf9b158aacc6b99ad1f85802 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Wed, 18 Dec 2024 13:47:21 -0800 Subject: [PATCH 1/6] Add `implementation_version` to `"kernel_info_reply"` --- Project.toml | 2 +- src/handlers.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 88aca27b..b73f3706 100644 --- a/Project.toml +++ b/Project.toml @@ -27,4 +27,4 @@ JSON = "0.18,0.19,0.20,0.21,1" MbedTLS = "0.5,0.6,0.7,1" SoftGlobalScope = "1" ZMQ = "1" -julia = "1.6" +julia = "1.10" diff --git a/src/handlers.jl b/src/handlers.jl index 4e84f709..3e752a6e 100644 --- a/src/handlers.jl +++ b/src/handlers.jl @@ -158,7 +158,7 @@ function kernel_info_request(socket, msg) msg_reply(msg, "kernel_info_reply", Dict("protocol_version" => "5.0", "implementation" => "ijulia", - # TODO: "implementation_version" => IJulia version string from Pkg + "implementation_version" => pkgversion(@__MODULE__), "language_info" => Dict("name" => "julia", "version" => From f670c6c9422cf40da98e59af316e048bf942fda8 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Wed, 18 Dec 2024 13:48:49 -0800 Subject: [PATCH 2/6] All `"*_reply"` messages should have a `"status"` field --- src/msg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msg.jl b/src/msg.jl index 74012b81..9608d0bc 100644 --- a/src/msg.jl +++ b/src/msg.jl @@ -32,7 +32,7 @@ msg_pub(m::Msg, msg_type, content, metadata=Dict{String,Any}()) = msg_header(m, msg_type), content, m.header, metadata) msg_reply(m::Msg, msg_type, content, metadata=Dict{String,Any}()) = - Msg(m.idents, msg_header(m, msg_type), content, m.header, metadata) + Msg(m.idents, msg_header(m, msg_type), merge(Dict("status" => "ok"), content), m.header, metadata) function show(io::IO, msg::Msg) print(io, "IPython Msg [ idents ") From 180f40f50b33507e8aa3d4493ea5bc59c9953290 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Wed, 18 Dec 2024 13:49:22 -0800 Subject: [PATCH 3/6] `"clear_output"` is not a reply, but an IOPub message --- src/IJulia.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IJulia.jl b/src/IJulia.jl index 4d5a4469..f6e116ab 100644 --- a/src/IJulia.jl +++ b/src/IJulia.jl @@ -285,7 +285,7 @@ function clear_output(wait=false) # flush pending stdio flush_all() empty!(displayqueue) # discard pending display requests - send_ipython(publish[], msg_reply(execute_msg::Msg, "clear_output", + send_ipython(publish[], msg_pub(execute_msg::Msg, "clear_output", Dict("wait" => wait))) stdio_bytes[] = 0 # reset output throttling end From e3791f92232211c2c5c5e0071cd5012096245052 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Wed, 18 Dec 2024 13:51:28 -0800 Subject: [PATCH 4/6] Send replies on the appropriate socket (Jupyter messaging protocol v5.4) --- src/comm_manager.jl | 2 +- src/handlers.jl | 8 ++++---- src/msg.jl | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/comm_manager.jl b/src/comm_manager.jl index 17319b71..0d37f862 100644 --- a/src/comm_manager.jl +++ b/src/comm_manager.jl @@ -59,7 +59,7 @@ function comm_info_request(sock, msg) end content = Dict(:comms => _comms) - send_ipython(IJulia.publish[], + send_ipython(sock, msg_reply(msg, "comm_info_reply", content)) end diff --git a/src/handlers.jl b/src/handlers.jl index 3e752a6e..ec51afb2 100644 --- a/src/handlers.jl +++ b/src/handlers.jl @@ -154,9 +154,9 @@ function complete_request(socket, msg) end function kernel_info_request(socket, msg) - send_ipython(requests[], + send_ipython(socket, msg_reply(msg, "kernel_info_reply", - Dict("protocol_version" => "5.0", + Dict("protocol_version" => "5.4", "implementation" => "ijulia", "implementation_version" => pkgversion(@__MODULE__), "language_info" => @@ -189,7 +189,7 @@ function connect_request(socket, msg) end function shutdown_request(socket, msg) - send_ipython(requests[], msg_reply(msg, "shutdown_reply", + send_ipython(socket, msg_reply(msg, "shutdown_reply", msg.content)) sleep(0.1) # short delay (like in ipykernel), to hopefully ensure shutdown_reply is sent exit() @@ -271,7 +271,7 @@ end function interrupt_request(socket, msg) @async Base.throwto(requests_task[], InterruptException()) - send_ipython(requests[], msg_reply(msg, "interrupt_reply", Dict())) + send_ipython(socket, msg_reply(msg, "interrupt_reply", Dict())) end function unknown_request(socket, msg) diff --git a/src/msg.jl b/src/msg.jl index 9608d0bc..be36a87d 100644 --- a/src/msg.jl +++ b/src/msg.jl @@ -20,7 +20,7 @@ msg_header(m::Msg, msg_type::String) = Dict("msg_id" => uuid4(), "session" => m.header["session"], "date" => now(), "msg_type" => msg_type, - "version" => "5.3") + "version" => "5.4") # PUB/broadcast messages use the msg_type as the ident, except for # stream messages which use the stream name (e.g. "stdout"). From bcf85533b6dc8a9999169ac4b08fbe897e5aebc4 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Wed, 18 Dec 2024 13:53:04 -0800 Subject: [PATCH 5/6] Add `"transient"` dict to `"display_data"` messages (Necessary for any future `"update_display_data"` message implementation) --- src/display.jl | 1 + src/inline.jl | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/display.jl b/src/display.jl index 2659b576..2fdbd4bf 100644 --- a/src/display.jl +++ b/src/display.jl @@ -48,6 +48,7 @@ register_jsonmime(x::AbstractVector{<:MIME}) = push!(ijulia_jsonmime_types, Vect # return a String=>Any dictionary to attach as metadata # in Jupyter display_data and pyout messages metadata(x) = Dict() +transient(x) = Dict() """ Generate the preferred MIME representation of x. diff --git a/src/inline.jl b/src/inline.jl index 2ef69587..339d05ad 100644 --- a/src/inline.jl +++ b/src/inline.jl @@ -62,6 +62,7 @@ for mime in ipy_mime msg_pub(execute_msg, "display_data", Dict( "metadata" => metadata(x), # optional + "transient" => transient(x), # optional "data" => Dict($mime => limitstringmime(MIME($mime), x))))) end displayable(d::InlineDisplay, ::MIME{Symbol($mime)}) = true @@ -87,6 +88,7 @@ function display(d::InlineDisplay, M::MIME, x) send_ipython(publish[], msg_pub(execute_msg, "display_data", Dict("metadata" => metadata(x), # optional + "transient" => transient(x), # optional "data" => d))) end @@ -98,6 +100,7 @@ function display(d::InlineDisplay, x) send_ipython(publish[], msg_pub(execute_msg, "display_data", Dict("metadata" => metadata(x), # optional + "transient" => transient(x), # optional "data" => display_dict(x)))) end From 8b56a0c5793a6f33f5ebc178971234a6f098f00c Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Mon, 13 Jan 2025 15:16:48 -0800 Subject: [PATCH 6/6] Get date and format for UTC (matches jupyter server) --- src/IJulia.jl | 2 +- src/msg.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/IJulia.jl b/src/IJulia.jl index f6e116ab..d3e13e18 100644 --- a/src/IJulia.jl +++ b/src/IJulia.jl @@ -36,7 +36,7 @@ export notebook, jupyterlab, installkernel using ZMQ, JSON, SoftGlobalScope import Base.invokelatest import Dates -using Dates: now +using Dates: now, format, @dateformat_str, UTC, ISODateTimeFormat import Random using Base64: Base64EncodePipe import REPL diff --git a/src/msg.jl b/src/msg.jl index be36a87d..c34a107a 100644 --- a/src/msg.jl +++ b/src/msg.jl @@ -18,7 +18,7 @@ end msg_header(m::Msg, msg_type::String) = Dict("msg_id" => uuid4(), "username" => m.header["username"], "session" => m.header["session"], - "date" => now(), + "date" => format(now(UTC), ISODateTimeFormat)*"Z", "msg_type" => msg_type, "version" => "5.4")