From a609a0e4701ca2111783a959db130a6c4ece7455 Mon Sep 17 00:00:00 2001 From: telamonian Date: Mon, 28 Sep 2020 23:48:38 -0400 Subject: [PATCH 1/2] clearer error msg on exceptions during `JupytextContentsManager.save` - following the pattern from `FileContentsManager.save` in the `notebook` package --- .gitignore | 12 ++++++++++-- jupytext/contentsmanager.py | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 1ba731bef..17921bf29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -.idea -.vscode .build .cache .coverage @@ -18,3 +16,13 @@ docs/_build # Will be created by postBuild demo/get_started.ipynb + +# jetbrains ide stuff +*.iml +.idea/ + +# vscode ide stuff +*.code-workspace +.history +.vscode/* +!.vscode/*.template diff --git a/jupytext/contentsmanager.py b/jupytext/contentsmanager.py index d3d111817..c4b62b01b 100644 --- a/jupytext/contentsmanager.py +++ b/jupytext/contentsmanager.py @@ -162,8 +162,9 @@ def save_one_file(path, fmt): return write_pair(path, jupytext_formats, save_one_file) - except Exception as err: - raise HTTPError(400, str(err)) + except Exception as e: + self.log.error(u'Error while saving file: %s %s', path, e, exc_info=True) + raise HTTPError(500, u'Unexpected error while saving file: %s %s' % (path, e)) def get( self, From a007c6709a27da6ac33243b521722c5adbda466f Mon Sep 17 00:00:00 2001 From: telamonian Date: Tue, 29 Sep 2020 08:21:18 -0400 Subject: [PATCH 2/2] bugfix: convert nb dict to nb Node before calling `jupytext.writes` --- jupytext/contentsmanager.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jupytext/contentsmanager.py b/jupytext/contentsmanager.py index c4b62b01b..2c59921c9 100644 --- a/jupytext/contentsmanager.py +++ b/jupytext/contentsmanager.py @@ -155,7 +155,9 @@ def save_one_file(path, fmt): text_model = dict( type="file", format="text", - content=jupytext.writes(model["content"], fmt=fmt), + content=jupytext.writes( + nbformat.from_dict(model["content"]), fmt=fmt + ), ) return self.super.save(text_model, path) @@ -163,8 +165,12 @@ def save_one_file(path, fmt): return write_pair(path, jupytext_formats, save_one_file) except Exception as e: - self.log.error(u'Error while saving file: %s %s', path, e, exc_info=True) - raise HTTPError(500, u'Unexpected error while saving file: %s %s' % (path, e)) + self.log.error( + u"Error while saving file: %s %s", path, e, exc_info=True + ) + raise HTTPError( + 500, u"Unexpected error while saving file: %s %s" % (path, e) + ) def get( self,