-
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
Conversation
Fixed the eslint/prettier error/warnings. Rebased on master. |
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.
Thank you, it looks CI is green! It seems that the numerator here is always fixed to 1 because each time there is only one execution. I am slightly worried that this might confuse users initially: they may expect it to count some actual execution cycles, like iterations or operations, which is rather difficult to do in a language-agnostic way in this extension. At a minimum I would recommend using a more precise wording.
Alternatively, slight variations of this PR with a non-constant numerator could include counting the number of outputs/time, or number of output updates/time.
schema/settings.json
Outdated
"showExecutionsPerSecond": { | ||
"type": "boolean", | ||
"title": "Show Executions Per Second", | ||
"description": "Show the executions per second calculated from the last execution time.", |
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.
I think this should be explicit that number of executions is always one.
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.
I have changed this to explicitly say Cell Executions Per Second, but I understand it might not resolve the issue completely.
I'm in favour of outputs/time or updates/time (keeping it language-agnostic).
@krassowski can it be done?
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.
@krassowski do tou know if there is a listener/hook exposed to jupyterlab extensions I can use? (for each write to stdout/output)
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.
There is a outputLengthChanged
signal in output area which you should be able to access via cell.outputArea.outputLengthChanged
.
@flaviomartins thanks for the contribution. Can you share a gif? Also, did you sign the CLA mentioned here? |
Here is a GIF: Signed the CLA today. |
@flaviomartins it looks like the lint is failing |
It should work now. Forgot a simple: jlpm run eslint:check |
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.
Tested locally, works well! I left a small suggestion on reducing the length of the text. One question, @flaviomartins would you be interested in adding a test case for this as well to ensure it works as other changes are made to the codebase in the future?
This test case could be a slight modification of:
jupyterlab-execute-time/ui-tests/tests/timing_outcomes.spec.ts
Lines 33 to 42 in 9c56a05
test('"Last executed at" state', async ({ page }) => { | |
const cell = await page.notebook.getCell(4); | |
// Execute cell and wait for it to complete | |
await page.notebook.runCell(4); | |
const widget = await cell.waitForSelector('.execute-time'); | |
expect(await widget.textContent()).toContain('Last executed at'); | |
expect(await maskedScreenshot(widget)).toMatchSnapshot('last-executed.png'); | |
}); |
but after toggling the settings for showing the outputs/second:
jupyterlab-execute-time/ui-tests/tests/timing_outcomes.spec.ts
Lines 10 to 11 in 9c56a05
test.use({ | |
mockSettings: { |
src/ExecuteTimeWidget.ts
Outdated
const numberOfOutputs = cell.model.outputs.length; | ||
if (this._settings.showOutputsPerSecond && numberOfOutputs > 0) { | ||
const outputsPerSecond = executionsPerSecond / numberOfOutputs; | ||
msg += ` and generated ${numberOfOutputs} output(s)`; |
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.
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.
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.
@krassowski I am not familiar with ui-tests. How can we get something like last-executed.png?
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 will be auto-generated when running the test for the first time: https://github.com/deshaw/jupyterlab-execute-time/tree/master/ui-tests#run-the-tests
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.
But in general I would just push the code and download the artifacts from CI
Added a new notebook for ui-tests since the |
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.
Thank you @flaviomartins, looks good to me!
src/ExecuteTimeWidget.ts
Outdated
endTime, | ||
startTime | ||
); | ||
if (this._settings.minTime <= executionTimeMillis) { |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I added the conversion back in a new commit. Thanks!
schema/settings.json
Outdated
"showOutputsPerSecond": { | ||
"type": "boolean", | ||
"title": "Show Outputs Per Second", | ||
"description": "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.
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.
metric after the cell is executed and not while the cell is running
Thanks for the PR! |
Closes #115
The cell outputs per second calculated using the last execution time and
cell.model.outputs.length
.