jupyterlab-ipyflow 0.0.154 → 0.0.155
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 +59 -30
- package/package.json +6 -5
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ICommandPalette } from '@jupyterlab/apputils';
|
|
2
2
|
import { CodeCell } from '@jupyterlab/cells';
|
|
3
3
|
import { INotebookTracker } from '@jupyterlab/notebook';
|
|
4
|
+
import _ from 'lodash';
|
|
4
5
|
const IPYFLOW_KERNEL_NAME = 'ipyflow';
|
|
5
6
|
const waitingClass = 'waiting-cell';
|
|
6
7
|
const readyClass = 'ready-cell';
|
|
@@ -206,6 +207,35 @@ const addUnsafeCellInteraction = (elem, linkedElems, cellsById, collapserFun, ev
|
|
|
206
207
|
const connectToComm = (session, notebook) => {
|
|
207
208
|
const comm = session.session.kernel.createComm('ipyflow');
|
|
208
209
|
let disconnected = false;
|
|
210
|
+
const gatherCellMetadataAndContent = () => {
|
|
211
|
+
const cell_metadata_by_id = {};
|
|
212
|
+
notebook.widgets.forEach((itercell, idx) => {
|
|
213
|
+
cell_metadata_by_id[itercell.model.id] = {
|
|
214
|
+
index: idx,
|
|
215
|
+
content: itercell.model.value.text,
|
|
216
|
+
type: itercell.model.type,
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
return cell_metadata_by_id;
|
|
220
|
+
};
|
|
221
|
+
const onContentChanged = _.debounce(() => {
|
|
222
|
+
if (disconnected) {
|
|
223
|
+
notebook.model.contentChanged.disconnect(onContentChanged);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
comm.send({
|
|
227
|
+
type: 'notify_content_changed',
|
|
228
|
+
cell_metadata_by_id: gatherCellMetadataAndContent(),
|
|
229
|
+
});
|
|
230
|
+
}, 500);
|
|
231
|
+
const requestComputeExecSchedule = (cell) => {
|
|
232
|
+
const cell_metadata_by_id = gatherCellMetadataAndContent();
|
|
233
|
+
comm.send({
|
|
234
|
+
type: 'compute_exec_schedule',
|
|
235
|
+
executed_cell_id: cell === null || cell === void 0 ? void 0 : cell.id,
|
|
236
|
+
cell_metadata_by_id,
|
|
237
|
+
});
|
|
238
|
+
};
|
|
209
239
|
const onExecution = (cell, args) => {
|
|
210
240
|
if (disconnected) {
|
|
211
241
|
cell.stateChanged.disconnect(onExecution);
|
|
@@ -214,23 +244,13 @@ const connectToComm = (session, notebook) => {
|
|
|
214
244
|
if (args.name !== 'executionCount' || args.newValue === null) {
|
|
215
245
|
return;
|
|
216
246
|
}
|
|
217
|
-
const cell_metadata_by_id = {};
|
|
218
247
|
notebook.widgets.forEach((itercell, idx) => {
|
|
219
|
-
cell_metadata_by_id[itercell.model.id] = {
|
|
220
|
-
index: idx,
|
|
221
|
-
content: itercell.model.value.text,
|
|
222
|
-
type: itercell.model.type,
|
|
223
|
-
};
|
|
224
248
|
if (itercell.model.id === cell.id) {
|
|
225
249
|
itercell.node.classList.remove(readyClass);
|
|
226
250
|
itercell.node.classList.remove(readyMakingInputClass);
|
|
227
251
|
}
|
|
228
252
|
});
|
|
229
|
-
|
|
230
|
-
type: 'compute_exec_schedule',
|
|
231
|
-
executed_cell_id: cell.id,
|
|
232
|
-
cell_metadata_by_id,
|
|
233
|
-
});
|
|
253
|
+
requestComputeExecSchedule(cell);
|
|
234
254
|
};
|
|
235
255
|
const notifyActiveCell = (newActiveCell) => {
|
|
236
256
|
let newActiveCellOrderIdx = -1;
|
|
@@ -308,10 +328,8 @@ const connectToComm = (session, notebook) => {
|
|
|
308
328
|
}
|
|
309
329
|
else if (readyCells.has(id)) {
|
|
310
330
|
elem.classList.add(readyMakingInputClass);
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
addWaitingOutputInteractions(elem, linkedReadyMakerClass);
|
|
314
|
-
}
|
|
331
|
+
elem.classList.add(readyClass);
|
|
332
|
+
addWaitingOutputInteractions(elem, linkedReadyMakerClass);
|
|
315
333
|
}
|
|
316
334
|
if (lastExecutionMode === 'reactive') {
|
|
317
335
|
return;
|
|
@@ -344,38 +362,49 @@ const connectToComm = (session, notebook) => {
|
|
|
344
362
|
}
|
|
345
363
|
};
|
|
346
364
|
comm.onMsg = (msg) => {
|
|
347
|
-
|
|
365
|
+
var _a;
|
|
366
|
+
const payload = msg.content.data;
|
|
367
|
+
if (disconnected || !((_a = payload.success) !== null && _a !== void 0 ? _a : false)) {
|
|
348
368
|
return;
|
|
349
369
|
}
|
|
350
|
-
if (
|
|
370
|
+
if (payload.type === 'establish') {
|
|
351
371
|
notebook.activeCell.model.stateChanged.connect(onExecution);
|
|
352
372
|
notifyActiveCell(notebook.activeCell.model);
|
|
373
|
+
notebook.model.contentChanged.connect(onContentChanged);
|
|
374
|
+
requestComputeExecSchedule();
|
|
353
375
|
}
|
|
354
|
-
else if (
|
|
355
|
-
waitingCells = new Set(
|
|
356
|
-
readyCells = new Set(
|
|
376
|
+
else if (payload.type === 'compute_exec_schedule') {
|
|
377
|
+
waitingCells = new Set(payload.waiting_cells);
|
|
378
|
+
readyCells = new Set(payload.ready_cells);
|
|
357
379
|
newReadyCells = new Set([
|
|
358
380
|
...newReadyCells,
|
|
359
|
-
...
|
|
381
|
+
...payload.new_ready_cells,
|
|
360
382
|
]);
|
|
361
383
|
forcedReactiveCells = new Set([
|
|
362
384
|
...forcedReactiveCells,
|
|
363
|
-
...
|
|
385
|
+
...payload.forced_reactive_cells,
|
|
364
386
|
]);
|
|
365
|
-
waiterLinks =
|
|
366
|
-
readyMakerLinks =
|
|
387
|
+
waiterLinks = payload.waiter_links;
|
|
388
|
+
readyMakerLinks = payload.ready_maker_links;
|
|
367
389
|
cellPendingExecution = null;
|
|
368
|
-
const exec_mode =
|
|
390
|
+
const exec_mode = payload.exec_mode;
|
|
369
391
|
isReactivelyExecuting = isReactivelyExecuting || (exec_mode === 'reactive');
|
|
370
|
-
const flow_order =
|
|
371
|
-
const exec_schedule =
|
|
392
|
+
const flow_order = payload.flow_order;
|
|
393
|
+
const exec_schedule = payload.exec_schedule;
|
|
372
394
|
lastExecutionMode = exec_mode;
|
|
373
|
-
lastExecutionHighlights =
|
|
374
|
-
const lastExecutedCellId =
|
|
395
|
+
lastExecutionHighlights = payload.highlights;
|
|
396
|
+
const lastExecutedCellId = payload.last_executed_cell_id;
|
|
375
397
|
executedReactiveReadyCells.add(lastExecutedCellId);
|
|
376
|
-
const last_execution_was_error =
|
|
398
|
+
const last_execution_was_error = payload.last_execution_was_error;
|
|
377
399
|
if (!last_execution_was_error) {
|
|
400
|
+
let lastExecutedCellIdSeen = false;
|
|
378
401
|
for (const cell of notebook.widgets) {
|
|
402
|
+
if (!lastExecutedCellIdSeen) {
|
|
403
|
+
lastExecutedCellIdSeen = (cell.model.id == lastExecutedCellId);
|
|
404
|
+
if (flow_order === 'in_order' || exec_schedule === 'strict') {
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
379
408
|
if (cell.model.type !== 'code' || executedReactiveReadyCells.has(cell.model.id)) {
|
|
380
409
|
continue;
|
|
381
410
|
}
|
package/package.json
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"jupyterlab",
|
|
7
7
|
"jupyterlab-extension"
|
|
8
8
|
],
|
|
9
|
-
"homepage": "https://github.com/
|
|
9
|
+
"homepage": "https://github.com/ipyflow/ipyflow",
|
|
10
10
|
"bugs": {
|
|
11
|
-
"url": "https://github.com/
|
|
11
|
+
"url": "https://github.com/ipyflow/ipyflow/issues"
|
|
12
12
|
},
|
|
13
13
|
"license": "BSD-3-Clause",
|
|
14
14
|
"author": "Stephen Macke",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"style": "style/index.css",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/
|
|
24
|
+
"url": "https://github.com/ipyflow/ipyflow.git"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@jupyterlab/application": "^3.4.3",
|
|
44
44
|
"@jupyterlab/coreutils": "^5.4.3",
|
|
45
|
-
"@jupyterlab/notebook": "^3.4.3"
|
|
45
|
+
"@jupyterlab/notebook": "^3.4.3",
|
|
46
|
+
"lodash": "^4.0"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@jupyterlab/builder": "^3.4.3",
|
|
@@ -63,5 +64,5 @@
|
|
|
63
64
|
"extension": true,
|
|
64
65
|
"outputDir": "../../core/ipyflow/resources/labextension/"
|
|
65
66
|
},
|
|
66
|
-
"version": "0.0.
|
|
67
|
+
"version": "0.0.155"
|
|
67
68
|
}
|