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

get(slider::RangeSlider) unnecessarily (?) returns an array instead of a range #130

Closed
ForceBru opened this issue Aug 28, 2021 · 1 comment · Fixed by #148
Closed

get(slider::RangeSlider) unnecessarily (?) returns an array instead of a range #130

ForceBru opened this issue Aug 28, 2021 · 1 comment · Fixed by #148
Labels
needs Pluto.jl feature Can't be done right now because something is missing from Pluto.jl itself

Comments

@ForceBru
Copy link

I've just attempted to put the result of a RangeSlider into the title of my plot, but it immediately crashed Pluto:

@bind time_frame RangeSlider(1:length(moving_res.range), right=100, show_value=true)

scatter(
	view(moving_res.M, :, time_frame)', view(moving_res.Σ, :, time_frame)',
	marker_z=moving_res.range[time_frame],
	markerstrokewidth=0, markersize=2, markeralpha=.6,
	title="Clusters over time ($time_frame)",
	label="", xlabel="Means", ylabel="Standard deviations",
	c=:deep,
	fmt=:png
)

I expected the title to become something like "Clusters over time (1:100)". However, Pluto crashed with this error:

┌ Error: Update notebook failed
│   🙋.body["updates"] =
│    1-element Vector{Dict{Any, Any}}:
│     Dict("value" => Dict{Any, Any}("value" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10  …  91, 92, 93, 94, 95, 96, 97, 98, 99, 100], "is_first_value" => true), "op" => "add", "path" => ["bonds", "time_frame"])
│   exception =
│    Distributed.ProcessExitedException(12)
│    Stacktrace:
│      [1] worker_from_id(pg::Distributed.ProcessGroup, i::Int64)
│        @ Distributed /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/cluster.jl:1084
│      [2] worker_from_id
│        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/cluster.jl:1081 [inlined]
│      [3] #remotecall_fetch#146
│        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:421 [inlined]
│      [4] remotecall_fetch
│        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:421 [inlined]
│      [5] remotecall_eval
│        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/macros.jl:246 [inlined]
│      [6] eval_fetch_in_workspace(session_notebook::Tuple{Pluto.ServerSession, Pluto.Notebook}, expr::Expr)
│        @ Pluto.WorkspaceManager ~/.julia/packages/Pluto/HmZoH/src/evaluation/WorkspaceManager.jl:294
│      [7] (::Pluto.var"#190#193"{Pluto.ServerSession, Pluto.Notebook})(bound_sym::Symbol)
│        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/evaluation/RunBonds.jl:25
│      [8] filter(f::Pluto.var"#190#193"{Pluto.ServerSession, Pluto.Notebook}, a::Vector{Symbol})
│        @ Base ./array.jl:2448
│      [9] set_bond_values_reactive(; session::Pluto.ServerSession, notebook::Pluto.Notebook, bound_sym_names::Vector{Symbol}, is_first_value::Nothing, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:run_async,), Tuple{Bool}}})
│        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/evaluation/RunBonds.jl:6
│     [10] response_update_notebook(🙋::Pluto.ClientRequest)
│        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/Dynamic.jl:315
│     [11] process_ws_message(session::Pluto.ServerSession, parentbody::Dict{Any, Any}, clientstream::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
│        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/WebServer.jl:340
│     [12] (::Pluto.var"#302#312"{Pluto.ServerSession, Base.RefValue{Function}})(clientstream::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
│        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/WebServer.jl:153
│     [13] upgrade(f::Pluto.var"#302#312"{Pluto.ServerSession, Base.RefValue{Function}}, http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}; binary::Bool)
│        @ HTTP.WebSockets ~/.julia/packages/HTTP/D0FSE/src/WebSockets.jl:160
│     [14] upgrade
│        @ ~/.julia/packages/HTTP/D0FSE/src/WebSockets.jl:142 [inlined]
│     [15] (::Pluto.var"#301#311"{Pluto.ServerSession, Base.RefValue{Function}, HTTP.Handlers.Router{Symbol("##281")}})(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
│        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/WebServer.jl:135
│     [16] handle
│        @ ~/.julia/packages/HTTP/D0FSE/src/Handlers.jl:270 [inlined]
│     [17] #4
│        @ ~/.julia/packages/HTTP/D0FSE/src/Handlers.jl:346 [inlined]
│     [18] macro expansion
│        @ ~/.julia/packages/HTTP/D0FSE/src/Servers.jl:413 [inlined]
│     [19] (::HTTP.Servers.var"#13#14"{HTTP.Handlers.var"#4#5"{HTTP.Handlers.StreamHandlerFunction{Pluto.var"#301#311"{Pluto.ServerSession, Base.RefValue{Function}, HTTP.Handlers.Router{Symbol("##281")}}}}, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, HTTP.Servers.Server{Nothing, Sockets.TCPServer}, HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})()
│        @ HTTP.Servers ./task.jl:411
└ @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/Dynamic.jl:325

I looked at the code of the RangeSlider and was very surprised by get(slider::RangeSlider) returning an array, while, given that the UI element is called RangeSlider, I expected to get a range:

/~https://github.com/fonsp/PlutoUI.jl/blob/a107c6aa010dff1ab9574874143007786fa86451/src/RangeSlider.jl#L64

Indeed, "$the_range" is a big string in my case, so I guess there were problems displaying it...


Wouldn't it make sense to return a range instead of an array, like get(slider::RangeSlider) = slider.left:step(slider.range):slider.right?

@fonsp fonsp added the needs Pluto.jl feature Can't be done right now because something is missing from Pluto.jl itself label Oct 31, 2021
@fonsp
Copy link
Member

fonsp commented Oct 31, 2021

It returns a vector because JavaScript has no range type, but this can be worked around soon.

@fonsp fonsp linked a pull request Nov 1, 2021 that will close this issue
@fonsp fonsp closed this as completed in #148 Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs Pluto.jl feature Can't be done right now because something is missing from Pluto.jl itself
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants