JuliaGizmos / Interact.jl

Interactive widgets to play with your Julia code
Other
520 stars 75 forks source link

Loss of observable function with package update #323

Open rand5 opened 5 years ago

rand5 commented 5 years ago

I just updated my packages and am now having an issue with observable updates. Currently using Interact v0.10.2

For example, the following code fails to update the variable D as the slider is manipulated.

C = Interact.slider(1:10)
D = map(C) do x
    y = x^2
    return y
end

I also checked two of the examples in the docs and they are broken as well (everything renders fine, but no interactivity when the sliders and buttons are manipulated). The examples I checked were:

function mycolorpicker()
    r = Interact.slider(0:255, label = "red")
    g = Interact.slider(0:255, label = "green")
    b = Interact.slider(0:255, label = "blue")
    update = Interact.button("Update plot")
    output = Interact.@map (&update; Colors.RGB(r[]/255, g[]/255, b[]/255))
    plt = Interact.@map plot(sin, color = &output)
    wdg = Widget(["r" => r, "g" => g, "b" => b, "update" => update], output = output)
    @layout! wdg hbox(plt, vbox(:r, :g, :b, :update)) ## custom layout: by default things are stacked vertically
end

and

width, height = 700, 300
colors = ["black", "gray", "silver", "maroon", "red", "olive", "yellow", "green", "lime", "teal", "aqua", "navy", "blue", "purple", "fuchsia"]
color(i) = colors[i%length(colors)+1]
ui = @manipulate for nsamples in 1:200,
        sample_step in Interact.slider(0.01:0.01:1.0, value=0.1, label="sample step"),
        phase in Interact.slider(0:0.1:2pi, value=0.0, label="phase"),
        radii in 0.1:0.1:60
    cxs_unscaled = [i*sample_step + phase for i in 1:nsamples]
    cys = sin.(cxs_unscaled) .* height/3 .+ height/2
    cxs = cxs_unscaled .* width/4pi
    dom"svg:svg[width=$width, height=$height]"(
        (dom"svg:circle[cx=$(cxs[i]), cy=$(cys[i]), r=$radii, fill=$(color(i))]"()
            for i in 1:nsamples)...
    )
end

I then went to test some of the examples in the tutorial workbooks, but were unable to load them for some reason.

Running:

