Skip to content

Commit 4a5d51b

Browse files
authored
Merge pull request #1138 from halleysfifthinc/messaging-updates
Jupyter messaging updates/correctness
2 parents 2164bfc + 57df15d commit 4a5d51b

File tree

7 files changed

+15
-11
lines changed

7 files changed

+15
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ JSON = "0.18,0.19,0.20,0.21,1"
2727
MbedTLS = "0.5,0.6,0.7,1"
2828
SoftGlobalScope = "1"
2929
ZMQ = "1.3"
30-
julia = "1.6"
30+
julia = "1.10"

src/IJulia.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export notebook, jupyterlab, installkernel
3636
using ZMQ, JSON, SoftGlobalScope
3737
import Base.invokelatest
3838
import Dates
39-
using Dates: now
39+
using Dates: now, format, UTC, ISODateTimeFormat
4040
import Random
4141
using Base64: Base64EncodePipe
4242
import REPL
@@ -285,7 +285,7 @@ function clear_output(wait=false)
285285
# flush pending stdio
286286
flush_all()
287287
empty!(displayqueue) # discard pending display requests
288-
send_ipython(publish[], msg_reply(execute_msg::Msg, "clear_output",
288+
send_ipython(publish[], msg_pub(execute_msg::Msg, "clear_output",
289289
Dict("wait" => wait)))
290290
stdio_bytes[] = 0 # reset output throttling
291291
end

src/comm_manager.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function comm_info_request(sock, msg)
5959
end
6060
content = Dict(:comms => _comms)
6161

62-
send_ipython(IJulia.publish[],
62+
send_ipython(sock,
6363
msg_reply(msg, "comm_info_reply", content))
6464
end
6565

src/display.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ register_jsonmime(x::AbstractVector{<:MIME}) = push!(ijulia_jsonmime_types, Vect
4848
# return a String=>Any dictionary to attach as metadata
4949
# in Jupyter display_data and pyout messages
5050
metadata(x) = Dict()
51+
transient(x) = Dict()
5152

5253
"""
5354
Generate the preferred MIME representation of x.

src/handlers.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ function complete_request(socket, msg)
154154
end
155155

156156
function kernel_info_request(socket, msg)
157-
send_ipython(requests[],
157+
send_ipython(socket,
158158
msg_reply(msg, "kernel_info_reply",
159-
Dict("protocol_version" => "5.0",
159+
Dict("protocol_version" => "5.4",
160160
"implementation" => "ijulia",
161-
# TODO: "implementation_version" => IJulia version string from Pkg
161+
"implementation_version" => pkgversion(@__MODULE__),
162162
"language_info" =>
163163
Dict("name" => "julia",
164164
"version" =>
@@ -274,7 +274,7 @@ end
274274

275275
function interrupt_request(socket, msg)
276276
@async Base.throwto(requests_task[], InterruptException())
277-
send_ipython(requests[], msg_reply(msg, "interrupt_reply", Dict()))
277+
send_ipython(socket, msg_reply(msg, "interrupt_reply", Dict()))
278278
end
279279

280280
function unknown_request(socket, msg)

src/inline.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ for mime in ipy_mime
6262
msg_pub(execute_msg, "display_data",
6363
Dict(
6464
"metadata" => metadata(x), # optional
65+
"transient" => transient(x), # optional
6566
"data" => Dict($mime => limitstringmime(MIME($mime), x)))))
6667
end
6768
displayable(d::InlineDisplay, ::MIME{Symbol($mime)}) = true
@@ -87,6 +88,7 @@ function display(d::InlineDisplay, M::MIME, x)
8788
send_ipython(publish[],
8889
msg_pub(execute_msg, "display_data",
8990
Dict("metadata" => metadata(x), # optional
91+
"transient" => transient(x), # optional
9092
"data" => d)))
9193
end
9294

@@ -98,6 +100,7 @@ function display(d::InlineDisplay, x)
98100
send_ipython(publish[],
99101
msg_pub(execute_msg, "display_data",
100102
Dict("metadata" => metadata(x), # optional
103+
"transient" => transient(x), # optional
101104
"data" => display_dict(x))))
102105
end
103106

src/msg.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ end
1818
msg_header(m::Msg, msg_type::String) = Dict("msg_id" => uuid4(),
1919
"username" => m.header["username"],
2020
"session" => m.header["session"],
21-
"date" => now(),
21+
"date" => format(now(UTC), ISODateTimeFormat)*"Z",
2222
"msg_type" => msg_type,
23-
"version" => "5.3")
23+
"version" => "5.4")
2424

2525
# PUB/broadcast messages use the msg_type as the ident, except for
2626
# stream messages which use the stream name (e.g. "stdout").
@@ -32,7 +32,7 @@ msg_pub(m::Msg, msg_type, content, metadata=Dict{String,Any}()) =
3232
msg_header(m, msg_type), content, m.header, metadata)
3333

3434
msg_reply(m::Msg, msg_type, content, metadata=Dict{String,Any}()) =
35-
Msg(m.idents, msg_header(m, msg_type), content, m.header, metadata)
35+
Msg(m.idents, msg_header(m, msg_type), merge(Dict("status" => "ok"), content), m.header, metadata)
3636

3737
function show(io::IO, msg::Msg)
3838
print(io, "IPython Msg [ idents ")

0 commit comments

Comments
 (0)