-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add an option to show the cell outputs per second #116
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b9ef0a5
Show the executions per second calculated from the last execution time.
flaviomartins 61a9240
Improve description using a more precise wording.
flaviomartins cd6d9a3
Now shows the number of cell outputs per second.
flaviomartins 69303e7
Shorten the message displaying outputs/s
flaviomartins cca94f0
Further improve outputs per second message
flaviomartins 6b5bb0a
small fix to outputPerSecond option description
flaviomartins 771f5ac
add timing_outputs_outcomes.spec.ts for ui-tests
flaviomartins cb935d0
Do not test execution started again, remove unused import and cells
krassowski 009e7f9
Add changelog entry
krassowski d553ca0
Adjust cell index after removing unused cells
krassowski 3927b85
fix comparison of millis with seconds
flaviomartins 5d84534
clarify in the description that showOutputsPerSecond option displays the
flaviomartins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ export interface IExecuteTimeSettings { | |
showDate: boolean; | ||
historyCount: number; | ||
dateFormat: string; | ||
showOutputsPerSecond: boolean; | ||
} | ||
|
||
export default class ExecuteTimeWidget extends Widget { | ||
|
@@ -290,11 +291,13 @@ export default class ExecuteTimeWidget extends Widget { | |
if (isLikelyAborted) { | ||
msg = ''; | ||
} else if (endTime) { | ||
if ( | ||
this._settings.minTime <= | ||
differenceInMilliseconds(endTime, startTime) / 1000.0 | ||
) { | ||
const executionTimeMillis = differenceInMilliseconds( | ||
endTime, | ||
startTime | ||
); | ||
if (this._settings.minTime <= executionTimeMillis) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is a bug here - minTime is in s and now this is compared in ms There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the conversion back in a new commit. Thanks! |
||
const executionTime = getTimeDiff(endTime, startTime); | ||
const executionsPerSecond = 1000.0 / executionTimeMillis; | ||
const lastExecutionTime = executionTimeNode.getAttribute( | ||
PREV_DATA_EXECUTION_TIME_ATTR | ||
); | ||
|
@@ -324,6 +327,15 @@ export default class ExecuteTimeWidget extends Widget { | |
msg += ` at ${getTimeString(endTime, this._settings.dateFormat)}`; | ||
} | ||
msg += ` in ${executionTime}`; | ||
|
||
const numberOfOutputs = cell.model.outputs.length; | ||
if (this._settings.showOutputsPerSecond && numberOfOutputs > 0) { | ||
const outputsPerSecond = executionsPerSecond / numberOfOutputs; | ||
msg += `, ${numberOfOutputs} output${ | ||
numberOfOutputs === 1 ? '' : 's' | ||
}`; | ||
msg += ` at ${outputsPerSecond.toFixed(2)}/s`; | ||
} | ||
} | ||
} else if (startTime) { | ||
if (this._settings.showLiveExecutionTime) { | ||
|
@@ -429,6 +441,9 @@ export default class ExecuteTimeWidget extends Widget { | |
); | ||
} | ||
|
||
this._settings.showOutputsPerSecond = settings.get('showOutputsPerSecond') | ||
.composite as boolean; | ||
|
||
const cells = this._panel.context.model.cells; | ||
if (this._settings.enabled) { | ||
cells.changed.connect(this.updateConnectedCell); | ||
|
@@ -513,5 +528,6 @@ export default class ExecuteTimeWidget extends Widget { | |
showDate: true, | ||
historyCount: 5, | ||
dateFormat: 'yyy-MM-dd HH:mm:ss', | ||
showOutputsPerSecond: false, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "98ce2d4e-e422-40ea-aa89-5adabbb8d0f0", | ||
"metadata": {}, | ||
"source": [ | ||
"Notes:\n", | ||
"- Each cells is self-contained to allow parallel testing.\n", | ||
"- Cell indices are used in tests." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "f28cb5ea-94a4-47d3-9860-4cf20a29d690", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Last executed at with outputs:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3cfa2867-8f80-4793-9a4d-d773b06136e1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for i in range(5):\n", | ||
" display(1)\n", | ||
" sleep(0.01)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { expect, galata, test } from '@jupyterlab/galata'; | ||
import { openNotebook, cleanup, maskedScreenshot } from './utils'; | ||
|
||
const SETTINGS_ID = 'jupyterlab-execute-time:settings'; | ||
|
||
test.describe('Timing outcomes with ', () => { | ||
test.beforeEach(openNotebook('Timing_outputs_outcomes.ipynb')); | ||
test.afterEach(cleanup); | ||
// Disable flashing highlight for screenshot consistency | ||
test.use({ | ||
mockSettings: { | ||
...galata.DEFAULT_SETTINGS, | ||
[SETTINGS_ID]: { | ||
...galata.DEFAULT_SETTINGS[SETTINGS_ID], | ||
highlight: false, | ||
showOutputsPerSecond: true, | ||
}, | ||
}, | ||
}); | ||
|
||
test('"Last executed at" state', async ({ page }) => { | ||
const cell = await page.notebook.getCell(2); | ||
|
||
// Execute cell and wait for it to complete | ||
await page.notebook.runCell(2); | ||
|
||
const widget = await cell.waitForSelector('.execute-time'); | ||
expect(await widget.textContent()).toContain('Last executed at'); | ||
expect(await widget.textContent()).toContain('outputs at'); | ||
expect(await maskedScreenshot(widget)).toMatchSnapshot( | ||
'last-executed-outputs.png' | ||
); | ||
}); | ||
}); |
Binary file added
BIN
+3.55 KB
...tests/timing_outputs_outcomes.spec.ts-snapshots/last-executed-outputs-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear from the name if this is in real time. How about: "After a cell has finished running, show the outputs per second calculated from the last cell execution time and number of outputs."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Updated the description with your copy.