Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes
  • Loading branch information
DonJayamanne committed Sep 25, 2020
commit 6ecb5f5fd8f45ab913f9a867630e1fb98cc86eb3
3 changes: 1 addition & 2 deletions src/client/datascience/jupyter/kernels/cellExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ export class CellExecution {

await updateCellExecutionTimes(this.editor, this.cell, {
startTime: this.cell.metadata.runStartTime,
lastRunDuration: this.stopWatch.elapsedTime,
duration: this.cell.metadata.lastRunDuration
lastRunDuration: this.stopWatch.elapsedTime
});

// If there are any errors in the cell, then change status to error.
Expand Down
15 changes: 11 additions & 4 deletions src/client/datascience/notebook/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,12 @@ export async function clearCellForExecution(editor: NotebookEditor, cell: Notebo
export async function updateCellExecutionTimes(
editor: NotebookEditor,
cell: NotebookCell,
times?: { startTime?: number; duration?: number; lastRunDuration?: number }
times?: { startTime?: number; lastRunDuration?: number }
) {
const cellIndex = cell.notebook.cells.indexOf(cell);

if (!times || !times.duration || !times.startTime) {
if (!times || !times.lastRunDuration || !times.startTime) {
// Based on feedback from VSC, its best to clone these objects when updating them.
const cellMetadata = cloneDeep(cell.metadata);
let updated = false;
if (cellMetadata.custom?.metadata?.vscode?.start_execution_time) {
Expand All @@ -380,16 +381,22 @@ export async function updateCellExecutionTimes(
updated = true;
}
if (updated) {
await editor.edit((edit) => edit.replaceCellMetadata(cellIndex, { ...cellMetadata }));
await editor.edit((edit) =>
edit.replaceCellMetadata(cellIndex, {
...cellMetadata
})
);
}
return;
}

const startTimeISO = new Date(times.startTime).toISOString();
const endTimeISO = new Date(times.startTime + times.duration).toISOString();
const endTimeISO = new Date(times.startTime + times.lastRunDuration).toISOString();
// Based on feedback from VSC, its best to clone these objects when updating them.
const customMetadata = cloneDeep(cell.metadata.custom || {});
customMetadata.metadata = customMetadata.metadata || {};
customMetadata.metadata.vscode = customMetadata.metadata.vscode || {};
// We store it in the metadata so we can display this when user opens a notebook again.
customMetadata.metadata.vscode.end_execution_time = endTimeISO;
customMetadata.metadata.vscode.start_execution_time = startTimeISO;
const lastRunDuration = times.lastRunDuration ?? cell.metadata.lastRunDuration;
Expand Down