jupyterlab-ipyflow 0.0.178 → 0.0.180
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 +24 -14
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -43,6 +43,7 @@ class IpyflowSessionState {
|
|
|
43
43
|
this.cellParents = {};
|
|
44
44
|
this.cellChildren = {};
|
|
45
45
|
this.settings = {};
|
|
46
|
+
this.lastCellMetadataMap = null;
|
|
46
47
|
}
|
|
47
48
|
gatherCellMetadataAndContent() {
|
|
48
49
|
const cell_metadata_by_id = {};
|
|
@@ -70,20 +71,13 @@ class IpyflowSessionState {
|
|
|
70
71
|
let numFinished = 0;
|
|
71
72
|
for (const cell of cells) {
|
|
72
73
|
// if any of them fail, change the [*] to [ ] on subsequent cells
|
|
73
|
-
CodeCell.execute(cell, this.session).then((
|
|
74
|
-
var _a
|
|
75
|
-
if ((
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if ((_c = cell.promptNode.textContent) === null || _c === void 0 ? void 0 : _c.includes('[*]')) {
|
|
79
|
-
cell.setPrompt('');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
numFinished++;
|
|
74
|
+
CodeCell.execute(cell, this.session).then(() => {
|
|
75
|
+
var _a;
|
|
76
|
+
if ((_a = cell.promptNode.textContent) === null || _a === void 0 ? void 0 : _a.includes('[*]')) {
|
|
77
|
+
// can happen if a preceding cell errored
|
|
78
|
+
cell.setPrompt('');
|
|
85
79
|
}
|
|
86
|
-
if (numFinished === cells.length) {
|
|
80
|
+
if (++numFinished === cells.length) {
|
|
87
81
|
this.requestComputeExecSchedule();
|
|
88
82
|
}
|
|
89
83
|
});
|
|
@@ -507,6 +501,7 @@ const addUnsafeCellInteraction = (elem, linkedElems, cellsById, collapserFun, ev
|
|
|
507
501
|
attachCleanupListener(elem, evt, listener);
|
|
508
502
|
};
|
|
509
503
|
const connectToComm = (session, notebooks, notebook) => {
|
|
504
|
+
var _a, _b;
|
|
510
505
|
initSessionState(session.session.id);
|
|
511
506
|
const state = ipyflowState[session.session.id];
|
|
512
507
|
state.activeCell = notebook.activeCell;
|
|
@@ -530,10 +525,16 @@ const connectToComm = (session, notebooks, notebook) => {
|
|
|
530
525
|
notebook.model.contentChanged.disconnect(onContentChanged);
|
|
531
526
|
return;
|
|
532
527
|
}
|
|
528
|
+
const cell_metadata_by_id = state.gatherCellMetadataAndContent();
|
|
529
|
+
if (_.isEqual(cell_metadata_by_id, state.lastCellMetadataMap)) {
|
|
530
|
+
// fixes https://github.com/ipyflow/ipyflow/issues/145
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
state.lastCellMetadataMap = cell_metadata_by_id;
|
|
533
534
|
notebook.widgets.forEach(syncDirtiness);
|
|
534
535
|
comm.send({
|
|
535
536
|
type: 'notify_content_changed',
|
|
536
|
-
cell_metadata_by_id
|
|
537
|
+
cell_metadata_by_id,
|
|
537
538
|
});
|
|
538
539
|
}, 500);
|
|
539
540
|
const onExecution = (cell, args) => {
|
|
@@ -762,6 +763,11 @@ const connectToComm = (session, notebooks, notebook) => {
|
|
|
762
763
|
state.settings = payload.settings;
|
|
763
764
|
state.cellParents = payload.cell_parents;
|
|
764
765
|
state.cellChildren = payload.cell_children;
|
|
766
|
+
notebook.model.setMetadata('ipyflow', {
|
|
767
|
+
cell_parents: state.cellParents,
|
|
768
|
+
cell_children: state.cellChildren,
|
|
769
|
+
});
|
|
770
|
+
void notebooks.currentWidget.context.save();
|
|
765
771
|
state.waitingCells = new Set(payload.waiting_cells);
|
|
766
772
|
state.readyCells = new Set(payload.ready_cells);
|
|
767
773
|
if (state.numPendingForcedReactiveCounterBumps === 0) {
|
|
@@ -910,8 +916,12 @@ const connectToComm = (session, notebooks, notebook) => {
|
|
|
910
916
|
}
|
|
911
917
|
}
|
|
912
918
|
};
|
|
919
|
+
const ipyflow_metadata = notebook.model.getMetadata('ipyflow');
|
|
913
920
|
comm.open({
|
|
914
921
|
interface: 'jupyterlab',
|
|
922
|
+
cell_metadata_by_id: state.gatherCellMetadataAndContent(),
|
|
923
|
+
cell_parents: (_a = ipyflow_metadata === null || ipyflow_metadata === void 0 ? void 0 : ipyflow_metadata.cell_parents) !== null && _a !== void 0 ? _a : {},
|
|
924
|
+
cell_children: (_b = ipyflow_metadata === null || ipyflow_metadata === void 0 ? void 0 : ipyflow_metadata.cell_children) !== null && _b !== void 0 ? _b : {},
|
|
915
925
|
});
|
|
916
926
|
// return a disconnection handle
|
|
917
927
|
return () => {
|
package/package.json
CHANGED