Livebook prevent cell from reevaluation

Is there a way, to not reevaluate a cell, if I add a new mix dependency? I have one cell, that takes long to compute, and I need a new dependency for further filtering after this cell. So, I want to avoid reevaluating this one cell. Moreover, the cells before that don’t need this new lib.

I don’t think so. It looks like every time you run the setup, Livebook starts a new runtime (Elixir node) to evaluate your notebook’s code.

So, given it’s a new runtime, I don’t think it would have knowledge of previous evaluations.

Too bad, that makes it hard to add more functionality over time. My workaround now is to save the intermediate result in a file and then open a new notebook.

If you want to keep the result in between livebook restarts, then your only option is to store the intermediate result on the filesystem (a file, persistent term, etc.).

You can put that resource intensive code in a branching section if you want to keep everything together (no need for a new notebook). Then you can explicitly re-run that code, but skip it when following your normal flow (where you load the intermediate results from the FS).

1 Like