computationalmodelling / nbval

A py.test plugin to validate Jupyter notebooks
Other
444 stars 51 forks source link

Is it possible to set time for running each notebook cell with nbval? #151

Open marimeireles opened 4 years ago

marimeireles commented 4 years ago

Hello nbval folks, first of all thanks a lot for your plugin! :) We've decided to use it on ipycytoscape but we found a problem. Currently we're having the following error on MacOS:

Notebook cell execution failed
Cell 2: Timeout of 5 seconds exceeded waiting for output.

The way libs like nbconvert are dealing with this is allowing the user to pass a flag that tells jupyter to wait an X amount of time for the cell finish loading with flags like this one: --ExecutePreprocessor.timeout=600 , docs.

Is it possible to do something similar on nbval?

Thanks a lot, please let me know if I can help somehow :)

vidartf commented 4 years ago

So my understanding of this error is that it is slightly different than the nbconvert case. In this case:

  1. The cell execute request is sent.
  2. The execution is processed.
  3. The execute_reply message is received.
  4. All further messages are awaited with a hard-coded timeout of 5 seconds per message receipt (until an execution_state: idle message is received).

For steps 1-3, a different timeout is used (which is configurable, via --nbval-cell-timeout which defaults to 2000 seconds).

I'm not entirely sure what is going on for the messages (after execution has finished) to take so long to send/process.

We could certainly make this configurable, but I just want to make sure it is the right fix. For now, could you try increasing this value in your local copy to A: see that it actually fixes the problem, and secondarily B: give some indication of how long is needed?

https://github.com/computationalmodelling/nbval/blob/3597e0bfd96c8b52d9f4e94abbe1cbb3887dcf25/nbval/plugin.py#L336

Borda commented 3 years ago

I was checking the --nbval-cell-timeout and it seems to have no effect, even with setting value to 300 I get the same error

Notebook cell execution failed
Cell X: Timeout of 5 seconds exceeded waiting for output.
jhlegarreta commented 2 years ago

According to the JupyterLab folks, timeout is not standard metadata, and it is being ignored: https://github.com/jupyterlab/jupyterlab/issues/12018

See specifically https://github.com/jupyterlab/jupyterlab/issues/12018#issuecomment-1046571679

Is there any plan to fix it or support it?

We're interested in continuing to use nbval within a CI context due to its ability to check the outputs stored in our notebooks. Many of the cells in our notebooks have large execution times, and thus we are stuck due to the timeout flag being ignored.

mikemhenry commented 6 months ago

@jhlegarreta Does --nbval-cell-timeout=3000 fix your issue? (2000 is the default (in seconds) so you might need more time depending on how long it takes)

jhlegarreta commented 5 months ago

@mikemhenry thanks for the suggestion. Here is the attempt: https://github.com/carpentries-incubator/SDC-BIDS-dMRI/pull/255

I'll keep an eye on it to see if the flag is being taken into account.

Edit: CI's are failing due to an unrelated issue. It will be some time before I get a chance to have a look at this.