jupyterlab-ipyflow 0.0.210 → 0.0.212
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +69 -65
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -114,9 +114,9 @@ class IpyflowSessionState {
|
|
|
114
114
|
}
|
|
115
115
|
toggleReactivity() {
|
|
116
116
|
if (this.settings.exec_mode === 'reactive') {
|
|
117
|
-
this.settings.exec_mode = '
|
|
117
|
+
this.settings.exec_mode = 'lazy';
|
|
118
118
|
}
|
|
119
|
-
else if (this.settings.exec_mode === '
|
|
119
|
+
else if (this.settings.exec_mode === 'lazy') {
|
|
120
120
|
this.settings.exec_mode = 'reactive';
|
|
121
121
|
}
|
|
122
122
|
return this.session.session.kernel.requestExecute({
|
|
@@ -133,7 +133,7 @@ class IpyflowSessionState {
|
|
|
133
133
|
store_history: false,
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
computeRawTransitiveClosureHelper(closure, cellId, edges, pullReactiveUpdates = false, skipFirstCheck = false) {
|
|
137
137
|
var _a, _b, _c;
|
|
138
138
|
if (!skipFirstCheck && closure.has(cellId)) {
|
|
139
139
|
return;
|
|
@@ -147,7 +147,7 @@ class IpyflowSessionState {
|
|
|
147
147
|
}
|
|
148
148
|
const prevClosureSize = closure.size;
|
|
149
149
|
relatives.forEach((related) => {
|
|
150
|
-
this.
|
|
150
|
+
this.computeRawTransitiveClosureHelper(closure, related, edges, pullReactiveUpdates);
|
|
151
151
|
});
|
|
152
152
|
if (pullReactiveUpdates &&
|
|
153
153
|
(closure.size > prevClosureSize ||
|
|
@@ -157,40 +157,41 @@ class IpyflowSessionState {
|
|
|
157
157
|
this.dirtyCells.has(cellId))) {
|
|
158
158
|
closure.add(cellId);
|
|
159
159
|
}
|
|
160
|
-
if (pullReactiveUpdates
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
160
|
+
if (!pullReactiveUpdates || !closure.has(cellId)) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
relatives.forEach((related) => {
|
|
164
|
+
var _a, _b, _c, _d;
|
|
165
|
+
if (closure.has(related)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
let shouldIncludeRelated = (_b = (_a = this.staleParents) === null || _a === void 0 ? void 0 : _a[cellId]) === null || _b === void 0 ? void 0 : _b.includes(related);
|
|
169
|
+
if (!shouldIncludeRelated) {
|
|
170
|
+
for (const [executed, staleParents] of Object.entries((_d = (_c = this.staleParentsByExecutedCellByChild) === null || _c === void 0 ? void 0 : _c[cellId]) !== null && _d !== void 0 ? _d : {})) {
|
|
171
|
+
if (!closure.has(executed)) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
shouldIncludeRelated = staleParents.includes(related);
|
|
175
|
+
if (shouldIncludeRelated) {
|
|
176
|
+
break;
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
}
|
|
180
|
+
if (shouldIncludeRelated) {
|
|
181
|
+
closure.add(related);
|
|
182
|
+
this.computeRawTransitiveClosureHelper(closure, related, edges, pullReactiveUpdates, true);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
for (const [child, staleParents] of Object.entries((_b = (_a = this.staleParentsByChildByExecutedCell) === null || _a === void 0 ? void 0 : _a[cellId]) !== null && _b !== void 0 ? _b : {})) {
|
|
186
|
+
if (!closure.has(child)) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
for (const parent of staleParents) {
|
|
190
|
+
if (closure.has(parent) || !((_c = edges === null || edges === void 0 ? void 0 : edges[child]) === null || _c === void 0 ? void 0 : _c.includes(parent))) {
|
|
185
191
|
continue;
|
|
186
192
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
closure.add(parent);
|
|
192
|
-
this.computeTransitiveClosureHelper(closure, parent, edges, pullReactiveUpdates, true);
|
|
193
|
-
}
|
|
193
|
+
closure.add(parent);
|
|
194
|
+
this.computeRawTransitiveClosureHelper(closure, parent, edges, pullReactiveUpdates, true);
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
}
|
|
@@ -204,27 +205,41 @@ class IpyflowSessionState {
|
|
|
204
205
|
.sort((a, b) => orderIdxById[a] - orderIdxById[b])
|
|
205
206
|
.map((id) => this.cellsById[id]);
|
|
206
207
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
computeRawTransitiveClosure(startCellIds, inclusive = true, parents = false) {
|
|
209
|
+
var _a, _b;
|
|
210
|
+
let cellIds = startCellIds;
|
|
211
|
+
const closure = new Set(cellIds);
|
|
212
|
+
// eslint-disable-next-line no-constant-condition
|
|
213
|
+
while (true) {
|
|
214
|
+
for (const cellId of cellIds) {
|
|
215
|
+
if (parents) {
|
|
216
|
+
this.computeRawTransitiveClosureHelper(closure, cellId, this.cellParents, false, true);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
this.computeRawTransitiveClosureHelper(closure, cellId, this.cellChildren, false, true);
|
|
220
|
+
}
|
|
212
221
|
}
|
|
213
|
-
|
|
214
|
-
|
|
222
|
+
if (parents || !((_a = this.settings.pull_reactive_updates) !== null && _a !== void 0 ? _a : false)) {
|
|
223
|
+
break;
|
|
215
224
|
}
|
|
216
|
-
}
|
|
217
|
-
if (!parents) {
|
|
218
225
|
for (const cellId of closure) {
|
|
219
|
-
this.
|
|
226
|
+
this.computeRawTransitiveClosureHelper(closure, cellId, this.cellParents, true, true);
|
|
227
|
+
}
|
|
228
|
+
if (cellIds.length === closure.size ||
|
|
229
|
+
!((_b = this.settings.push_reactive_updates_to_cousins) !== null && _b !== void 0 ? _b : false)) {
|
|
230
|
+
break;
|
|
220
231
|
}
|
|
232
|
+
cellIds = Array.from(closure);
|
|
221
233
|
}
|
|
222
234
|
if (!inclusive) {
|
|
223
|
-
for (const cellId of
|
|
235
|
+
for (const cellId of startCellIds) {
|
|
224
236
|
closure.delete(cellId);
|
|
225
237
|
}
|
|
226
238
|
}
|
|
227
|
-
return
|
|
239
|
+
return closure;
|
|
240
|
+
}
|
|
241
|
+
computeTransitiveClosure(startCellIds, inclusive = true, parents = false) {
|
|
242
|
+
return this.cellIdsToCells(Array.from(this.computeRawTransitiveClosure(startCellIds, inclusive, parents)));
|
|
228
243
|
}
|
|
229
244
|
}
|
|
230
245
|
_IpyflowSessionState_instances = new WeakSet(), _IpyflowSessionState_computeTopoOrderIdxHelper = function _IpyflowSessionState_computeTopoOrderIdxHelper(cellId, orderedCellIds, seen) {
|
|
@@ -345,7 +360,7 @@ const extension = {
|
|
|
345
360
|
}
|
|
346
361
|
else if (state.settings.reactivity_mode === 'batch') {
|
|
347
362
|
let closure = altModeExecuteCells !== null && altModeExecuteCells !== void 0 ? altModeExecuteCells : [notebooks.activeCell];
|
|
348
|
-
if (state.settings.exec_mode === '
|
|
363
|
+
if (state.settings.exec_mode === 'lazy' &&
|
|
349
364
|
altModeExecuteCells === null) {
|
|
350
365
|
closure = state.computeTransitiveClosure([
|
|
351
366
|
notebooks.activeCell.model.id,
|
|
@@ -398,7 +413,7 @@ const extension = {
|
|
|
398
413
|
app.commands.execute('notebook:enter-command-mode');
|
|
399
414
|
const closure = state.computeTransitiveClosure([state.activeCell.model.id], true, isBackward);
|
|
400
415
|
state.numPendingForcedReactiveCounterBumps++;
|
|
401
|
-
if (state.settings.exec_mode === '
|
|
416
|
+
if (state.settings.exec_mode === 'lazy') {
|
|
402
417
|
state.executeCells(closure);
|
|
403
418
|
}
|
|
404
419
|
else {
|
|
@@ -724,9 +739,6 @@ const connectToComm = (session, notebooks, notebook) => {
|
|
|
724
739
|
itercell.node.classList.remove(readyMakingInputClass);
|
|
725
740
|
}
|
|
726
741
|
});
|
|
727
|
-
if (state.settings.reactivity_mode === 'incremental') {
|
|
728
|
-
state.requestComputeExecSchedule();
|
|
729
|
-
}
|
|
730
742
|
};
|
|
731
743
|
for (const cell of notebook.widgets) {
|
|
732
744
|
cell.model.stateChanged.connect(onExecution);
|
|
@@ -812,7 +824,7 @@ const connectToComm = (session, notebooks, notebook) => {
|
|
|
812
824
|
if (model.type !== 'code') {
|
|
813
825
|
return;
|
|
814
826
|
}
|
|
815
|
-
if (((_a = state.settings.color_scheme) !== null && _a !== void 0 ? _a : '
|
|
827
|
+
if (((_a = state.settings.color_scheme) !== null && _a !== void 0 ? _a : 'lazy') === 'classic') {
|
|
816
828
|
node.classList.add(classicColorsClass);
|
|
817
829
|
}
|
|
818
830
|
if (inExecuteSlice) {
|
|
@@ -862,26 +874,18 @@ const connectToComm = (session, notebooks, notebook) => {
|
|
|
862
874
|
}
|
|
863
875
|
};
|
|
864
876
|
const updateUI = (notebook) => {
|
|
865
|
-
var _a;
|
|
866
877
|
clearCellState(notebook);
|
|
867
878
|
refreshNodeMapping(notebook);
|
|
868
|
-
const slice = new Set();
|
|
869
879
|
let closureCellIds = state.selectedCells;
|
|
870
880
|
if (closureCellIds.length === 0) {
|
|
871
881
|
closureCellIds = [state.activeCell.model.id];
|
|
872
882
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
const executeSlice = new Set(slice);
|
|
877
|
-
if ((_a = state.settings.pull_reactive_updates) !== null && _a !== void 0 ? _a : false) {
|
|
878
|
-
for (const cellId of slice) {
|
|
879
|
-
state.computeTransitiveClosureHelper(executeSlice, cellId, state.cellParents, true, true);
|
|
880
|
-
}
|
|
881
|
-
}
|
|
883
|
+
const executeSlice = state.computeRawTransitiveClosure(closureCellIds, true, false);
|
|
884
|
+
closureCellIds = Array.from(executeSlice);
|
|
885
|
+
const slice = new Set(executeSlice);
|
|
882
886
|
for (const cellId of closureCellIds) {
|
|
883
887
|
slice.delete(cellId);
|
|
884
|
-
state.
|
|
888
|
+
state.computeRawTransitiveClosureHelper(slice, cellId, state.cellParents);
|
|
885
889
|
}
|
|
886
890
|
for (const cell of notebook.widgets) {
|
|
887
891
|
const id = cell.model.id;
|
|
@@ -1089,7 +1093,7 @@ const connectToComm = (session, notebooks, notebook) => {
|
|
|
1089
1093
|
else {
|
|
1090
1094
|
state.isReactivelyExecuting = true;
|
|
1091
1095
|
state.executedCells.add(state.cellPendingExecution.model.id);
|
|
1092
|
-
|
|
1096
|
+
state.executeCells([state.cellPendingExecution]);
|
|
1093
1097
|
}
|
|
1094
1098
|
}
|
|
1095
1099
|
if (doneReactivelyExecuting) {
|
package/package.json
CHANGED