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

docs/notebook_validation.py: update nbconvert logs #2703

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mitchdz
Copy link
Collaborator

@mitchdz mitchdz commented Mar 6, 2025

Improve the timing logs for the docker container validation during nbconvert.

This is because in CI, the list of timings is printed after the nbconvert is done, so you see something like:

...
[NbConvertApp] Converting notebook applications/python/readout_error_mitigation.ipynb to notebook
[NbConvertApp] Writing 187307 bytes to applications/python/readout_error_mitigation.nbconvert.ipynb
[NbConvertApp] Converting notebook applications/python/deutsch_jozsa.ipynb to notebook
[NbConvertApp] Writing 10396 bytes to applications/python/deutsch_jozsa.nbconvert.ipynb
Time taken for nbconvert: 6.10 seconds
Time taken for nbconvert: 7.83 seconds
Time taken for nbconvert: 10.72 seconds
Time taken for nbconvert: 3.18 seconds
Time taken for nbconvert: 7.33 seconds
...

See: https://github.com/NVIDIA/cuda-quantum/actions/runs/13690948087/job/38285994246#step:5:1387

Which makes it hard to see what took a long time.

add the name of the notebook for the timing.

This is because in CI, the list of timings is printed
after the nbconvert is done, so you see something like:

[NbConvertApp] Converting notebook applications/python/readout_error_mitigation.ipynb to notebook
[NbConvertApp] Writing 187307 bytes to applications/python/readout_error_mitigation.nbconvert.ipynb
[NbConvertApp] Converting notebook applications/python/deutsch_jozsa.ipynb to notebook
[NbConvertApp] Writing 10396 bytes to applications/python/deutsch_jozsa.nbconvert.ipynb
Time taken for nbconvert: 6.10 seconds
Time taken for nbconvert: 7.83 seconds
Time taken for nbconvert: 10.72 seconds
Time taken for nbconvert: 3.18 seconds
Time taken for nbconvert: 7.33 seconds
Time taken for nbconvert: 6.19 seconds

Which makes it hard to see what took a long time.

Signed-off-by: Mitchell Dzurick <[email protected]>
@mitchdz mitchdz added the maintenance Work items to update and improve the code base label Mar 6, 2025
Copy link

copy-pr-bot bot commented Mar 6, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

print(f"Time taken for nbconvert: {elapsed:.2f} seconds")
print(
f"Time taken for nbconvert : {elapsed:.2f} seconds for '{notebook_filename}'"
)
os.remove(notebook_filename_out)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't we need to remove this _out file in the except block if there is an error while running nbconvert?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good idea. I think it won't help much for simply timing out but if an actual error occurs it could be nice to know how long it took to hit the error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh you mean remove the file itself, my brain for some reason was thinking you were asking for the timing as well for an error, which thinking about it could be helpful too :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

:). Yes, we can add finally block here (and add os.remove in it) which can clean this file.

Copy link
Collaborator

@sacpis sacpis left a comment

Choose a reason for hiding this comment

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

LGTM, just one change unrelated to this PR requested. Thanks @mitchdz.

@mitchdz
Copy link
Collaborator Author

mitchdz commented Mar 6, 2025

Let's hold off on merging this in, there's some higher priority PRs in the pipeline for release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Work items to update and improve the code base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants