-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return code of executing notebooks in papermill #337
Comments
It does this today unless I'm missing something from the question. You get a zero exit code on success and non-zero on failure from the CLI call -- or an exception if you're in Python calling the library. |
@vinaykumar80 The reference section of the documentation provides more information. Here's an example of an exception: https://papermill.readthedocs.io/en/latest/reference/papermill-workflow.html#papermill.execute.raise_for_execution_errors |
I see the same problem here:
It turns out that the kernel I am using (sos) returns Because the papermill/papermill/execute.py Line 154 in 0ee0da7
looks for output of type However, returning code |
I would further argue that the existence of an Basically I believe that only an @MSeal What do you think? |
Sorry for the late reply @BoPeng , catching back up from the holidays. Unfortunately this is a shortcoming in the API spec for jupyter. The execute_reply and the error message patterns are intermixed by a lot of kernels as it's confusing what's used for what. The result is that different interfaces have made changes to work for specific kernel patterns which isn't necessarily in the spec. From the api spec docs: https://jupyter-client.readthedocs.io/en/stable/messaging.html#messages-on-the-shell-router-dealer-channel interfaces should behave the way your describing, relying on
The actual code we need to touch is in nbconvert https://github.com/jupyter/nbconvert/blob/master/nbconvert/preprocessors/execute.py#L475-L479, captured by papermill/papermill/preprocess.py Line 64 in 0ee0da7
Also this change in behavior is pending for the next papermill release: #449 -- it adds checks for the type of exit so that user exit(0) can be respected as a successful exit. This might complicate the proposed check here, though I don't think they're incompatible. |
Since jupyter/nbconvert#1163 has been merged, can we re-open this ticket and see what can be done on the papermill side? |
I believe there is noting to do in papermill. It just needs the dependency update and it should follow nbconvert's behavior. This will happen once I finish jupyter/nbconvert#821 (which I am actively working on this week) and papermill 2.0 releases. |
If it helps, you can grep the output for
|
@BoPeng is there a way to catch any error in any cell? When does papermill execution of a notebook return output of type import papermill as pm
nb_node = pm.execute_notebook(
'input.ipynb',
'output.ipynb',
)
pm.execute.raise_for_execution_errors(nb_node, "output.ipynb")
The
|
This is kernel dependent. Obviously this kernel decides to output an error message in HTML format instead of sending an actual |
I see. What kernels are compatible with this method? |
Hi, sorry, bumping to see if anyone knows the answer to my last question. 🙏 |
ipykernel (Python) should work. |
I'm using ipykernel (see
|
Hi All,
Is there a way to capture return code of executing notebooks in papermill API library or CLI methods? When any notebook cell execution encounters an error, it should return an error return code AND when all notebook cells execute successfully it should return a success return code.
Thanks!
The text was updated successfully, but these errors were encountered: