jtpio / ipylab

Control JupyterLab from Python Notebooks with Jupyter Widgets 🧪 ☢️ 🐍

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Previous cell execution

djangoliv opened this issue · comments

Is it possible to run the previous notebook cell with ipylab?

I have a notebook with a cell with a button widget that runs unittests on the code in the cell above.

So it would be great to programmatically run the latest version of the code I want to test (which is in the previous cell) before.

Regards

Looking at the list of available commands, maybe a combination of notebook:move-cursor-up and notebook:run-cell would work?

https://jupyterlab.readthedocs.io/en/latest/user/commands.html#commands-list

Looking at the list of available commands, maybe a combination of notebook:move-cursor-up and notebook:run-cell would work?

https://jupyterlab.readthedocs.io/en/latest/user/commands.html#commands-list

that make sense

Thanks @jtpio

It's actually a good idea. However, I can't get it to work in a simple way.

When I execute the second cell, the first cell is indeed executed (twice even, I don't know why) but the result is still not usable.

image

would you try notebook:run-all-below after cursor up?

Thanks @jtpio

It's actually a good idea. However, I can't get it to work in a simple way.

When I execute the second cell, the first cell is indeed executed (twice even, I don't know why) but the result is still not usable.

image

@erkin98 thank you for participating in the discussion

There are several problems with this idea:

  • The code in the second cell should not be re-executed, otherwise the code will loop.
  • But above all, I don't want to run my entire notebook which potentially contains other cells underneath.