A very basic question, so I apologize if it’s been dealt with elsewhere - I did look.
Suppose I have some function f(x1, x2, x3, x4, …) that is compute intensive and takes a long time to return. How can I enter specific values of x1, x2, … (some are strings, some are dates, some are numbers) without triggering a full calculation of f every time I type a number in the NumberField box for x1 or use a Select dropdown to choose a date for x2, etc.?
It would not be a problem if each change to a variable halted everything and began a new calculation of f (or all dependent cells, more generally). But that doesn’t seem to be the case: If the Pluto notebook is opened with f(x1 = 0, x2 = 0, …) and I first set x1 =1 and then set x2 = 1 it seems to be the case that Pluto first evaluates f(1,0,…) fully before evaluating f(1,1,…).
This feature, if there isn’t an easy workaround that I (an admittedly unsophisticated user) don’t know about, makes Pluto impractical for many important real-world uses of Julia…
Any further guidance on how to use the combine method? I can’t find the required @htl anywhere and am unclear on what to do. As per the example, I’d love to use a single confirm call to wrap a bunch of NumberFields and Sliders because if I bind and confirm each widget separately then I trigger a separate valuation with each push of the confirm button.
That macro comes from the HypertextLiteral package, you’ll need to import that into your notebook. You might not need @htl though if you’re not wanting to do anything fancy, the markdown macro md"" might be enough for your needs:
@bind output confirm(
PlutoUI.combine() do bind
md"""
1) $(bind(Slider(1:10)))
2) $(bind(Slider(1:10)))
3) $(bind(Slider(1:10)))
4) $(bind(Slider(1:10)))
"""
end
)
So now I have it working well in a small test notebook. But in the larger notebook for which I want to control calculation I get this error (the rest of the cell shown is long but properly constructed). Any thoughts?
Sorry for the windup. Apparently one of the other packages also had a combine method. Everything works as it should when I’m explicit and use PlutoUI.combine and PlutoUI.confirm.
Apparently, I was overly optimistic… The code that uses Pluto.confirm and Pluto.combine works in some notebooks but not in others. There is a problem above and beyond the conflict that arose from not specifying the PlutoUI package for the confirm and combine methods:
Here’s the relevant snippet from the larger notebook that shows the error as well as how I import PlutoUI. You are right that I could have been doing that wrong and should have included it in the original screenshot. I will try to construct a small notebook that illustrates the problem. But I doubt that I will be able to, as I have another notebook for which the identical snippet shown works fine (it differs only in the Children being combined inside the do statement). Additionally, there are no errors or useful logging info displayed in the terminal from which the Pluto notebook was launched (screenshot also attached).