jupyterlab-ipyflow 0.0.153 → 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 +64 -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';
|
|
@@ -60,6 +61,11 @@ const extension = {
|
|
|
60
61
|
keys: ['Accel Shift Enter'],
|
|
61
62
|
selector: '.jp-Notebook',
|
|
62
63
|
});
|
|
64
|
+
app.commands.addKeyBinding({
|
|
65
|
+
command: 'alt-mode-execute',
|
|
66
|
+
keys: ['Ctrl Shift Enter'],
|
|
67
|
+
selector: '.jp-Notebook',
|
|
68
|
+
});
|
|
63
69
|
palette.addItem({
|
|
64
70
|
command: 'alt-mode-execute',
|
|
65
71
|
category: 'execution',
|
|
@@ -201,6 +207,35 @@ const addUnsafeCellInteraction = (elem, linkedElems, cellsById, collapserFun, ev
|
|
|
201
207
|
const connectToComm = (session, notebook) => {
|
|
202
208
|
const comm = session.session.kernel.createComm('ipyflow');
|
|
203
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
|
+
};
|
|
204
239
|
const onExecution = (cell, args) => {
|
|
205
240
|
if (disconnected) {
|
|
206
241
|
cell.stateChanged.disconnect(onExecution);
|
|
@@ -209,23 +244,13 @@ const connectToComm = (session, notebook) => {
|
|
|
209
244
|
if (args.name !== 'executionCount' || args.newValue === null) {
|
|
210
245
|
return;
|
|
211
246
|
}
|
|
212
|
-
const cell_metadata_by_id = {};
|
|
213
247
|
notebook.widgets.forEach((itercell, idx) => {
|
|
214
|
-
cell_metadata_by_id[itercell.model.id] = {
|
|
215
|
-
index: idx,
|
|
216
|
-
content: itercell.model.value.text,
|
|
217
|
-
type: itercell.model.type,
|
|
218
|
-
};
|
|
219
248
|
if (itercell.model.id === cell.id) {
|
|
220
249
|
itercell.node.classList.remove(readyClass);
|
|
221
250
|
itercell.node.classList.remove(readyMakingInputClass);
|
|
222
251
|
}
|
|
223
252
|
});
|
|
224
|
-
|
|
225
|
-
type: 'compute_exec_schedule',
|
|
226
|
-
executed_cell_id: cell.id,
|
|
227
|
-
cell_metadata_by_id,
|
|
228
|
-
});
|
|
253
|
+
requestComputeExecSchedule(cell);
|
|
229
254
|
};
|
|
230
255
|
const notifyActiveCell = (newActiveCell) => {
|
|
231
256
|
let newActiveCellOrderIdx = -1;
|
|
@@ -303,10 +328,8 @@ const connectToComm = (session, notebook) => {
|
|
|
303
328
|
}
|
|
304
329
|
else if (readyCells.has(id)) {
|
|
305
330
|
elem.classList.add(readyMakingInputClass);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
addWaitingOutputInteractions(elem, linkedReadyMakerClass);
|
|
309
|
-
}
|
|
331
|
+
elem.classList.add(readyClass);
|
|
332
|
+
addWaitingOutputInteractions(elem, linkedReadyMakerClass);
|
|
310
333
|
}
|
|
311
334
|
if (lastExecutionMode === 'reactive') {
|
|
312
335
|
return;
|
|
@@ -339,38 +362,49 @@ const connectToComm = (session, notebook) => {
|
|
|
339
362
|
}
|
|
340
363
|
};
|
|
341
364
|
comm.onMsg = (msg) => {
|
|
342
|
-
|
|
365
|
+
var _a;
|
|
366
|
+
const payload = msg.content.data;
|
|
367
|
+
if (disconnected || !((_a = payload.success) !== null && _a !== void 0 ? _a : false)) {
|
|
343
368
|
return;
|
|
344
369
|
}
|
|
345
|
-
if (
|
|
370
|
+
if (payload.type === 'establish') {
|
|
346
371
|
notebook.activeCell.model.stateChanged.connect(onExecution);
|
|
347
372
|
notifyActiveCell(notebook.activeCell.model);
|
|
373
|
+
notebook.model.contentChanged.connect(onContentChanged);
|
|
374
|
+
requestComputeExecSchedule();
|
|
348
375
|
}
|
|
349
|
-
else if (
|
|
350
|
-
waitingCells = new Set(
|
|
351
|
-
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);
|
|
352
379
|
newReadyCells = new Set([
|
|
353
380
|
...newReadyCells,
|
|
354
|
-
...
|
|
381
|
+
...payload.new_ready_cells,
|
|
355
382
|
]);
|
|
356
383
|
forcedReactiveCells = new Set([
|
|
357
384
|
...forcedReactiveCells,
|
|
358
|
-
...
|
|
385
|
+
...payload.forced_reactive_cells,
|
|
359
386
|
]);
|
|
360
|
-
waiterLinks =
|
|
361
|
-
readyMakerLinks =
|
|
387
|
+
waiterLinks = payload.waiter_links;
|
|
388
|
+
readyMakerLinks = payload.ready_maker_links;
|
|
362
389
|
cellPendingExecution = null;
|
|
363
|
-
const exec_mode =
|
|
390
|
+
const exec_mode = payload.exec_mode;
|
|
364
391
|
isReactivelyExecuting = isReactivelyExecuting || (exec_mode === 'reactive');
|
|
365
|
-
const flow_order =
|
|
366
|
-
const exec_schedule =
|
|
392
|
+
const flow_order = payload.flow_order;
|
|
393
|
+
const exec_schedule = payload.exec_schedule;
|
|
367
394
|
lastExecutionMode = exec_mode;
|
|
368
|
-
lastExecutionHighlights =
|
|
369
|
-
const lastExecutedCellId =
|
|
395
|
+
lastExecutionHighlights = payload.highlights;
|
|
396
|
+
const lastExecutedCellId = payload.last_executed_cell_id;
|
|
370
397
|
executedReactiveReadyCells.add(lastExecutedCellId);
|
|
371
|
-
const last_execution_was_error =
|
|
398
|
+
const last_execution_was_error = payload.last_execution_was_error;
|
|
372
399
|
if (!last_execution_was_error) {
|
|
400
|
+
let lastExecutedCellIdSeen = false;
|
|
373
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
|
+
}
|
|
374
408
|
if (cell.model.type !== 'code' || executedReactiveReadyCells.has(cell.model.id)) {
|
|
375
409
|
continue;
|
|
376
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
|
}
|