diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 63b407d..8dcd9d7 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.16 +current_version = 0.0.17 parse = (?P\d+)\.(?P\d+)\.(?P\d+) serialize = {major}.{minor}.{patch} diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e43384..0ff7d59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.0.17] - 2022-12-16 +### Changed +- Catch all HTTPStatusErrors when trying to delete the kernel session after successful execution ## [0.0.16] - 2022-12-14 ### Changed diff --git a/papermill_origami/_version.py b/papermill_origami/_version.py index 8384f6d..fc28f3a 100644 --- a/papermill_origami/_version.py +++ b/papermill_origami/_version.py @@ -1 +1 @@ -version = "0.0.16" +version = "0.0.17" diff --git a/papermill_origami/engine.py b/papermill_origami/engine.py index fee6842..2b78427 100644 --- a/papermill_origami/engine.py +++ b/papermill_origami/engine.py @@ -452,6 +452,13 @@ async def papermill_execute_cells(self): "Timed out while deleting kernel session for file id %s", self.file.id, ) + except httpx.HTTPStatusError as e: + # Ignore any HTTP errors that occur while deleting the kernel session + logger.warning( + "Failed to delete kernel session for file id %s. Error: %s", + self.file.id, + e, + ) def _get_timeout(self, cell: Optional[NotebookNode]) -> int: """Helper to fetch a timeout as a value or a function to be run against a cell""" diff --git a/papermill_origami/tests/test_engine.py b/papermill_origami/tests/test_engine.py index 17bac4e..0c8a29a 100644 --- a/papermill_origami/tests/test_engine.py +++ b/papermill_origami/tests/test_engine.py @@ -4,6 +4,7 @@ from datetime import datetime from unittest.mock import ANY +import httpx import nbformat import pytest from nbclient.exceptions import CellExecutionError @@ -394,3 +395,22 @@ async def test_kernel_session_is_not_deleted_after_failed_execution( # Assert that the kernel session was not deleted noteable_engine.client.delete_kernel_session.assert_not_called() + + @pytest.mark.parametrize( + "exception", + [ + httpx.ReadTimeout("fake message"), + httpx.HTTPStatusError("fake message", request=None, response=None), + ], + ) + async def test_catch_delete_kernel_session_errors( + self, file_content, noteable_engine, exception + ): + noteable_engine.client.delete_kernel_session.side_effect = exception + try: + await noteable_engine.execute( + file_id='fake_id', + noteable_nb=file_content, + ) + except exception.__class__: + pytest.fail("papermill_execute_cells should catch delete_kernel_session errors") diff --git a/pyproject.toml b/pyproject.toml index 3f92d90..ba9c65c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "papermill-origami" -version = "0.0.16" +version = "0.0.17" description = "The noteable API interface" authors = ["Matt Seal "] maintainers = ["Matt Seal "]