Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Mar 8, 2022
1 parent 4762a9b commit f5688a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/source/developers/savehooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ They are both called with keyword arguments::
pre_save_hook(model=model, path=path, contents_manager=cm)
post_save_hook(model=model, os_path=os_path, contents_manager=cm)

Assigning to ``pre_save_hook`` (or ``post_save_hook``) multiple times will
register hooks, not override them. They will then be called sequentially.

Examples
--------

Expand Down
7 changes: 6 additions & 1 deletion jupyter_server/services/contents/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ def run_post_save_hook(self, model, os_path):
self.log.debug("Running post-save hook on %s", os_path)
post_save_hook(os_path=os_path, model=model, contents_manager=self)
except Exception as e:
self.log.error("Post-save %s hook failed on %s", post_save_hook.__name__, os_path, exc_info=True)
self.log.error(
"Post-save %s hook failed on %s",
post_save_hook.__name__,
os_path,
exc_info=True,
)
raise web.HTTPError(
500, "Unexpected error while running post hook save: %s" % e
) from e
Expand Down
7 changes: 6 additions & 1 deletion jupyter_server/services/contents/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ def run_pre_save_hook(self, model, path, **kwargs):
except Exception:
# unhandled errors don't prevent saving,
# which could cause frustrating data loss
self.log.error("Pre-save hook %s failed on %s", pre_save_hook.__name__, path, exc_info=True)
self.log.error(
"Pre-save hook %s failed on %s",
pre_save_hook.__name__,
path,
exc_info=True,
)

checkpoints_class = Type(Checkpoints, config=True)
checkpoints = Instance(Checkpoints, config=True)
Expand Down

0 comments on commit f5688a7

Please sign in to comment.