nbgrader icon indicating copy to clipboard operation
nbgrader copied to clipboard

c.ExecutePreprocessor.timeout does not work in config

Open luchungi opened this issue 4 years ago • 6 comments

Operating system

Windows 10

nbgrader --version

0.6.2

jupyterhub --version (if used with JupyterHub)

Nil

jupyter notebook --version

6.3.0

Expected behavior

Setting c.ExecutePreprocessor.timeout in config should change validation timeout window

Actual behavior

Setting c.ExecutePreprocessor.timeout to None or another other number has no effect on the default 30s

Additional info

I have looked at both issues #1004 and #1075 but nothing works

luchungi avatar Jul 04 '21 06:07 luchungi

I managed to set the timeout to 600s via nbgrader validate --Execute.timeout=600 and in the config file via c.Execute.timeout = 600.

See also

# nbgrader --help-all | grep -A16 Execute.timeout=
--Execute.timeout=<Int>
    Default: 30
    The time to wait (in seconds) for output from executions. If a cell
    execution takes longer, an exception (TimeoutError on python 3+,
    RuntimeError on python 2) is raised.
    `None` or `-1` will disable the timeout. If `timeout_func` is set, it
    overrides `timeout`.
--Execute.timeout_func=<Any>
    Default: None
    A callable which, when given the cell source as input, returns the time to
    wait (in seconds) for output from cell executions. If a cell execution takes
    longer, an exception (TimeoutError on python 3+, RuntimeError on python 2)
    is raised.
    Returning `None` or `-1` will disable the timeout for the cell. Not setting
    `timeout_func` will cause the preprocessor to default to using the `timeout`
    trait for all cells. The `timeout_func` trait overrides `timeout` if it is
    not `None`.

FYI @RonaldEnsing Pingback #1004 #1075

herr-biber avatar Oct 04 '21 10:10 herr-biber

I stumbled on the same issue, and confirm that using Execute.timeout rather than ExecuteProcessor.timeout worked.

Presumably the FAQ would need to be adjusted to clarify when Execute.timeout or ExecuteProcessor.timeout should be used. I started preparing a PR, and then realized I was still too confused about that to explain.

https://github.com/jupyter/nbgrader/blame/master/nbgrader/docs/source/user_guide/faq.rst#L193

Explanations welcome!

nthiery avatar Mar 29 '22 07:03 nthiery

Explanations welcome!

I will try 😉... The ExecuteProcessor comes from nbconvert(https://github.com/jupyter/nbgrader/blob/v0.6.2/nbgrader/preprocessors/execute.py#L1) and we are supposed?? to load those config values as well (https://github.com/jupyter/nbgrader/blob/v0.6.2/nbgrader/validator.py#L285-L289), but that is somehow not working... it seems, and this is why timeout is the only "inherited" option actually working (https://github.com/jupyter/nbgrader/blob/v0.6.2/nbgrader/preprocessors/execute.py#L11) when you explicitly use Execute.timeout?

damianavila avatar Apr 04 '22 15:04 damianavila

I managed to set the timeout to 600s via nbgrader validate --Execute.timeout=600 and in the config file via c.Execute.timeout = 600.

See also

# nbgrader --help-all | grep -A16 Execute.timeout=
--Execute.timeout=<Int>
    Default: 30
    The time to wait (in seconds) for output from executions. If a cell
    execution takes longer, an exception (TimeoutError on python 3+,
    RuntimeError on python 2) is raised.
    `None` or `-1` will disable the timeout. If `timeout_func` is set, it
    overrides `timeout`.
--Execute.timeout_func=<Any>
    Default: None
    A callable which, when given the cell source as input, returns the time to
    wait (in seconds) for output from cell executions. If a cell execution takes
    longer, an exception (TimeoutError on python 3+, RuntimeError on python 2)
    is raised.
    Returning `None` or `-1` will disable the timeout for the cell. Not setting
    `timeout_func` will cause the preprocessor to default to using the `timeout`
    trait for all cells. The `timeout_func` trait overrides `timeout` if it is
    not `None`.

FYI @RonaldEnsing Pingback #1004 #1075

Neither of both suggestions works for me, there will be always the warning that config option "timeout" not recognized by "Execute" with the latest pypi release 0.7.0, and cells can only run for 30 seconds.

wkirgsn avatar May 24 '22 07:05 wkirgsn

I'm also still running into this issue.

Here's the code for a minimal reproducible example for the assignment notebook:

import time
time.sleep(31)

I've configured nbgrader [1] correctly.

Still, I am getting the following error:

[AutogradeApp | ERROR] Timeout waiting for execute reply (30s).
[AutogradeApp | ERROR] Interrupting kernel

This issue appears with nbgrader=0.7.1, but not with nbgrader=0.6.2.

[1] https://nbgrader.readthedocs.io/en/stable/user_guide/faq.html#what-should-i-do-if-validation-or-grading-of-a-notebook-fails-with-a-timeout-waiting-for-execute-reply-error

RonaldEnsing avatar Aug 16 '22 11:08 RonaldEnsing

c.Execute.timeout_func = lambda x: 500 can be used as a work-around in 0.7.1

davidnero avatar Sep 28 '22 01:09 davidnero

Same problem here. Using @davidnero 's workaround in nbgrader_config.py worked. You made my day :-]

olbapjose avatar Oct 12 '22 13:10 olbapjose

I don't think this issue should be closed, as there currently isn't a proper solution for this problem. What @davidnero suggests works but is only a workaround.

emield12 avatar Dec 14 '22 16:12 emield12