Skip to content

Commit

Permalink
By default, raise errors on IOPub timeouts
Browse files Browse the repository at this point in the history
See the following links for details on the issues with IOPub and
nbconvert's ExecutePreprocessor:

- nteract/papermill#426 (comment)
- jupyter/nbconvert#994
  • Loading branch information
jsvine committed Jan 24, 2020
1 parent aefe1a5 commit 719ae2d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ nbexec --max-depth 3 path/to/directory-of-notebooks

```
usage: nbexec [-h] [--max-depth MAX_DEPTH] [--timeout TIMEOUT]
[--kernel-name KERNEL_NAME] [--quiet] [--stdout]
[--allow-iopub-timeout] [--kernel-name KERNEL_NAME] [--quiet]
[--stdout]
notebooks [notebooks ...]
Execute Jupyter notebooks on the command line.
Expand All @@ -60,6 +61,9 @@ optional arguments:
(default: 1)
--timeout TIMEOUT How long to wait, in seconds, for any given notebook
cell to before raising an exception. (default: None)
--allow-iopub-timeout
Don't raise an error on IOPub timeouts. (default:
False)
--kernel-name KERNEL_NAME
The name of the kernel to use, e.g., 'python3'. If
None, nbexec uses the kernel specified in the
Expand Down
6 changes: 6 additions & 0 deletions nbexec/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def parse_args(args):
help = "How long to wait, in seconds, for any given notebook cell to before raising an exception."
)

parser.add_argument(
"--allow-iopub-timeout",
action = "store_true",
help = "Don't raise an error on IOPub timeouts."
)

parser.add_argument(
"--kernel-name",
default = DEFAULTS["kernel_name"],
Expand Down
4 changes: 3 additions & 1 deletion nbexec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
DEFAULTS = {
"timeout": None,
"kernel_name": None,
"stdout": False
"stdout": False,
"allow_iopub_timeout": True,
}

class NBExecError(Exception):
Expand All @@ -42,6 +43,7 @@ def exec_nb(path, **kwargs):

ep = ExecutePreprocessor(
timeout = settings["timeout"],
raise_on_iopub_timeout = not settings["allow_iopub_timeout"],
kernel_name = kernel_name
)

Expand Down

0 comments on commit 719ae2d

Please sign in to comment.