Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter messaging updates/correctness #1138

Merged
merged 7 commits into from
Jan 29, 2025
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.3"
julia = "1.6"
julia = "1.10"
4 changes: 2 additions & 2 deletions src/IJulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
using ZMQ, JSON, SoftGlobalScope
import Base.invokelatest
import Dates
using Dates: now
using Dates: now, format, UTC, ISODateTimeFormat
import Random
using Base64: Base64EncodePipe
import REPL
Expand Down Expand Up @@ -285,7 +285,7 @@
# 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",

Check warning on line 288 in src/IJulia.jl

View check run for this annotation

Codecov / codecov/patch

src/IJulia.jl#L288

Added line #L288 was not covered by tests
Dict("wait" => wait)))
stdio_bytes[] = 0 # reset output throttling
end
Expand Down
2 changes: 1 addition & 1 deletion src/comm_manager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
end
content = Dict(:comms => _comms)

send_ipython(IJulia.publish[],
send_ipython(sock,

Check warning on line 62 in src/comm_manager.jl

View check run for this annotation

Codecov / codecov/patch

src/comm_manager.jl#L62

Added line #L62 was not covered by tests
msg_reply(msg, "comm_info_reply", content))
end

Expand Down
1 change: 1 addition & 0 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
# return a String=>Any dictionary to attach as metadata
# in Jupyter display_data and pyout messages
metadata(x) = Dict()
transient(x) = Dict()

Check warning on line 51 in src/display.jl

View check run for this annotation

Codecov / codecov/patch

src/display.jl#L51

Added line #L51 was not covered by tests

"""
Generate the preferred MIME representation of x.
Expand Down
8 changes: 4 additions & 4 deletions src/handlers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@
end

function kernel_info_request(socket, msg)
send_ipython(requests[],
send_ipython(socket,

Check warning on line 157 in src/handlers.jl

View check run for this annotation

Codecov / codecov/patch

src/handlers.jl#L157

Added line #L157 was not covered by tests
msg_reply(msg, "kernel_info_reply",
Dict("protocol_version" => "5.0",
Dict("protocol_version" => "5.4",
"implementation" => "ijulia",
# TODO: "implementation_version" => IJulia version string from Pkg
"implementation_version" => pkgversion(@__MODULE__),

Check warning on line 161 in src/handlers.jl

View check run for this annotation

Codecov / codecov/patch

src/handlers.jl#L161

Added line #L161 was not covered by tests
"language_info" =>
Dict("name" => "julia",
"version" =>
Expand Down Expand Up @@ -274,7 +274,7 @@

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()))

Check warning on line 277 in src/handlers.jl

View check run for this annotation

Codecov / codecov/patch

src/handlers.jl#L277

Added line #L277 was not covered by tests
end

function unknown_request(socket, msg)
Expand Down
3 changes: 3 additions & 0 deletions src/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/msg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ 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.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").
Expand All @@ -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 ")
Expand Down
Loading