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

wait and resume execution on button press #803

Closed
gszep opened this issue Dec 23, 2020 · 5 comments
Closed

wait and resume execution on button press #803

gszep opened this issue Dec 23, 2020 · 5 comments

Comments

@gszep
Copy link

gszep commented Dec 23, 2020

suppose there are two sections in my notebook:

  • First Section: Pre-processing and lightweight computation, lots of interactivity
  • Second Section: Application of algorithm, only need to visualise results, heavyweight computation

Ideally I would have a "Run Algorithm" button in the second section, where Pluto does not execute any code below the button - which contains heavyweight computations - and waits until I press it to execute it. Would this be possible? It would be nice to be able to separate out execution spaces.. Sometimes I just want to execute the first section without executing the second one at all, for example if I've changed my mind about the dataset I've loaded.

@fonsp
Copy link
Owner

fonsp commented Jan 5, 2021

Can you split you issue in two: 1. Clearly state the problem, 2. Your suggestion. I have found that it is difficult to discuss direct suggestions, but discussing the underlying problem leads to creative solutions.

@gszep
Copy link
Author

gszep commented Jan 6, 2021

Sure :) Suppose I have a notebook that looks like the following

### A Pluto.jl notebook ###
# v0.12.18

using Markdown
using InteractiveUtils

# ╔═╡ c49493f2-4366-11eb-2969-b3fff0c37e7b
begin # load packages and other requirements
	using ...
end

# ╔═╡ ba294c1c-43ab-11eb-0695-1147232dc62a
begin
       
       # allow user to interactively change prepocessing params
        @bind preprocessingParams ... # or more complicated binding of observables using JSServe.jl
	data,labels = load(path)
	
	# apply preprocessing params to data; typically fast and plot should be reactive
	transform!(data, preprocessingParams...)
	plot(data) # show summary statistics of preprocessed data; updates on changes to observables
end

# ╔═╡ 9dbf3d0c-4432-11eb-1170-4f59655b7820
begin  # computationally expensive cell; updates every time preprocessing params are changed - not desirable!
	outputs = train(data,labels)
end

# ╔═╡ b80a14f4-4435-11eb-07bd-7fcc8ca10325
begin  # interactively explore outputs
	 @bind plotParams ... 
	 plot(outputs,plotParams...)
end

# ╔═╡ Cell order:
# ╠═c49493f2-4366-11eb-2969-b3fff0c37e7b
# ╟─ba294c1c-43ab-11eb-0695-1147232dc62a
# ╟─9dbf3d0c-4432-11eb-1170-4f59655b7820
# ╟─b80a14f4-4435-11eb-07bd-7fcc8ca10325

The issue in this example is that the computationally expensive cell 9dbf3d0c-4432-11eb-1170-4f59655b7820 re-evaluates every time the user updates any of the observables in preprocessingParams. The user would usually tinker with those parameters, then once happy would execute cell 9dbf3d0c-4432-11eb-1170-4f59655b7820, grab a cup of tea, then come back and then explore the results in an interactive plot in cell b80a14f4-4435-11eb-07bd-7fcc8ca10325

Proposed Solution:
Create a "pagebreak" style functionality. For example inserting a pagebreak like so

# ╔═╡ Cell order:
# ╠═c49493f2-4366-11eb-2969-b3fff0c37e7b
# ╟─ba294c1c-43ab-11eb-0695-1147232dc62a
# pagebreak
# ╟─9dbf3d0c-4432-11eb-1170-4f59655b7820
# ╟─b80a14f4-4435-11eb-07bd-7fcc8ca10325

Would treat the first two cells and the last two cells essentially as separate notebooks, with separate execution spaces. However when cell 9dbf3d0c-4432-11eb-1170-4f59655b7820 is executed, the current state of the preceding notebook is imported, including all values of observables.

Not sure how this could be done in practice. One could use an include statement but this would merely import the state with default values for all observables. Using include also re-evaluates the whole previous notebook which is not needed as the results are already available.. maybe this can be done by two different workers that pass messages between each other? Hope this helps explain the feature request.

@gszep
Copy link
Author

gszep commented Jan 6, 2021

I think this would also allow users to create larger notebooks - the size of a book for example - where each chapter or section in the book is treated as a separate execution space that (optionally) inherits the state from the previous section. This way when the user loads the notebook they don't have to wait until all cells in the book are executed before being able to interact with the first section of the book

@fonsp
Copy link
Owner

fonsp commented Jan 6, 2021

Can you take a close look at #298 ? It is a proposed solution to the same problem, so try to narrow down on how your suggestion is different and better.

It sounds very similar to #298 (comment)
my response to this suggestion is #298 (comment) , you can comment on that message if you want to discuss that message further

@gszep
Copy link
Author

gszep commented Jan 6, 2021

will continue discussion on relevant thread :)

@gszep gszep closed this as completed Jan 6, 2021
pankgeorg pushed a commit that referenced this issue Jan 28, 2021
[Diff since v0.12.18](v0.12.18...v0.12.19)

**Closed issues:**
- GPU usage and console messages (#685)
- Feature Proposal: Exported HTML can be passed to a static site generator (#794)
- wait and resume execution on button press (#803)
- Latex code not appropriately displayed (#817)
- Python doesn't work in Pluto (#818)
- add pluto - pluto not found - Julia 1.5.3 macOS (#819)
- Cell output not shown correctly if in-line comment ends with semicolon (#820)
- _llvm (#821)
- Can't move cells (#822)
- Conditions on list comprehensions and execution order (#824)
- Electron app (#825)
- Errors when pressing Ctrl+C to stop Pluto (#827)
- Failed to load notebook error (#829)
- Popup docs don't work for some symbols (#832)
- Running a notebook deleted contents of `.julia/registries` (#834)
- Ctrl+C broken with `julia -e "Pluto.run()"` instead of the REPL (#836)
- Edit or remove default header and footer in exported static PDF (#837)
- Parameters.jl dynamically created macros confuse Pluto (#838)
- Feature request: Open URL from terminal (#840)
- Notebook gets stuck in forever loading state after restarting my PC while running it (#849)
- Syntax highlighting of @. (#854)
- File not found when file newly created while session is running (#855)
- Weird output from a mix of MathJax, Markdown and PlutoUI (#856)
- Misaligned plots when plotting with UnicodePlots.jl using BrailleCanvas (#870)

**Merged pull requests:**
- Pluto ux process file drop (#707) (@pankgeorg)
- Dralbase state managment (#710) (@dralletje)
- PLJ-785 CodeMirror Eject to TextArea - Reload from TextArea in Offline HTML export (#805) (@pankgeorg)
-  Dralbase state managment: Fix front-end tests (#809) (@pankgeorg)
- Update README.md (#814) (@fonsp)
- Regard `:=` in macros as einsum notation (take 2) (#816) (@mcabbott)
- 🧸 Open your own files as samples (#828) (@fonsp)
- Handle filters in generators, closes #824 (#839) (@Pangoraw)
- Update `== nothing` to `=== nothing` in Parse.jl (#841) (@heetbeet)
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

No branches or pull requests

2 participants