jupyterlab-ipyflow 0.0.151 → 0.0.153

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 +44 -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,27 +349,36 @@ 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;
361
363
  const exec_mode = msg.content.data['exec_mode'];
364
+ isReactivelyExecuting = isReactivelyExecuting || (exec_mode === 'reactive');
362
365
  const flow_order = msg.content.data['flow_order'];
363
366
  const exec_schedule = msg.content.data['exec_schedule'];
364
367
  lastExecutionMode = exec_mode;
365
368
  lastExecutionHighlights = msg.content.data['highlights'];
366
- executedReactiveReadyCells.add(msg.content.data['last_executed_cell_id']);
369
+ const lastExecutedCellId = msg.content.data['last_executed_cell_id'];
370
+ executedReactiveReadyCells.add(lastExecutedCellId);
367
371
  const last_execution_was_error = msg.content.data['last_execution_was_error'];
368
372
  if (!last_execution_was_error) {
369
373
  for (const cell of notebook.widgets) {
370
374
  if (cell.model.type !== 'code' || executedReactiveReadyCells.has(cell.model.id)) {
371
375
  continue;
372
376
  }
373
- if (!forcedReactiveCells.has(cell.model.id)) {
374
- if (exec_mode !== 'reactive' || !newReadyCells.has(cell.model.id)) {
375
- continue;
376
- }
377
+ if (!newReadyCells.has(cell.model.id)) {
378
+ continue;
379
+ }
380
+ if (!forcedReactiveCells.has(cell.model.id) && exec_mode !== 'reactive') {
381
+ continue;
377
382
  }
378
383
  const codeCell = cell;
379
384
  if (cellPendingExecution === null) {
@@ -397,14 +402,13 @@ const connectToComm = (session, notebook) => {
397
402
  if (lastExecutionHighlights === 'reactive') {
398
403
  readyCells = executedReactiveReadyCells;
399
404
  }
400
- resetReactiveState();
401
405
  comm.send({
402
406
  type: 'reactivity_cleanup',
403
407
  });
404
408
  }
405
- else {
406
- executedReactiveReadyCells = new Set();
407
- }
409
+ forcedReactiveCells = new Set();
410
+ newReadyCells = new Set();
411
+ executedReactiveReadyCells = new Set();
408
412
  updateUI(notebook);
409
413
  isReactivelyExecuting = false;
410
414
  }
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.153"
67
67
  }