Skip to content

Commit

Permalink
Catch exceptions on update cell and nb metadata (#108)
Browse files Browse the repository at this point in the history
* Catch exceptions on update cell and nb metadata

* reword debug log

* refactor

* update origami to 0.0.17

* add changelog

* Bump version: 0.0.18 → 0.0.19
  • Loading branch information
rohitsanj authored Jan 4, 2023
1 parent 764dbcd commit f46ee92
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.18
current_version = 0.0.19
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
serialize =
{major}.{minor}.{patch}
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ 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.18] - 2021-12-19
## [0.0.19] - 2023-01-04
### Added
- Catch exceptions on update cell and nb metadata

## [0.0.18] - 2022-12-19
### Changed
- Catch asyncio.exceptions.TimeoutError when updating notebook metadata over RTU

Expand Down
2 changes: 1 addition & 1 deletion papermill_origami/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.0.18"
version = "0.0.19"
26 changes: 17 additions & 9 deletions papermill_origami/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import httpx
import nbformat
import orjson
import websockets.exceptions
from jupyter_client.utils import run_sync
from nbclient.exceptions import CellExecutionError
from nbformat import NotebookNode
Expand Down Expand Up @@ -124,11 +125,18 @@ def wrapper(cell, *args, **kwargs):
for key, value in flatten_dict(
cell.metadata.papermill, parent_key_tuple=("papermill",)
).items():
run_sync(self.km.client.update_cell_metadata)(
file=self.file,
cell_id=cell.id,
metadata_update_properties={"path": key, "value": value},
)
try:
run_sync(self.km.client.update_cell_metadata)(
file=self.file,
cell_id=cell.id,
metadata_update_properties={"path": key, "value": value},
)
except (
asyncio.exceptions.TimeoutError,
websockets.exceptions.ConnectionClosedError,
):
logger.debug("Encountered an error while updating cell metadata")
pass
return ret_val

return wrapper
Expand Down Expand Up @@ -322,8 +330,8 @@ async def sync_noteable_nb_metadata_with_papermill(self):
).items():
try:
await self.km.client.update_nb_metadata(self.file, {"path": key, "value": value})
except asyncio.exceptions.TimeoutError:
logger.debug("Timeout error while updating notebook metadata")
except (asyncio.exceptions.TimeoutError, websockets.exceptions.ConnectionClosedError):
logger.debug("Encountered an error while updating notebook metadata")
pass

@staticmethod
Expand Down Expand Up @@ -366,8 +374,8 @@ def _cell_exception(self, cell, cell_index=None, **kwargs):
run_sync(self.km.client.update_nb_metadata)(
self.file, {"path": ["papermill", "exception"], "value": True}
)
except asyncio.exceptions.TimeoutError:
logger.debug("Timeout error while updating notebook metadata")
except (asyncio.exceptions.TimeoutError, websockets.exceptions.ConnectionClosedError):
logger.debug("Encountered an error while updating notebook metadata")
pass

def _cell_complete(self, cell, cell_index=None, **kwargs):
Expand Down
Loading

0 comments on commit f46ee92

Please sign in to comment.