Julia Version 1.0.1
Commit 0d713926f8 (2018-09-29 19:05 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

  [fbb218c0] BSON v0.2.3
  [6e4b80f9] BenchmarkTools v0.4.2
  [ad839575] Blink v0.10.1+ #master (https://github.com/JunoLab/Blink.jl.git)
  [336ed68f] CSV v0.5.7
  [a2cac450] ColorBrewer v0.4.0
  [5ae59095] Colors v0.9.5
  [861a8166] Combinatorics v0.7.0
  [150eb455] CoordinateTransformations v0.5.0
  [a93c6f00] DataFrames v0.18.4
  [39dd38d3] Dierckx v0.4.1
  [b4f34e82] Distances v0.8.0
  [31c24e10] Distributions v0.19.2
  [587475ba] Flux v0.8.3
  [da1fdf0e] FreqTables v0.3.1
  [38e38edf] GLM v1.3.0
  [c27321d9] Glob v1.2.0
  [a2bd30eb] Graphics v0.4.0
  [4c0ca9eb] Gtk v0.16.5
  [27996c0f] GtkReactive v0.6.0
  [54070661] GtkUtilities v0.3.0
  [cd3eb016] HTTP v0.7.1 ⚲
  [09f84164] HypothesisTests v0.8.0
  [7073ff75] IJulia v1.18.1
  [4381153b] ImageDraw v0.1.0
  [92ff4b2b] ImageFeatures v0.3.0
  [6a3955dd] ImageFiltering v0.6.3
  [6218d12a] ImageMagick v0.7.5
  [787d08f9] ImageMorphology v0.1.1
  [80713f31] ImageSegmentation v1.2.0
  [7632190a] ImageTracking v0.0.1 #master (https://github.com/JuliaImages/ImageTracking.jl)
  [86fae568] ImageView v0.9.0
  [916415d5] Images v0.17.3
  [c601a237] Interact v0.10.2
  [a98d9a8b] Interpolations v0.12.2
  [8197267c] IntervalSets v0.3.1
  [5ab0869b] KernelDensity v0.5.1
  [b964fa9f] LaTeXStrings v1.0.3
  [2fda8390] LsqFit v0.8.1
  [76087f3c] NLopt v0.5.1
  [47be7bcc] ORCA v0.2.1
  [429524aa] Optim v0.18.1
  [f0f68f2c] PlotlyJS v0.12.5
  [91a5bcdd] Plots v0.25.3 #master (https://github.com/JuliaPlots/Plots.jl.git)
  [d330b81b] PyPlot v2.8.1
  [a8468747] QHull v0.1.0
  [1fd47b50] QuadGK v2.1.0 #master (https://github.com/JuliaMath/QuadGK.jl.git)
  [a223df75] Reactive v0.8.3
  [6038ab10] Rotations v0.11.1
  [90137ffa] StaticArrays v0.11.0
  [2913bbd2] StatsBase v0.30.0
  [4c63d2b9] StatsFuns v0.8.0
  [48a634ad] Tensors v1.1.0
  [5e47fb64] TestImages v0.5.1
  [0f1e0344] WebIO v0.8.6 ⚲
  [8ba89e20] Distributed 
  [10745b16] Statistics
rand5 commented 5 years ago

In retrospect, I think this is related to https://github.com/JuliaGizmos/Interact.jl/issues/315, but it is not clear to me what the final solution was. Should we be using the master WebIO? Referencing https://github.com/JuliaGizmos/WebIO.jl/pull/308

jleman commented 5 years ago

@rand5: I observed similar behavior in Jupyter after updating Julia to 1.1.1 and updating all packages (Windows 10 machine). I'm also using Interact v0.10.2. I found the following process seems to fix the issue temporarily, but I have to repeat it every time I open a notebook containing and Interact script.

  1. First, with the notebook open, go to "Kernel"->"Change Kernel" and select an older Julia Kernel (in my case 1.0.3). Wait for connection to the kernel to establish.
  2. Second, using the same menu items, change back to the newest kernel (1.1.1 in my case)

For me this causes the Interact functionality to work, though it is tedious. Hopefully this provides a clue as to what's wrong.

I also get this message when I compile a script that calls Interact.jl:

┌ Warning: Accessing scope.id is deprecated, use scopeid(scope) instead. │ caller = ip:0x0 └ @ Core :-1

Here is the code block I am running:

using Interact
@manipulate for t=1:NDT
plot(collect(1:NDZ),Vout[t,:])
end

The script links a slider to plot rows of matrix Vout.

briochemc commented 5 years ago

@jleman's trick worked for me too

htzh commented 4 years ago

Having the same issue. @jleman suggestion of disconnecting and reconnecting the kernel works. Before restarting the kernel, with the following code

wdg = slider(1:100)
vbox(wdg, observe(wdg))

slider updates but the observer box does not. After restarting the kernel, both updates work. I am on Windows 10 with Chrome browser and

  [79e6a3ab] Adapt v1.0.0
  [c5f51814] CUDAdrv v3.1.0
  [be33ccc6] CUDAnative v2.3.1
  [3a865a2d] CuArrays v1.2.1
  [587475ba] Flux v0.9.0
  [f6369f11] ForwardDiff v0.10.3
  [0c68f7d7] GPUArrays v1.0.3
  [92fee26a] GZip v0.5.0
  [7073ff75] IJulia v1.20.0
  [916415d5] Images v0.18.0
  [c601a237] Interact v0.10.3
  [18b7da76] JuliaAcademyData v0.1.0 #master (https://github.com/JuliaComputing/JuliaAcademyData.jl)
  [872c559c] NNlib v0.6.0
  [91a5bcdd] Plots v0.27.0
  [438e738f] PyCall v1.91.2
  [d330b81b] PyPlot v2.8.2
  [0f1e0344] WebIO v0.8.11
M-R-Schaefer commented 4 years ago

I'm having the same issue. The initial render is successful, I can drag sliders etc but nothing is updated.

Version 1.2.0 (2019-08-20)

  "Interact"              => v"0.10.3"
  "Conda"                 => v"1.3.0"
  "Roots"                 => v"0.8.3"
  "PyCall"                => v"1.91.2"
  "IterativeSolvers"      => v"0.8.1"
  "DataStructures"        => v"0.17.5"
  "IJulia"                => v"1.20.2"
  "Plots"                 => v"0.27.0"
  "PyPlot"                => v"2.8.2"
  "Colors"                => v"0.9.6"
  "Gadfly"                => v"1.0.1"
  "WebIO"                 => v"0.8.11"
  "QuadGK"                => v"2.1.1"
  "ProfileView"           => v"0.5.0"
  "DifferentialEquations" => v"6.8.0"
  "FFTW"                  => v"1.1.0"