Skip to content

Commit

Permalink
raw cells should not stay in a pending exec state (#9634)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Apr 12, 2022
1 parent 62748ab commit a2171fd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/2 Fixes/9633.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure `raw` cells do not stay in a pending execution state.
4 changes: 4 additions & 0 deletions src/notebooks/execution/cellExecution.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export class CellExecution implements IDisposable {
this.disposables
);
NotebookCellStateTracker.setCellState(cell, NotebookCellExecutionState.Idle);
const execution = CellExecutionCreator.get(cell);
if (this.canExecuteCell()) {
// This has been queued for execution, hence clear all the output.
// (possible solution for ) https://github.com/microsoft/vscode-jupyter/issues/7123
Expand All @@ -207,6 +208,9 @@ export class CellExecution implements IDisposable {
// void tempTask.end(undefined);
this.execution = CellExecutionCreator.getOrCreate(cell, this.controller);
NotebookCellStateTracker.setCellState(cell, NotebookCellExecutionState.Pending);
} else if (execution) {
execution.start();
execution.end(undefined);
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/notebooks/execution/cellExecutionCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class CellExecutionCreator {
static getOrCreate(cell: NotebookCell, controller: NotebookController) {
let cellExecution: NotebookCellExecutionWrapper | undefined;
const key = cell.document.uri.toString();
cellExecution = CellExecutionCreator._map.get(key);
cellExecution = this.get(cell);
if (!cellExecution) {
cellExecution = CellExecutionCreator.create(key, cell, controller);
} else {
Expand All @@ -105,6 +105,10 @@ export class CellExecutionCreator {
}
return cellExecution;
}
static get(cell: NotebookCell) {
const key = cell.document.uri.toString();
return CellExecutionCreator._map.get(key);
}

private static create(key: string, cell: NotebookCell, controller: NotebookController) {
const result = new NotebookCellExecutionWrapper(
Expand Down
20 changes: 20 additions & 0 deletions src/test/datascience/notebook/executionService.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,26 @@ suite('DataScience - VSCode Notebook - (Execution) (slow)', function () {
waitForTextOutput(cell, 'after fail', 0, false)
]);
});
test('Raw cells should not get executed', async () => {
await insertCodeCell('print(1234)', { index: 0 });
await insertCodeCell('Hello World', { index: 1, language: 'raw' });
await insertCodeCell('print(5678)', { index: 2 });

const [cell1, cell2, cell3] = vscodeNotebook.activeNotebookEditor!.document.getCells();
await Promise.all([
runAllCellsInActiveNotebook(),
waitForCellExecutionToComplete(cell1),
waitForTextOutput(cell1, '1234', 0, false),
waitForCellExecutionToComplete(cell3),
waitForTextOutput(cell3, '5678', 0, false)
]);

// Second cell should not have been executed.
assert.isEmpty(cell2.outputs, 'Second cell should not have any output');
assert.isUndefined(cell2.executionSummary?.executionOrder, 'Second cell should not have an execution order');
assert.isUndefined(cell2.executionSummary?.timing, 'Second cell should not have execution times');
assert.isUndefined(cell2.executionSummary?.success, 'Second cell should not have execution result');
});
test('Run whole document and test status of cells', async () => {
const cells = await insertRandomCells({ count: 4, addMarkdownCells: false });

Expand Down

0 comments on commit a2171fd

Please sign in to comment.