jupyterlab-ipyflow 0.0.151 → 0.0.152

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 +43 -40
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -2,6 +2,31 @@ import { ICommandPalette } from '@jupyterlab/apputils';
2
2
  import { CodeCell } from '@jupyterlab/cells';
3
3
  import { INotebookTracker } from '@jupyterlab/notebook';
4
4
  const IPYFLOW_KERNEL_NAME = 'ipyflow';
5
+ const waitingClass = 'waiting-cell';
6
+ const readyClass = 'ready-cell';
7
+ const readyMakingClass = 'ready-making-cell';
8
+ const readyMakingInputClass = 'ready-making-input-cell';
9
+ const linkedWaitingClass = 'linked-waiting';
10
+ const linkedReadyMakerClass = 'linked-ready-maker';
11
+ // ipyflow frontend state
12
+ let dirtyCells = new Set();
13
+ let waitingCells = new Set();
14
+ let readyCells = new Set();
15
+ let waiterLinks = {};
16
+ let readyMakerLinks = {};
17
+ let activeCell = null;
18
+ let activeCellId = null;
19
+ let cellsById = {};
20
+ let cellModelsById = {};
21
+ let orderIdxById = {};
22
+ let cellPendingExecution = null;
23
+ let lastExecutionMode = null;
24
+ let isReactivelyExecuting = false;
25
+ let lastExecutionHighlights = null;
26
+ let executedReactiveReadyCells = new Set();
27
+ let newReadyCells = new Set();
28
+ let forcedReactiveCells = new Set();
29
+ const cleanup = new Event('cleanup');
5
30
  /**
6
31
  * Initialization data for the jupyterlab-ipyflow extension.
7
32
  */
@@ -79,35 +104,6 @@ const extension = {
79
104
  });
80
105
  }
81
106
  };
82
- const waitingClass = 'waiting-cell';
83
- const readyClass = 'ready-cell';
84
- const readyMakingClass = 'ready-making-cell';
85
- const readyMakingInputClass = 'ready-making-input-cell';
86
- const linkedWaitingClass = 'linked-waiting';
87
- const linkedReadyMakerClass = 'linked-ready-maker';
88
- let dirtyCells = new Set();
89
- let waitingCells = new Set();
90
- let readyCells = new Set();
91
- let waiterLinks = {};
92
- let readyMakerLinks = {};
93
- let activeCell = null;
94
- let activeCellId = null;
95
- let cellsById = {};
96
- let cellModelsById = {};
97
- let orderIdxById = {};
98
- let cellPendingExecution = null;
99
- let lastExecutionMode = null;
100
- let isReactivelyExecuting = false;
101
- let lastExecutionHighlights = null;
102
- let executedReactiveReadyCells = new Set();
103
- let newReadyCells = new Set();
104
- let forcedReactiveCells = new Set();
105
- const cleanup = new Event('cleanup');
106
- const resetReactiveState = () => {
107
- newReadyCells = new Set();
108
- forcedReactiveCells = new Set();
109
- executedReactiveReadyCells = new Set();
110
- };
111
107
  const getJpInputCollapser = (elem) => {
112
108
  if (elem === null || elem === undefined) {
113
109
  return null;
@@ -353,8 +349,14 @@ const connectToComm = (session, notebook) => {
353
349
  else if (msg.content.data['type'] === 'compute_exec_schedule') {
354
350
  waitingCells = new Set(msg.content.data['waiting_cells']);
355
351
  readyCells = new Set(msg.content.data['ready_cells']);
356
- newReadyCells = new Set([...newReadyCells, ...msg.content.data['new_ready_cells']]);
357
- forcedReactiveCells = new Set([...forcedReactiveCells, ...msg.content.data['forced_reactive_cells']]);
352
+ newReadyCells = new Set([
353
+ ...newReadyCells,
354
+ ...msg.content.data['new_ready_cells'],
355
+ ]);
356
+ forcedReactiveCells = new Set([
357
+ ...forcedReactiveCells,
358
+ ...msg.content.data['forced_reactive_cells'],
359
+ ]);
358
360
  waiterLinks = msg.content.data['waiter_links'];
359
361
  readyMakerLinks = msg.content.data['ready_maker_links'];
360
362
  cellPendingExecution = null;
@@ -363,17 +365,19 @@ const connectToComm = (session, notebook) => {
363
365
  const exec_schedule = msg.content.data['exec_schedule'];
364
366
  lastExecutionMode = exec_mode;
365
367
  lastExecutionHighlights = msg.content.data['highlights'];
366
- executedReactiveReadyCells.add(msg.content.data['last_executed_cell_id']);
368
+ const lastExecutedCellId = msg.content.data['last_executed_cell_id'];
369
+ executedReactiveReadyCells.add(lastExecutedCellId);
367
370
  const last_execution_was_error = msg.content.data['last_execution_was_error'];
368
371
  if (!last_execution_was_error) {
369
372
  for (const cell of notebook.widgets) {
370
373
  if (cell.model.type !== 'code' || executedReactiveReadyCells.has(cell.model.id)) {
371
374
  continue;
372
375
  }
373
- if (!forcedReactiveCells.has(cell.model.id)) {
374
- if (exec_mode !== 'reactive' || !newReadyCells.has(cell.model.id)) {
375
- continue;
376
- }
376
+ if (!newReadyCells.has(cell.model.id)) {
377
+ continue;
378
+ }
379
+ if (!forcedReactiveCells.has(cell.model.id) && exec_mode !== 'reactive') {
380
+ continue;
377
381
  }
378
382
  const codeCell = cell;
379
383
  if (cellPendingExecution === null) {
@@ -397,14 +401,13 @@ const connectToComm = (session, notebook) => {
397
401
  if (lastExecutionHighlights === 'reactive') {
398
402
  readyCells = executedReactiveReadyCells;
399
403
  }
400
- resetReactiveState();
401
404
  comm.send({
402
405
  type: 'reactivity_cleanup',
403
406
  });
404
407
  }
405
- else {
406
- executedReactiveReadyCells = new Set();
407
- }
408
+ forcedReactiveCells = new Set();
409
+ newReadyCells = new Set();
410
+ executedReactiveReadyCells = new Set();
408
411
  updateUI(notebook);
409
412
  isReactivelyExecuting = false;
410
413
  }
package/package.json CHANGED
@@ -63,5 +63,5 @@
63
63
  "extension": true,
64
64
  "outputDir": "../../core/ipyflow/resources/labextension/"
65
65
  },
66
- "version": "0.0.151"
66
+ "version": "0.0.152"
67
67
  }