Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for a global track timing setting #7578

Merged
merged 3 commits into from Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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