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

timings & timestamps for input cells #686

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

Conversation

deeenes
Copy link

@deeenes deeenes commented Dec 4, 2022

  • This patch makes it possible to include under each cell the time of the last run and how long the execution took
  • It does the same as the execute_time extension for Jupyter Notebook: https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/execute_time/readme.html
  • The timings are taken from cell.metadata.ExecuteTime, I don't know if it exists in notebooks that don't use the extension
  • The nbsphinx_timings option enables or disables showing the timings (not sure where to document it)

The HTML output looks like this (haven't tested LaTeX):

nbsphinx_timings

Having the timings is highly helpful for the readers as they know what to expect, how long does it take to run the code, and tells something about the age of the content (e.g. it's too new or too old to run with a certain version, etc).

@mgeier
Copy link
Member

mgeier commented Dec 4, 2022

Thanks for this PR!

How is this related to https://github.com/deshaw/jupyterlab-execute-time?

Will this work with notebook v7?

The timings are taken from cell.metadata.ExecuteTime, I don't know if it exists in notebooks that don't use the extension

I guess not, I've never seen it.

The nbsphinx_timings option enables or disables showing the timings (not sure where to document it)

I think this should be documented in a new notebook, maybe in this section: https://nbsphinx.readthedocs.io/executing-notebooks.html

It would be good if only that one notebook shows the timings, the rest of the docs should stay unchanged.

The actual option should also be mentioned at https://nbsphinx.readthedocs.io/en/0.8.10/usage.html#nbsphinx-Configuration-Values

(haven't tested LaTeX)

We will see once this is part of the docs.
The PDF should be generated automatically by CI, but currently this seems to be broken (due to an unrelated problem, which I'll look into once I have time).

[...] and tells something about the age of the content (e.g. it's too new or too old to run with a certain version, etc).

I think there are better ways to convey this information.
For example, you could include the versions of the used modules in the notebook.
If you want to know the date of the last change in a notebook (and if you happen to use Git), I can recommend my own extension https://github.com/mgeier/sphinx-last-updated-by-git.

Anyway, that's not really that important for the issue at hand.

@deeenes
Copy link
Author

deeenes commented Dec 5, 2022

Thanks Matthias for the reply,

Thanks for this PR!

How is this related to https://github.com/deshaw/jupyterlab-execute-time?

Will this work with notebook v7?

This works with the classic Jupyter Notebook extension, but can be adapted easily to the extension above, only have to check how it records the timestamps in the ipynb data structure.

The timings are taken from cell.metadata.ExecuteTime, I don't know if it exists in notebooks that don't use the extension

I guess not, I've never seen it.

The nbsphinx_timings option enables or disables showing the timings (not sure where to document it)

I think this should be documented in a new notebook, maybe in this section: https://nbsphinx.readthedocs.io/executing-notebooks.html

It would be good if only that one notebook shows the timings, the rest of the docs should stay unchanged.

The actual option should also be mentioned at https://nbsphinx.readthedocs.io/en/0.8.10/usage.html#nbsphinx-Configuration-Values

(haven't tested LaTeX)

We will see once this is part of the docs. The PDF should be generated automatically by CI, but currently this seems to be broken (due to an unrelated problem, which I'll look into once I have time).

Cool, maybe it's easier for you to edit the docs, or I can give it a try if you want

[...] and tells something about the age of the content (e.g. it's too new or too old to run with a certain version, etc).

I think there are better ways to convey this information. For example, you could include the versions of the used modules in the notebook. If you want to know the date of the last change in a notebook (and if you happen to use Git), I can recommend my own extension https://github.com/mgeier/sphinx-last-updated-by-git.

Sure, a plugin for this (and support in nbsphinx) would be great, just like the sessionInfo in R.

Anyway, that's not really that important for the issue at hand.

@mgeier
Copy link
Member

mgeier commented Dec 6, 2022

only have to check how it records the timestamps in the ipynb data structure.

Yes, please do that. I hope the two extensions are compatible.

maybe it's easier for you to edit the docs, or I can give it a try if you want

I will try to fix the CI error (which is probably related to #687), but you should modify the docs for your new feature. The docs are at the same time tests to check if the feature works, so they should be updated together with the implementation of the feature.

@mgeier
Copy link
Member

mgeier commented Dec 23, 2022

I've merged #688, now CI should work.

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

Successfully merging this pull request may close these issues.

2 participants