Add stale cells (aka single-shot cells)
As discussed in #2970 and previous discussions, having a way to temporarily block the execution of long-running cells would be beneficial.
This implementation goes for a very flexible solution: Main.PlutoRunner.Stale. When returned from a cell, this struct passes down its formatting to its single member out. However, the cell also gets marked as stale. This means that none of the cells that depend on it will be run. The stale cell, however, will still be run when its dependencies run, to see if its no longer stale.
On the frontend stale outputs are displayed on a light or dark orange background while stale cells and cells that depend on them get orange traffic lights.
When a cell is in one of those two states a warning sign with an explanatory popup is displayed below the "fold code" button.
(see picture below)
Small details
- We might want to change the frontend formatting a bit. Maybe dim the cells like when they are disabled.
- Implementation-wise, I decided not to touch the topology when running the cells, because of the dynamic nature of the stale state. I basically only check if a cell depends on stale ones before running it. We could pro-actively exclude all dependents of a cell that returns Stale.
Future
We could add utility macros to PlutoHooks/PlutoLinks, something like single-shot. This would show how to use the marker.
Try this Pull Request!
Open Julia and type:
julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/SimonLafran/Pluto.jl", rev="stale-cells")
julia> using Pluto
Hey @SimonLafran! Let's have a call? Send me an email on [email protected]
Notes from our call:
Integrated approach
The single shot feature can be integrated into the existing disabled-cells feature!
Disabled cells will get a button to "run once" (and stay disabled).
For this, we would also improve the existing disabled feature:
- Display: the current 50% opacity display is an accessibility issue. We need an alternative with full visibility like implemented in this PR. It could be an icy frozen 🥶 look
- Dirty: when a disabled cell becomes dirty (one of its dependencies re-runs), this should be visible. So you know that it needs a re-run.
Implementation
The "run" command from the frontend can contain a list of single-shot ids. The disabled status of those cells will be ignored during the run. If simon sees opportunities to improve our implementation of disabled cells in the meantime then great!!
Conflict
It's possible that a cell depends on two disabled cells, and you single-shot one of them. We need to decide what to do here.
I am really interested in this feature. :)