spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
450 stars 130 forks source link

timings & timestamps for input cells #686

Open deeenes opened 1 year ago

deeenes commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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