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

Add stale cells (aka single-shot cells) #3068

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SimonLafran
Copy link

@SimonLafran SimonLafran commented Oct 21, 2024

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)

Picture of frontend rendering

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

Adds to PlutoRunner a new struct `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.

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.

Add a small test for stale cells
@fonsp
Copy link
Owner

fonsp commented Oct 25, 2024

Hey @SimonLafran! Let's have a call? Send me an email on [email protected]

@fonsp
Copy link
Owner

fonsp commented Oct 31, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants