Skip to content

Commit

Permalink
Merge pull request #7578 from mlucool/global-track-timing
Browse files Browse the repository at this point in the history
Allow for a global track timing setting
  • Loading branch information
saulshanabrook committed Dec 5, 2019
2 parents 5e68c8a + ad4c5a5 commit 69dbd5a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 30 deletions.
2 changes: 2 additions & 0 deletions packages/cells/src/widget.ts
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions packages/notebook-extension/schema/tracker.json
Expand Up @@ -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,
Expand Down
17 changes: 2 additions & 15 deletions packages/notebook-extension/src/index.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -1922,7 +1910,6 @@ function populatePalette(
CommandIDs.deselectAll,
CommandIDs.clearAllOutputs,
CommandIDs.toggleAllLines,
CommandIDs.toggleRecordTiming,
CommandIDs.editMode,
CommandIDs.commandMode,
CommandIDs.changeKernel,
Expand Down
15 changes: 1 addition & 14 deletions packages/notebook/src/actions.tsx
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 7 additions & 1 deletion packages/notebook/src/widget.ts
Expand Up @@ -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
};

/**
Expand Down

0 comments on commit 69dbd5a

Please sign in to comment.