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

Add an option to show the cell outputs per second #116

Merged
merged 12 commits into from
Apr 26, 2024
Merged

Add an option to show the cell outputs per second #116

merged 12 commits into from
Apr 26, 2024

Conversation

flaviomartins
Copy link
Contributor

@flaviomartins flaviomartins commented Mar 27, 2024

Closes #115

The cell outputs per second calculated using the last execution time and cell.model.outputs.length.

@flaviomartins
Copy link
Contributor Author

Fixed the eslint/prettier error/warnings. Rebased on master.

Copy link
Collaborator

@krassowski krassowski left a 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.

"showExecutionsPerSecond": {
"type": "boolean",
"title": "Show Executions Per Second",
"description": "Show the executions per second calculated from the last execution time.",
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

@flaviomartins flaviomartins Apr 9, 2024

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)

Copy link
Collaborator

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.

@mlucool
Copy link
Member

mlucool commented Apr 2, 2024

@flaviomartins thanks for the contribution. Can you share a gif?

Also, did you sign the CLA mentioned here?

@flaviomartins
Copy link
Contributor Author

@flaviomartins thanks for the contribution. Can you share a gif?

Also, did you sign the CLA mentioned here?

Here is a GIF:

output

Signed the CLA today.

@krassowski krassowski self-requested a review April 9, 2024 16:19
@flaviomartins
Copy link
Contributor Author

Here is a GIF:

output

@flaviomartins flaviomartins changed the title Create an option to show the cell executions per second calculated using the last execution time. Create an option to show the cell outputs per second calculated using the last execution time and cell.model.outputs.length Apr 11, 2024
@krassowski
Copy link
Collaborator

@flaviomartins it looks like the lint is failing

@flaviomartins
Copy link
Contributor Author

@flaviomartins it looks like the lint is failing

It should work now. Forgot a simple: jlpm run eslint:check

Copy link
Collaborator

@krassowski krassowski left a 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:

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:

test.use({
mockSettings: {

const numberOfOutputs = cell.model.outputs.length;
if (this._settings.showOutputsPerSecond && numberOfOutputs > 0) {
const outputsPerSecond = executionsPerSecond / numberOfOutputs;
msg += ` and generated ${numberOfOutputs} output(s)`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting a bit long:

image

Can you modify this line to only append "s" when the number of outputs is >1? This will also remove the parentheses making it shorter in both cases.

additional idea: "and generated" could be replaced by shorter "displaying"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. It looks like this now. Much shorter 👍

image

Copy link
Contributor Author

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?

Copy link
Collaborator

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

Copy link
Collaborator

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

@flaviomartins
Copy link
Contributor Author

flaviomartins commented Apr 24, 2024

Added a new notebook for ui-tests since the Timing_outcomes.ipynb cells don't produce any output and the display of outputs per second only happens when the numberOfOutputs > 0.

@krassowski krassowski changed the title Create an option to show the cell outputs per second calculated using the last execution time and cell.model.outputs.length Create an option to show the cell outputs per second Apr 26, 2024
@krassowski krassowski added the enhancement New feature or request label Apr 26, 2024
@krassowski krassowski changed the title Create an option to show the cell outputs per second Add an option to show the cell outputs per second Apr 26, 2024
Copy link
Collaborator

@krassowski krassowski left a 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!

endTime,
startTime
);
if (this._settings.minTime <= executionTimeMillis) {
Copy link
Member

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

Copy link
Contributor Author

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!

"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.",
Copy link
Member

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."

Copy link
Contributor Author

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.

@mlucool mlucool merged commit 7ebb8dc into deshaw:master Apr 26, 2024
3 checks passed
@mlucool
Copy link
Member

mlucool commented Apr 26, 2024

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display cell Outputs-per-Second metric
3 participants