38

In jupyter notebook, I can configure an automatic cell timing with nbextensions, the result is like so:

jupyter_notebook

How can I do this in jupyter lab? I didn't find any extensions that do a similar thing.

Obs.: I know that a similar result can be achieved with %%time magic, but I want it to be automatic, so I don't have to place the magic function at the beginning of each cell.

Braiam
  • 1
  • 11
  • 47
  • 78
Danilo Filippo
  • 762
  • 1
  • 6
  • 12
  • If you don't mind to code it on your own, you could use post and pre excute hooks, like in this answer: https://stackoverflow.com/a/50648266/6646912 – krassowski Jul 02 '19 at 20:31
  • Official thread: https://github.com/jupyterlab/jupyterlab/issues/3320 Does this help? – marc-cejalvo Mar 09 '20 at 09:18

4 Answers4

51

Requirement

JupyterLab >= 2.0.2

enter image description here

Let's move step by step

Extension available for JupyterLab is

jupyterlab-execute-time

First enable Extension Manager

enter image description here

After enabling you see new button in side task bar at the end "Extension Manager"

You can also enable it with the following steps:

  1. Go into advanced settings editor.
  2. Open the Extension Manager section.
  3. Add the entry “enabled”: true.
  4. Save the settings. If prompted whether you are sure, read the warning, and click “Enable” if you are still sure. Once enabled, you should see a new tab appear in the left sidebar enter image description here

By default, the disclaimer is not acknowledged. enter image description here

As the disclaimer is not acknowledged, you can search for an extension, but can not install it (no install button is available). enter image description here

To install an extension, you first have to explicitly acknowledge the disclaimer. Once done, this will remain across sessions and the user would not have to check it again.

enter image description here

Finding Extension

enter image description here

search jupyterlab-execute-time

Install Enable

After enable you have to Rebuild it: A small popup window open on it click on Rebulid;

then you have to restart kernel

Still you find you will not able to see what you want :

Last thing

Note: for this to show anything, you need to enable cell timing in the notebook via Settings->Advanced Settings Editor->Notebook: {"recordTiming": true}

Advanced Settings Editor

enter image description here

finally "recordTiming"=true

enter image description here

and save it at right end!

Donald Seinen
  • 4,179
  • 5
  • 15
  • 40
Welcome_back
  • 1,245
  • 12
  • 18
  • 8
    Hi, thank you for the detailed explanation. I'm getting the error: ``` An error occurred installing jupyterlab-execute-time. Error message: The extension "jupyterlab-execute-time" does not yet support the current version of JupyterLab. Conflicting Dependencies: JupyterLab Extension Package >=3.0.4 <3.1.0 >=2.0.2 <3.0.0 @jupyterlab/application >=3.0.4 <3.1.0 >=2.0.2 <3.0.0 @jupyterlab/notebook >=3.0.2 <3.1.0 >=2.0.1 <3.0.0 @jupyterlab/settingregistry ``` any idea what I can do? – Leonid Ganeline Feb 13 '21 at 00:35
  • @LeonidGaneline it is not working for your jupyter-lab version. It supports <3.0.0 so you can use with downgraded jupyter-lab. I hope they fix. – tyasird Mar 11 '21 at 13:06
  • As of 4/2/21, this is working for JupyterLab v3.0.12. – Jadon Apr 02 '21 at 14:46
  • 1
    In my case, the last step: refresh the browser, so the jupyterlab can rebuild and show the timing message. – Ziu May 25 '21 at 07:13
  • I get the same kind of error (12/7/21) as Leonid did on v3.0.14. It lists the dependencies as >= 3.0.9 and >=3.0.5, though, so I don't understand how this was working for Jadon's v3.012. – Semiclassical Dec 07 '21 at 18:00
  • It would be great to be able to add the `{"recordTiming": true}` line from the terminal directly instead of from the GUI – Jon Cardoso-Silva Apr 06 '22 at 11:02
  • won't work for jupyter-lab > 3.2. Extension Installation Error An error occurred installing jupyterlab-execute-time. Error message: The extension "jupyterlab-execute-time" does not yet support the current version of JupyterLab. Conflicting Dependencies: JupyterLab Extension Package >=3.2.1 <3.3.0 >=2.0.2 <3.0.0 @jupyterlab/application >=3.2.1 <3.3.0 >=2.0.2 <3.0.0 @jupyterlab/notebook >=3.2.1 <3.3.0 >=2.0.1 <3.0.0 @jupyterlab/settingregistry – Travis Jul 24 '22 at 07:14
  • 2
    For people getting the error message regarding noje js installation missing, try installing the execute-time via pip , it worked for me. >>pip install jupyterlab_execute_time – Pedro Alonso Aug 29 '22 at 23:40
  • Answer is very verbose, at least it should mention the jupyterlab-execute-time extension name in the beginning. – ei-grad Apr 21 '23 at 10:30
  • Also answer is outdated since jupyterlab 3.0 was released more than 2 years ago. – ei-grad Apr 21 '23 at 10:37
28

Appreciated the answer of @welcome_back, but you don't have to mess with the jupyter extension manager especially if you are concerned about that warnings.

Enable execution time in 3 steps

  • install this package !pip install jupyterlab_execute_time
  • reload the jupyterlab page (no need to shut down)
  • go to notebook section in jupyterlab advanced setting and paste this code
{"recordTiming": true}
And voila!! you are done!
tozCSS
  • 5,487
  • 2
  • 34
  • 31
Darkstar Dream
  • 1,649
  • 1
  • 12
  • 23
  • 2
    Works for me, just to add that, the last step is added in the json view of the setting page, not the GUI page. – Diansheng Jan 03 '23 at 09:02
  • 2
    This legit works. For the last step, you can also enable it from GUI by going to ```Advance Settings Editor``` > `Execute Time`, then check the `Enabled` checkbox. – Joker Jan 05 '23 at 20:34
16

No need for an extension.

Simply use (at any cell):

try:
    %load_ext autotime
except:
    !pip install ipython-autotime
    %load_ext autotime

To stop cell timing, use:

%unload_ext autotime
Zvi
  • 2,354
  • 2
  • 26
  • 37
3

When trying to install for jypyter lab >= 3.0.0 use:

pip install jupyterlab_execute_time

LucyDrops
  • 539
  • 5
  • 15