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

Disable Cell button #985

Merged
merged 151 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from 150 commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
0ba0ce7
added helper functions for cell dependencies
lungben Feb 3, 2021
3e436b1
bug fixed and tests added
lungben Feb 3, 2021
d218c04
added dependency info to Cell
lungben Feb 4, 2021
3b1e830
test cases added
lungben Feb 5, 2021
92619b2
Make front-end aware of cell order 2️⃣1️⃣
Feb 7, 2021
ce98738
handled case where cell ID is not found
lungben Feb 8, 2021
844b3b9
handle missing case
lungben Feb 8, 2021
0422fe7
debugging stuff
lungben Feb 8, 2021
6357691
removed debug statements, but kept brackets
lungben Feb 8, 2021
f6de90b
next try for the missing issue
lungben Feb 8, 2021
a670f3c
next try
lungben Feb 8, 2021
6e3ae67
Restore .gitignore
fonsp Feb 9, 2021
26b99d6
enhanced docstrings
lungben Feb 9, 2021
0a7601b
replacing cell nr with UUIDs (backend part)
lungben Feb 9, 2021
77ec60b
cell dependency type hints adjusted
lungben Feb 9, 2021
6678954
execution order corrected
lungben Feb 9, 2021
e47826e
avoiding duplicate calculations of cell order
lungben Feb 9, 2021
21492c8
removed outdated function def
lungben Feb 9, 2021
7454ca0
dict mapping symbols to cell uuids now passed to frontend
lungben Feb 10, 2021
419973f
added test for function def in cell
lungben Feb 10, 2021
7d99187
js @type adopted
lungben Feb 10, 2021
643807c
precedence_heuristic added
lungben Feb 11, 2021
66cea3d
removed one redundant cell ordering
lungben Feb 11, 2021
ae2ebc9
added cell execution order on notebook level
lungben Feb 11, 2021
65cfdf4
passing cell execution order for whole notebook to frontend
lungben Feb 11, 2021
a0afc3f
use workaround only for old Julia versions
lungben Feb 11, 2021
918a0a7
removed set_dependencies! from reshow_cell
lungben Feb 12, 2021
83cba50
script for performance testing added
lungben Feb 12, 2021
dfa55b5
setting dependencies next to `updated_topology`
lungben Feb 12, 2021
f772b39
caching execution order
lungben Feb 12, 2021
1ab0a70
removed big notebook test script
lungben Feb 12, 2021
0f21a13
converting missings for frontend
lungben Feb 12, 2021
e6e0cf7
tests for notebook.execution_order added
lungben Feb 19, 2021
eb38f87
removed redundant cell level execution order
lungben Feb 19, 2021
c08f64f
Merge branch 'master' into cell_dep_visualizer
Feb 21, 2021
bd94025
Bump version
Feb 21, 2021
0c80054
Merge branch 'cell_dep_visualizer' of github.com:lungben/Pluto.jl int…
Feb 21, 2021
4fa7c3e
test case adopted to new preceedence heuristic
lungben Feb 22, 2021
9ae3966
WIP: disable referenced_cells & dependent_cells
Feb 23, 2021
a0dd425
Send simple dicts over to the FE
Feb 23, 2021
91d62ec
Recert cell deps missing when not calculated
Feb 24, 2021
dd7164a
Revert Cell.jl to missing
Feb 25, 2021
9775a00
Merge branch 'master' into cell_dep_visualizer
Feb 26, 2021
009a2d1
Merge branch 'master' into cell_dep_visualizer
Mar 5, 2021
a4991e5
Remove expoeriment code
Mar 5, 2021
e5b5c8d
fixed tests
lungben Mar 9, 2021
5975d25
fields for execution barrier added
lungben Mar 9, 2021
6eef599
saving/loading of barriers
lungben Mar 9, 2021
d665241
added cell property is_deactivated
lungben Mar 9, 2021
7fde147
deactivate execution after barrier
lungben Mar 9, 2021
c84a328
un-queue deactivated cells
lungben Mar 9, 2021
4a078e2
activate all cells before checking which to deactivate
lungben Mar 9, 2021
50fdf91
Merge branch 'master' into pr/891
fonsp Mar 9, 2021
ee765d1
Restore package-lock.json
fonsp Mar 9, 2021
5961a8a
Restore jest.config.js
fonsp Mar 9, 2021
da678be
Renamed functions & compacted a little
fonsp Mar 9, 2021
5d76ed6
whitespace
fonsp Mar 9, 2021
258daa3
Merge branch 'master' into execution_barrier
lungben Mar 9, 2021
ff30502
Restore Firebasey.jl
fonsp Mar 9, 2021
50859e0
Restore jest-puppeteer.config.js
fonsp Mar 9, 2021
7b1f444
Merge branch 'master' into pr/891
fonsp Mar 9, 2021
c61103e
Merge branch 'execution_barrier' into cell_dep_visualizer
lungben Mar 9, 2021
90586a2
Merge pull request #1 from lungben/cell_dep_visualizer
lungben Mar 9, 2021
7e5c3e9
adjustments to upstream changes
lungben Mar 9, 2021
f3264d5
Revert "Merge branch 'execution_barrier' into cell_dep_visualizer"
fonsp Mar 10, 2021
229c287
Merge branch 'master' into pr/891
fonsp Mar 10, 2021
f9f1b35
fixed cell deactivation
lungben Mar 12, 2021
f3f3149
started frontend implementation
lungben Mar 12, 2021
eed2ea2
got basic functionality working :-)
lungben Mar 13, 2021
e2de34c
showing deactivated cells in gui
lungben Mar 13, 2021
5e19776
automatic re-run of cell if barrier is deactivated
lungben Mar 13, 2021
a989b46
extracted cell deactivation to function
lungben Mar 18, 2021
054ab3a
add cell deactivation to Dynamic response
lungben Mar 18, 2021
b70323c
deleted outdated files
lungben Mar 18, 2021
47be85f
Merge remote-tracking branch 'origin' into cell_dep_visualizer
lungben Mar 21, 2021
7fc158c
Merge remote-tracking branch 'origin/main' into cell_dep_visualizer
lungben Mar 21, 2021
1d7e101
Merge remote-tracking branch 'origin/main' into cell_dep_visualizer
lungben Mar 21, 2021
d376cba
Merge remote-tracking branch 'origin/main' into cell_dep_visualizer
lungben Mar 23, 2021
a0fed32
switched off new functionality
lungben Mar 23, 2021
27476d1
updated dependency visualization
lungben Mar 23, 2021
4a20826
type changed to concrete
lungben Mar 23, 2021
dc51120
moved topological_order to corresponding file
lungben Mar 23, 2021
0230fd0
Merge branch 'main' into pr/891
fonsp Mar 25, 2021
f443e38
move cell dependency info to third Dict in state object
fonsp Mar 25, 2021
99f7fe6
pragmatic tests
fonsp Mar 25, 2021
8e17d5c
fix JS types
fonsp Mar 25, 2021
ebe4562
typo
fonsp Mar 25, 2021
366d2ff
fixed cell deactivation
lungben Mar 26, 2021
facf9ca
adjustments to upstream changes
lungben Mar 9, 2021
3595b17
fixed cell deactivation
lungben Mar 12, 2021
7171c57
started frontend implementation
lungben Mar 12, 2021
212a3e4
got basic functionality working :-)
lungben Mar 13, 2021
8d4776e
showing deactivated cells in gui
lungben Mar 13, 2021
2b9e58e
automatic re-run of cell if barrier is deactivated
lungben Mar 13, 2021
d8cd1c9
extracted cell deactivation to function
lungben Mar 18, 2021
e7609fc
add cell deactivation to Dynamic response
lungben Mar 18, 2021
8804bcf
Merge branch 'execution_barrier' of https://github.com/lungben/Pluto.…
lungben Mar 26, 2021
0c74937
Merge remote-tracking branch 'origin/main' into execution_barrier
lungben Apr 2, 2021
742be37
saving/loading of barriers
lungben Mar 9, 2021
4135d04
dependencies moved
lungben Apr 6, 2021
42d9b25
got it working again
lungben Apr 6, 2021
081217a
Opacity used for deactivated cells
lungben Apr 6, 2021
d3da7ad
pause icon for cells with barrier
lungben Apr 6, 2021
6e110d1
trying barrier activation with right-click on run - not working
lungben Apr 6, 2021
a1f09f0
add onRightClick using onContextmenu
Apr 6, 2021
1296f1d
removed old barrier UI
lungben Apr 7, 2021
000a953
debug logging removed
lungben Apr 7, 2021
9129881
Merge remote-tracking branch 'origin/main' into execution_barrier
lungben Apr 7, 2021
5687c1d
hello
fonsp Apr 7, 2021
b198d09
grey out deactivated cells at once
lungben Apr 7, 2021
a04df47
only allow running of cells without barrier
lungben Apr 7, 2021
52c49a7
asdf
fonsp Apr 8, 2021
4504440
visualization examples as comments in Cell.js
lungben Apr 9, 2021
65171cd
Merge branch 'demo-of-using-reactivity-info' into execution_barrier
lungben Apr 9, 2021
fb13fbf
list items corrected
lungben Apr 9, 2021
cb4c6b3
Merge remote-tracking branch 'origin/main' into execution_barrier
lungben Apr 29, 2021
0be37a0
traffic light is not visible anymore for deactivated cells
lungben Apr 30, 2021
d427fad
replaced loop by filter
lungben Apr 30, 2021
366a070
activating a cell dependent on a still deactivated one does not error…
lungben Apr 30, 2021
4ac3ef4
Merge remote-tracking branch 'origin/main' into execution_barrier
lungben May 3, 2021
322de21
Merge remote-tracking branch 'origin/main' into execution_barrier
May 4, 2021
d6e2792
Update Execution barrier UI
May 4, 2021
78a5944
Focus nearest barriered cell when trying to run a disabled cell
May 5, 2021
ff71dc4
Update context menu styles
May 6, 2021
a7add4f
Merge branch 'main' into execution_barrier
May 6, 2021
c6adaed
Remove barrier persistence
May 7, 2021
4a6235c
Small Cleanup
May 7, 2021
d20dadf
Restore Notebook.jl
fonsp May 7, 2021
3c95b73
renamed variables for disabled cells
lungben May 7, 2021
d924468
added some tests for cell disabling backend
lungben May 7, 2021
46f01b1
renamed disabling flags
lungben May 7, 2021
5481789
Merge remote-tracking branch 'origin/main' into execution_barrier
lungben May 18, 2021
812fd48
interrupt running cells if barrier is activated
lungben May 18, 2021
177f4e8
modified message for disabled cells
lungben May 18, 2021
4d38f94
disabled automatic interrupt when deactivating cell
lungben May 19, 2021
c749e03
Merge remote-tracking branch 'origin/main' into execution_barrier
lungben May 25, 2021
4e17959
Merge branch 'main' into pr/985
fonsp May 25, 2021
cd6f0f0
format js
fonsp May 25, 2021
26b8bd6
Fix touch input screens
fonsp May 25, 2021
bb3d586
Fix set_waiting_to_run and Shift+Enter
fonsp May 25, 2021
d336edf
Fix outdated tooltips
fonsp May 25, 2021
83f28b6
css tweaks
fonsp May 25, 2021
b6a22fd
better runarea actions
fonsp May 25, 2021
84ff7e2
css tweaks
fonsp May 25, 2021
beb6ac5
rename is_disabled to depends_on_disabled_cells
fonsp May 25, 2021
974a37f
rename is_running_disabled to running_disabled
fonsp May 25, 2021
875c8f0
Add tests
fonsp May 25, 2021
47934ce
Simplify julia code
fonsp May 25, 2021
c360ffb
restore unrelated change
fonsp May 25, 2021
71eb8e1
Merge branch 'main' into pr/985
fonsp May 25, 2021
a8a8dd7
fixie fix
fonsp May 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions frontend/components/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import { PlutoContext } from "../common/PlutoContext.js"
* }} props
* */
export const Cell = ({
cell_result: { queued, running, runtime, errored, output, published_objects },
cell_input: { cell_id, code, code_folded },
cell_input: { cell_id, code, code_folded, running_disabled },
cell_result: { queued, running, runtime, errored, output, published_objects, depends_on_disabled_cells },
cell_dependencies: { downstream_cells_map, upstream_cells_map, precedence_heuristic },
cell_input_local,
notebook_id,
on_update_doc_query,
Expand Down Expand Up @@ -64,7 +65,7 @@ export const Cell = ({
const [waiting_to_run, set_waiting_to_run] = useState(false)
useEffect(() => {
set_waiting_to_run(false)
}, [queued, running, output?.last_run_timestamp])
}, [queued, running, output?.last_run_timestamp, depends_on_disabled_cells, running_disabled])
// We activate animations instantly BUT deactivate them NSeconds later.
// We then toggle animation visibility using opacity. This saves a bunch of repaints.
const activate_animation = useDebouncedTruth(running || queued || waiting_to_run)
Expand All @@ -82,6 +83,9 @@ export const Cell = ({
published_objects_ref.current = published_objects
const disable_input_ref = useRef(disable_input)
disable_input_ref.current = disable_input
const should_set_waiting_to_run_ref = useRef(true)
should_set_waiting_to_run_ref.current = !running_disabled && !depends_on_disabled_cells
const set_waiting_to_run_smart = (x) => set_waiting_to_run(x && should_set_waiting_to_run_ref.current)

useLayoutEffect(() => {
Object.assign(node_ref.current, {
Expand All @@ -107,6 +111,8 @@ export const Cell = ({
selected: selected,
code_differs: class_code_differs,
code_folded: class_code_folded,
running_disabled: running_disabled,
depends_on_disabled_cells: depends_on_disabled_cells,
show_input: show_input,
drop_target: drag_active,
saving_file: saving_file,
Expand Down Expand Up @@ -152,7 +158,7 @@ export const Cell = ({
on_drag_drop_events=${handler}
on_submit=${() => {
if (!disable_input_ref.current) {
set_waiting_to_run(true)
set_waiting_to_run_smart(true)
pluto_actions.set_and_run_multiple([cell_id])
}
}}
Expand All @@ -176,19 +182,23 @@ export const Cell = ({
on_focus_neighbor=${on_focus_neighbor}
cell_id=${cell_id}
notebook_id=${notebook_id}
running_disabled=${running_disabled}
/>
<${RunArea}
onClick=${() => {
if (running || queued) {
pluto_actions.interrupt_remote(cell_id)
} else {
set_waiting_to_run(true)
let cell_to_run = selected ? selected_cells : [cell_id]
pluto_actions.set_and_run_multiple(cell_to_run)
}
cell_id=${cell_id}
running_disabled=${running_disabled}
depends_on_disabled_cells=${depends_on_disabled_cells}
on_run=${() => {
set_waiting_to_run_smart(true)
let cell_to_run = selected ? selected_cells : [cell_id]
pluto_actions.set_and_run_multiple(cell_to_run)
}}
on_interrupt=${() => {
pluto_actions.interrupt_remote(cell_id)
}}
runtime=${runtime}
running=${running}
queued=${queued}
/>
<button
onClick=${() => {
Expand Down
45 changes: 42 additions & 3 deletions frontend/components/CellInput.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, useState, useEffect, useLayoutEffect, useRef, useContext } from "../imports/Preact.js"
import { html, useState, useEffect, useLayoutEffect, useRef, useContext, useMemo } from "../imports/Preact.js"
import observablehq_for_myself from "../common/SetupCellEnvironment.js"

import { utf8index_to_ut16index } from "../common/UnicodeTools.js"
Expand Down Expand Up @@ -57,6 +57,7 @@ export const CellInput = ({
on_drag_drop_events,
cell_id,
notebook_id,
running_disabled,
}) => {
let pluto_actions = useContext(PlutoContext)

Expand Down Expand Up @@ -539,15 +540,53 @@ export const CellInput = ({
}, [show_input])

// TODO effect hook for disable_input?

return html`
<pluto-input ref=${dom_node_ref}>
<button onClick=${on_delete} class="delete_cell" title="Delete cell"><span></span></button>
<${InputContextMenu} on_delete=${on_delete} cell_id=${cell_id} run_cell=${on_submit} running_disabled=${running_disabled} />
<textarea ref=${text_area_ref}></textarea>
</pluto-input>
`
}

const InputContextMenu = ({ on_delete, cell_id, run_cell, running_disabled }) => {
const timeout = useRef(null)
let pluto_actions = useContext(PlutoContext)
const [open, setOpen] = useState(false)
const mouseenter = () => {
clearTimeout(timeout.current)
}
const mouseleave = () => {
timeout.current = setTimeout(() => setOpen(false), 250)
}
const toggle_running_disabled = async (e) => {
const new_val = !running_disabled
e.preventDefault()
e.stopPropagation()
await pluto_actions.update_notebook((notebook) => {
notebook.cell_inputs[cell_id].running_disabled = new_val
})
// we also 'run' the cell if it is disabled, this will make the backend propage the disabled state to dependent cells
await run_cell()
}

return html` <button onMouseleave=${mouseleave} onClick=${() => setOpen(!open)} onBlur=${() => setOpen(false)} class="delete_cell" title="Actions">
<span class="icon"></span>
${open
? html`<ul onMouseenter=${mouseenter} class="input_menu">
<li
onClick=${toggle_running_disabled}
title=${running_disabled ? "Enable and run the cell" : "Disable this cell, and all cells that depend on it"}
>
${running_disabled ? html`<span class="enable_cell_icon" />` : html`<span class="disable_cell_icon" />`}
${running_disabled ? html`Enable cell` : html`Disable cell`}
</li>
<li onClick=${on_delete} title="Delete"><span class="delete_icon" />Delete cell</li>
<li class="coming_soon" title=""><span class="bandage_icon" /><em>Coming soon…</em></li>
</ul>`
: html``}
</button>`
}

const no_autocomplete = " \t\r\n([])+-=/,;'\"!#$%^&*~`<>|"

const on_tab_key = (cm) => {
Expand Down
11 changes: 10 additions & 1 deletion frontend/components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const first_true_key = (obj) => {
* cell_id: string,
* code: string,
* code_folded: boolean,
* running_disabled: boolean,
* }}
*/

Expand All @@ -130,7 +131,12 @@ const first_true_key = (obj) => {
* queued: boolean,
* running: boolean,
* errored: boolean,
* runtime?: number,
* runtime: ?number,
* downstream_cells_map: { string: [string]},
* upstream_cells_map: { string: [string]},
* precedence_heuristic: ?number,
* running_disabled: boolean,
* depends_on_disabled_cells: boolean,
* output: {
* body: string,
* persist_js_state: boolean,
Expand Down Expand Up @@ -280,6 +286,7 @@ export class Editor extends Component {
cell_id: uuidv4(),
code: code,
code_folded: false,
running_disabled: false,
}))
if (index === -1) {
index = this.state.notebook.cell_order.length
Expand Down Expand Up @@ -355,6 +362,7 @@ export class Editor extends Component {
cell_id: uuidv4(),
code: code,
code_folded: false,
running_disabled: false,
}
})

Expand Down Expand Up @@ -412,6 +420,7 @@ export class Editor extends Component {
cell_id: id,
code,
code_folded: false,
running_disabled: false,
}
notebook.cell_order = [...notebook.cell_order.slice(0, index), id, ...notebook.cell_order.slice(index, Infinity)]
})
Expand Down
10 changes: 8 additions & 2 deletions frontend/components/Notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let CellMemo = ({
notebook_id,
on_update_doc_query,
on_cell_input,
cell_dependencies,
on_focus_neighbor,
selected,
selected_cells,
Expand All @@ -20,12 +21,13 @@ let CellMemo = ({
}) => {
const selected_cells_diffable_primitive = (selected_cells || []).join("")
const { body, last_run_timestamp, mime, persist_js_state, rootassignee } = cell_result?.output || {}
const { queued, running, runtime, errored } = cell_result || {}
const { cell_id, code, code_folded } = cell_input || {}
const { queued, running, runtime, errored, depends_on_disabled_cells } = cell_result || {}
const { cell_id, code, code_folded, running_disabled } = cell_input || {}
return useMemo(() => {
return html`
<${Cell}
cell_result=${cell_result}
cell_dependencies=${cell_dependencies}
cell_input=${cell_input}
cell_input_local=${cell_input_local}
notebook_id=${notebook_id}
Expand All @@ -42,6 +44,8 @@ let CellMemo = ({
`
}, [
cell_id,
running_disabled,
depends_on_disabled_cells,
queued,
running,
runtime,
Expand All @@ -57,6 +61,7 @@ let CellMemo = ({
notebook_id,
on_update_doc_query,
on_cell_input,
cell_dependencies,
on_focus_neighbor,
selected,
selected_cells_diffable_primitive,
Expand Down Expand Up @@ -151,6 +156,7 @@ export const Notebook = ({
output: null,
}}
cell_input=${notebook.cell_inputs[cell_id]}
cell_dependencies=${notebook.cell_dependencies[cell_id] ?? {}}
cell_input_local=${cell_inputs_local[cell_id]}
notebook_id=${notebook.notebook_id}
on_update_doc_query=${on_update_doc_query}
Expand Down
53 changes: 49 additions & 4 deletions frontend/components/RunArea.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,56 @@
import { in_textarea_or_input } from "../common/KeyboardShortcuts.js"
import { html, useEffect, useMemo, useState } from "../imports/Preact.js"
import { PlutoContext } from "../common/PlutoContext.js"
import { html, useContext, useEffect, useMemo, useState } from "../imports/Preact.js"

export const RunArea = ({ runtime, onClick, running }) => {
const upstream_of = (a_cell_id, notebook) => Object.values(notebook?.cell_dependencies?.[a_cell_id]?.upstream_cells_map || {}).flatMap((x) => x)

const all_upstreams_of = (a_cell_id, notebook) => {
const upstreams = upstream_of(a_cell_id, notebook)
if (upstreams.length === 0) return []
return [...upstreams, ...upstreams.flatMap((v) => all_upstreams_of(v, notebook))]
}
const hasBarrier = (a_cell_id, notebook) => {
return notebook?.cell_inputs?.[a_cell_id]?.running_disabled
}

export const RunArea = ({ runtime, running, queued, on_run, on_interrupt, on_save, depends_on_disabled_cells, running_disabled, cell_id }) => {
const localTimeRunning = 10e5 * useMillisSinceTruthy(running)
const pluto_actions = useContext(PlutoContext)

const on_jump = () => {
const notebook = pluto_actions.get_notebook() || {}
const barrier_cell_id = all_upstreams_of(cell_id, notebook).find((c) => hasBarrier(c, notebook))
barrier_cell_id &&
window.dispatchEvent(
new CustomEvent("cell_focus", {
detail: {
cell_id: barrier_cell_id,
line: 0, // 1-based to 0-based index
},
})
)
}
const action = running || queued ? "interrupt" : running_disabled ? "save" : depends_on_disabled_cells ? "jump" : "run"

const fmap = {
on_interrupt,
on_save,
on_jump,
on_run,
}

const titlemap = {
interrupt: "Interrupt",
save: "Save code without running",
jump: "This cell depends on a disabled cell",
run: "Run cell",
}

return html`
<pluto-runarea>
<button onClick=${onClick} class="runcell" title="Run"><span></span></button>
<pluto-runarea class=${action}>
<button onClick=${fmap[`on_${action}`]} class="runcell" title=${titlemap[action]}>
<span></span>
</button>
<span class="runtime">${prettytime(running ? localTimeRunning || runtime : runtime)}</span>
</pluto-runarea>
`
Expand Down
Loading