diff --git a/packages/cells/src/widget.ts b/packages/cells/src/widget.ts index bb56dc8931e7..aef57c35cae5 100644 --- a/packages/cells/src/widget.ts +++ b/packages/cells/src/widget.ts @@ -1091,6 +1091,8 @@ export namespace CodeCell { return true; }; cell.outputArea.future.registerMessageHook(recordTimingHook); + } else { + model.metadata.delete('execution'); } // Save this execution's future so we can compare in the catch below. future = cell.outputArea.future; diff --git a/packages/notebook-extension/schema/tracker.json b/packages/notebook-extension/schema/tracker.json index bc75cb91b87b..a52b78848175 100644 --- a/packages/notebook-extension/schema/tracker.json +++ b/packages/notebook-extension/schema/tracker.json @@ -352,6 +352,12 @@ "description": "Whether to be able to scroll so the last cell is at the top of the panel", "type": "boolean", "default": true + }, + "recordTiming": { + "title": "Recording timing", + "description": "Should timing data be recorded in cell metadata", + "type": "boolean", + "default": false } }, "additionalProperties": false, diff --git a/packages/notebook-extension/src/index.ts b/packages/notebook-extension/src/index.ts index 2dc2c0bdeacc..1137aa0cbb9f 100644 --- a/packages/notebook-extension/src/index.ts +++ b/packages/notebook-extension/src/index.ts @@ -177,8 +177,6 @@ namespace CommandIDs { export const toggleAllLines = 'notebook:toggle-all-cell-line-numbers'; - export const toggleRecordTiming = 'notebook:toggle-record-timing'; - export const undoCellAction = 'notebook:undo-cell-action'; export const redoCellAction = 'notebook:redo-cell-action'; @@ -631,7 +629,8 @@ function activateNotebookHandler( factory.editorConfig = { code, markdown, raw }; factory.notebookConfig = { scrollPastEnd: settings.get('scrollPastEnd').composite as boolean, - defaultCell: settings.get('defaultCell').composite as nbformat.CellType + defaultCell: settings.get('defaultCell').composite as nbformat.CellType, + recordTiming: settings.get('recordTiming').composite as boolean }; factory.shutdownOnClose = settings.get('kernelShutdown') .composite as boolean; @@ -1560,17 +1559,6 @@ function addCommands( }, isEnabled }); - commands.addCommand(CommandIDs.toggleRecordTiming, { - label: 'Toggle Recording Cell Timing', - execute: args => { - const current = getCurrent(args); - - if (current) { - return NotebookActions.toggleRecordTiming(current.content); - } - }, - isEnabled - }); commands.addCommand(CommandIDs.commandMode, { label: 'Enter Command Mode', execute: args => { @@ -1922,7 +1910,6 @@ function populatePalette( CommandIDs.deselectAll, CommandIDs.clearAllOutputs, CommandIDs.toggleAllLines, - CommandIDs.toggleRecordTiming, CommandIDs.editMode, CommandIDs.commandMode, CommandIDs.changeKernel, diff --git a/packages/notebook/src/actions.tsx b/packages/notebook/src/actions.tsx index 97f70bb82291..8c61047cdf6a 100644 --- a/packages/notebook/src/actions.tsx +++ b/packages/notebook/src/actions.tsx @@ -1021,19 +1021,6 @@ export namespace NotebookActions { Private.handleState(notebook, state); } - /** - * Toggle whether to record cell timing execution. - * - * @param notebook - The target notebook widget. - */ - export function toggleRecordTiming(notebook: Notebook): void { - if (!notebook.model) { - return; - } - const currentValue = notebook.model.metadata.get('record_timing') || false; - notebook.model.metadata.set('record_timing', !currentValue); - } - /** * Clear the code outputs of the selected cells. * @@ -1562,7 +1549,7 @@ namespace Private { if (session) { return CodeCell.execute(cell as CodeCell, session, { deletedCells: notebook.model.deletedCells, - recordTiming: notebook.model.metadata.get('record_timing') || false + recordTiming: notebook.notebookConfig.recordTiming }) .then(reply => { notebook.model.deletedCells.splice( diff --git a/packages/notebook/src/widget.ts b/packages/notebook/src/widget.ts index d1c3e1edae5a..3c842a71485f 100644 --- a/packages/notebook/src/widget.ts +++ b/packages/notebook/src/widget.ts @@ -759,13 +759,19 @@ export namespace StaticNotebook { * The default type for new notebook cells. */ defaultCell: nbformat.CellType; + + /** + * Should timing be recorded in metadata + */ + recordTiming: boolean; } /** * Default configuration options for notebooks. */ export const defaultNotebookConfig: INotebookConfig = { scrollPastEnd: true, - defaultCell: 'code' + defaultCell: 'code', + recordTiming: false }; /**