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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
julia = "1.6"
julia = "1.10"
2 changes: 1 addition & 1 deletion src/IJulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ 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

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 @@ 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.
Expand Down
10 changes: 5 additions & 5 deletions src/handlers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ 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",
# TODO: "implementation_version" => IJulia version string from Pkg
"implementation_version" => pkgversion(@__MODULE__),
"language_info" =>
Dict("name" => "julia",
"version" =>
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
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
4 changes: 2 additions & 2 deletions src/msg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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").
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