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.
Files changed (2) hide show
  1. package/lib/index.js +69 -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,27 +205,41 @@ class IpyflowSessionState {
204
205
  .sort((a, b) => orderIdxById[a] - orderIdxById[b])
205
206
  .map((id) => this.cellsById[id]);
206
207
  }
207
- computeTransitiveClosure(cellIds, inclusive = true, parents = false) {
208
- const closure = new Set();
209
- for (const cellId of cellIds) {
210
- if (parents) {
211
- this.computeTransitiveClosureHelper(closure, cellId, this.cellParents);
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
- else {
214
- this.computeTransitiveClosureHelper(closure, cellId, this.cellChildren);
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.computeTransitiveClosureHelper(closure, cellId, this.cellParents, true, true);
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 cellIds) {
235
+ for (const cellId of startCellIds) {
224
236
  closure.delete(cellId);
225
237
  }
226
238
  }
227
- 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)));
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 === 'normal' &&
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 === 'normal') {
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 : 'normal') === 'classic') {
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
- for (const cellId of closureCellIds) {
874
- state.computeTransitiveClosureHelper(slice, cellId, state.cellChildren);
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.computeTransitiveClosureHelper(slice, cellId, state.cellParents);
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
- CodeCell.execute(state.cellPendingExecution, session);
1096
+ state.executeCells([state.cellPendingExecution]);
1093
1097
  }
1094
1098
  }
1095
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.210"
70
+ "version": "0.0.212"
71
71
  }