From c1cff526ab449895f3c41c7a2a33e7efbd968cc9 Mon Sep 17 00:00:00 2001 From: Nguyen Huy Hoang <24520554@gm.uit.edu.vn> Date: Thu, 26 Mar 2026 22:08:04 +0700 Subject: [PATCH 1/3] feat: extend `papermillexecutionerror` to carry the executed output notebook object Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com> --- papermill/exceptions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/papermill/exceptions.py b/papermill/exceptions.py index e8988d93..3f42f3c3 100644 --- a/papermill/exceptions.py +++ b/papermill/exceptions.py @@ -20,7 +20,7 @@ class PapermillMissingParameterException(PapermillException): class PapermillExecutionError(PapermillException): """Raised when an exception is encountered in a notebook.""" - def __init__(self, cell_index, exec_count, source, ename, evalue, traceback): + def __init__(self, cell_index, exec_count, source, ename, evalue, traceback, output_notebook=None): args = cell_index, exec_count, source, ename, evalue, traceback self.cell_index = cell_index self.exec_count = exec_count @@ -28,6 +28,7 @@ def __init__(self, cell_index, exec_count, source, ename, evalue, traceback): self.ename = ename self.evalue = evalue self.traceback = traceback + self.output_notebook = output_notebook super().__init__(*args) From 928454113ace2186222dc977b7d9fd1839abf50d Mon Sep 17 00:00:00 2001 From: Nguyen Huy Hoang <24520554@gm.uit.edu.vn> Date: Thu, 26 Mar 2026 22:08:07 +0700 Subject: [PATCH 2/3] feat: extend `papermillexecutionerror` to carry the executed output notebook object Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com> --- papermill/execute.py | 1 + 1 file changed, 1 insertion(+) diff --git a/papermill/execute.py b/papermill/execute.py index eb76cc34..f8473bd3 100644 --- a/papermill/execute.py +++ b/papermill/execute.py @@ -211,6 +211,7 @@ def raise_for_execution_errors(nb, output_path): ename=output.ename, evalue=output.evalue, traceback=output.traceback, + output_notebook=nb, ) break From d1837777ce4682eaeeae321b92cecec79c355951 Mon Sep 17 00:00:00 2001 From: Nguyen Huy Hoang <24520554@gm.uit.edu.vn> Date: Thu, 26 Mar 2026 22:08:09 +0700 Subject: [PATCH 3/3] feat: extend `papermillexecutionerror` to carry the executed output notebook object Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com> --- papermill/tests/test_execute.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/papermill/tests/test_execute.py b/papermill/tests/test_execute.py index 09600d64..9d2098d0 100644 --- a/papermill/tests/test_execute.py +++ b/papermill/tests/test_execute.py @@ -31,6 +31,13 @@ def setUp(self): def tearDown(self): shutil.rmtree(self.test_dir) + def test_execution_error_includes_output_notebook(self): + notebook_name = 'broken.ipynb' + nb_test_executed_fname = os.path.join(self.test_dir, f'output_{notebook_name}') + with self.assertRaises(PapermillExecutionError) as err: + execute_notebook(get_notebook_path(notebook_name), nb_test_executed_fname) + self.assertIsInstance(err.exception.output_notebook, nbformat.NotebookNode) + @patch(f"{engines.__name__}.PapermillNotebookClient") def test_start_timeout(self, preproc_mock): execute_notebook(self.notebook_path, self.nb_test_executed_fname, start_timeout=123)