Integrating a long(ish) running simulation into Pluto

I very often write big simulations in Pluto.

The basic tip is that generally your long simulation should be called from a function and not a script (or a begin block or consecutive cells). Now you can have this long function defined in Pluto, but I usually do it differently.

What I commonly do is start Pluto in a local directory with local package manager using
Pkg.activate. I define a module in this directory and I put my non-Pluto bulky code (e.g. your simulation) in there. Because of Revise, I can also update it easily.

Then when I start Pluto the first cells do using Revise and Pkg.activate(".").
I import my local module using MyModule and I access the functions from there.

Can I detach it somehow from Pluto’s normal reactive behaviour?

No. If you change any variables that are used as arguments to call the simulation function in your notebook, then the simulation will rerun. But that’s desirable. If you structure your notebook nicely I don’t see why would that be a problem.

Regarding the progress bar, you can definitely use some inside you simulation function.
See ProgressMeter in Pluto
Pluto will then visualize it.

btw your link doesn’t work.

5 Likes