jupyterlab-ipyflow 0.0.211 → 0.0.214

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.
Files changed (2) hide show
  1. package/lib/index.js +53 -65
  2. 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 = 'normal';
117
+ this.settings.exec_mode = 'lazy';
118
118
  }
119
- else if (this.settings.exec_mode === 'normal') {
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
- computeTransitiveClosureHelper(closure, cellId, edges, pullReactiveUpdates = false, skipFirstCheck = false) {
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.computeTransitiveClosureHelper(closure, related, edges, pullReactiveUpdates);
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 && closure.has(cellId)) {
161
- relatives.forEach((related) => {
162
- var _a, _b, _c, _d;
163
- if (closure.has(related)) {
164
- return;
165
- }
166
- let shouldIncludeRelated = (_b = (_a = this.staleParents) === null || _a === void 0 ? void 0 : _a[cellId]) === null || _b === void 0 ? void 0 : _b.includes(related);
167
- if (!shouldIncludeRelated) {
168
- for (const [executed, staleParents] of Object.entries((_d = (_c = this.staleParentsByExecutedCellByChild) === null || _c === void 0 ? void 0 : _c[cellId]) !== null && _d !== void 0 ? _d : {})) {
169
- if (!closure.has(executed)) {
170
- continue;
171
- }
172
- shouldIncludeRelated = staleParents.includes(related);
173
- if (shouldIncludeRelated) {
174
- break;
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
- if (shouldIncludeRelated) {
179
- closure.add(related);
180
- this.computeTransitiveClosureHelper(closure, related, edges, pullReactiveUpdates, true);
181
- }
182
- });
183
- for (const [child, staleParents] of Object.entries((_b = (_a = this.staleParentsByChildByExecutedCell) === null || _a === void 0 ? void 0 : _a[cellId]) !== null && _b !== void 0 ? _b : {})) {
184
- if (!closure.has(child)) {
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
- for (const parent of staleParents) {
188
- if (closure.has(parent) || !((_c = edges === null || edges === void 0 ? void 0 : edges[child]) === null || _c === void 0 ? void 0 : _c.includes(parent))) {
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,26 +205,28 @@ class IpyflowSessionState {
204
205
  .sort((a, b) => orderIdxById[a] - orderIdxById[b])
205
206
  .map((id) => this.cellsById[id]);
206
207
  }
207
- computeTransitiveClosure(startCellIds, inclusive = true, parents = false) {
208
+ computeRawTransitiveClosure(startCellIds, inclusive = true, parents = false) {
208
209
  var _a, _b;
209
210
  let cellIds = startCellIds;
210
211
  const closure = new Set(cellIds);
212
+ // eslint-disable-next-line no-constant-condition
211
213
  while (true) {
212
214
  for (const cellId of cellIds) {
213
215
  if (parents) {
214
- this.computeTransitiveClosureHelper(closure, cellId, this.cellParents, false, true);
216
+ this.computeRawTransitiveClosureHelper(closure, cellId, this.cellParents, false, true);
215
217
  }
216
218
  else {
217
- this.computeTransitiveClosureHelper(closure, cellId, this.cellChildren, false, true);
219
+ this.computeRawTransitiveClosureHelper(closure, cellId, this.cellChildren, false, true);
218
220
  }
219
221
  }
220
222
  if (parents || !((_a = this.settings.pull_reactive_updates) !== null && _a !== void 0 ? _a : false)) {
221
223
  break;
222
224
  }
223
225
  for (const cellId of closure) {
224
- this.computeTransitiveClosureHelper(closure, cellId, this.cellParents, true, true);
226
+ this.computeRawTransitiveClosureHelper(closure, cellId, this.cellParents, true, true);
225
227
  }
226
- if (cellIds.length === closure.size || !((_b = this.settings.push_reactive_updates_to_cousins) !== null && _b !== void 0 ? _b : false)) {
228
+ if (cellIds.length === closure.size ||
229
+ !((_b = this.settings.push_reactive_updates_to_cousins) !== null && _b !== void 0 ? _b : false)) {
227
230
  break;
228
231
  }
229
232
  cellIds = Array.from(closure);
@@ -233,7 +236,10 @@ class IpyflowSessionState {
233
236
  closure.delete(cellId);
234
237
  }
235
238
  }
236
- return this.cellIdsToCells(Array.from(closure));
239
+ return closure;
240
+ }
241
+ computeTransitiveClosure(startCellIds, inclusive = true, parents = false) {
242
+ return this.cellIdsToCells(Array.from(this.computeRawTransitiveClosure(startCellIds, inclusive, parents)));
237
243
  }
238
244
  }
239
245
  _IpyflowSessionState_instances = new WeakSet(), _IpyflowSessionState_computeTopoOrderIdxHelper = function _IpyflowSessionState_computeTopoOrderIdxHelper(cellId, orderedCellIds, seen) {
@@ -354,7 +360,7 @@ const extension = {
354
360
  }
355
361
  else if (state.settings.reactivity_mode === 'batch') {
356
362
  let closure = altModeExecuteCells !== null && altModeExecuteCells !== void 0 ? altModeExecuteCells : [notebooks.activeCell];
357
- if (state.settings.exec_mode === 'normal' &&
363
+ if (state.settings.exec_mode === 'lazy' &&
358
364
  altModeExecuteCells === null) {
359
365
  closure = state.computeTransitiveClosure([
360
366
  notebooks.activeCell.model.id,
@@ -407,7 +413,7 @@ const extension = {
407
413
  app.commands.execute('notebook:enter-command-mode');
408
414
  const closure = state.computeTransitiveClosure([state.activeCell.model.id], true, isBackward);
409
415
  state.numPendingForcedReactiveCounterBumps++;
410
- if (state.settings.exec_mode === 'normal') {
416
+ if (state.settings.exec_mode === 'lazy') {
411
417
  state.executeCells(closure);
412
418
  }
413
419
  else {
@@ -733,9 +739,6 @@ const connectToComm = (session, notebooks, notebook) => {
733
739
  itercell.node.classList.remove(readyMakingInputClass);
734
740
  }
735
741
  });
736
- if (state.settings.reactivity_mode === 'incremental') {
737
- state.requestComputeExecSchedule();
738
- }
739
742
  };
740
743
  for (const cell of notebook.widgets) {
741
744
  cell.model.stateChanged.connect(onExecution);
@@ -821,7 +824,7 @@ const connectToComm = (session, notebooks, notebook) => {
821
824
  if (model.type !== 'code') {
822
825
  return;
823
826
  }
824
- if (((_a = state.settings.color_scheme) !== null && _a !== void 0 ? _a : 'normal') === 'classic') {
827
+ if (((_a = state.settings.color_scheme) !== null && _a !== void 0 ? _a : 'lazy') === 'classic') {
825
828
  node.classList.add(classicColorsClass);
826
829
  }
827
830
  if (inExecuteSlice) {
@@ -871,33 +874,18 @@ const connectToComm = (session, notebooks, notebook) => {
871
874
  }
872
875
  };
873
876
  const updateUI = (notebook) => {
874
- var _a, _b;
875
877
  clearCellState(notebook);
876
878
  refreshNodeMapping(notebook);
877
879
  let closureCellIds = state.selectedCells;
878
880
  if (closureCellIds.length === 0) {
879
881
  closureCellIds = [state.activeCell.model.id];
880
882
  }
881
- const executeSlice = new Set(closureCellIds);
882
- while (true) {
883
- for (const cellId of closureCellIds) {
884
- state.computeTransitiveClosureHelper(executeSlice, cellId, state.cellChildren, false, true);
885
- }
886
- if (!((_a = state.settings.pull_reactive_updates) !== null && _a !== void 0 ? _a : false)) {
887
- break;
888
- }
889
- for (const cellId of executeSlice) {
890
- state.computeTransitiveClosureHelper(executeSlice, cellId, state.cellParents, true, true);
891
- }
892
- if (executeSlice.size === closureCellIds.length || !((_b = state.settings.push_reactive_updates_to_cousins) !== null && _b !== void 0 ? _b : false)) {
893
- break;
894
- }
895
- closureCellIds = Array.from(executeSlice);
896
- }
883
+ const executeSlice = state.computeRawTransitiveClosure(closureCellIds, true, false);
884
+ closureCellIds = Array.from(executeSlice);
897
885
  const slice = new Set(executeSlice);
898
886
  for (const cellId of closureCellIds) {
899
887
  slice.delete(cellId);
900
- state.computeTransitiveClosureHelper(slice, cellId, state.cellParents);
888
+ state.computeRawTransitiveClosureHelper(slice, cellId, state.cellParents);
901
889
  }
902
890
  for (const cell of notebook.widgets) {
903
891
  const id = cell.model.id;
@@ -1105,7 +1093,7 @@ const connectToComm = (session, notebooks, notebook) => {
1105
1093
  else {
1106
1094
  state.isReactivelyExecuting = true;
1107
1095
  state.executedCells.add(state.cellPendingExecution.model.id);
1108
- CodeCell.execute(state.cellPendingExecution, session);
1096
+ state.executeCells([state.cellPendingExecution]);
1109
1097
  }
1110
1098
  }
1111
1099
  if (doneReactivelyExecuting) {
package/package.json CHANGED
@@ -67,5 +67,5 @@
67
67
  "extension": true,
68
68
  "outputDir": "../../core/ipyflow/resources/labextension/"
69
69
  },
70
- "version": "0.0.211"
70
+ "version": "0.0.214"
71
71
  }