Skip to content

Commit 01500bd

Browse files
Mariko WakabayashiZsailer
authored andcommitted
Checkpoints: Make all not implemented methods async
1 parent b19edc0 commit 01500bd

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

jupyter_server/services/contents/checkpoints.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,25 @@ class AsyncCheckpoints(Checkpoints):
146146
"""
147147
Base class for managing checkpoints for a ContentsManager asynchronously.
148148
"""
149+
async def create_checkpoint(self, contents_mgr, path):
150+
"""Create a checkpoint."""
151+
raise NotImplementedError("must be implemented in a subclass")
152+
153+
async def restore_checkpoint(self, contents_mgr, checkpoint_id, path):
154+
"""Restore a checkpoint"""
155+
raise NotImplementedError("must be implemented in a subclass")
156+
157+
async def rename_checkpoint(self, checkpoint_id, old_path, new_path):
158+
"""Rename a single checkpoint from old_path to new_path."""
159+
raise NotImplementedError("must be implemented in a subclass")
160+
161+
async def delete_checkpoint(self, checkpoint_id, path):
162+
"""delete a checkpoint for a file"""
163+
raise NotImplementedError("must be implemented in a subclass")
164+
165+
async def list_checkpoints(self, path):
166+
"""Return a list of checkpoints for a given file"""
167+
raise NotImplementedError("must be implemented in a subclass")
149168

150169
async def rename_all_checkpoints(self, old_path, new_path):
151170
"""Rename all checkpoints for old_path to new_path."""
@@ -191,3 +210,41 @@ async def restore_checkpoint(self, contents_mgr, checkpoint_id, path):
191210
else:
192211
raise HTTPError(500, u'Unexpected type %s' % type)
193212
await contents_mgr.save(model, path)
213+
214+
# Required Methods
215+
async def create_file_checkpoint(self, content, format, path):
216+
"""Create a checkpoint of the current state of a file
217+
218+
Returns a checkpoint model for the new checkpoint.
219+
"""
220+
raise NotImplementedError("must be implemented in a subclass")
221+
222+
async def create_notebook_checkpoint(self, nb, path):
223+
"""Create a checkpoint of the current state of a file
224+
225+
Returns a checkpoint model for the new checkpoint.
226+
"""
227+
raise NotImplementedError("must be implemented in a subclass")
228+
229+
async def get_file_checkpoint(self, checkpoint_id, path):
230+
"""Get the content of a checkpoint for a non-notebook file.
231+
232+
Returns a dict of the form:
233+
{
234+
'type': 'file',
235+
'content': <str>,
236+
'format': {'text','base64'},
237+
}
238+
"""
239+
raise NotImplementedError("must be implemented in a subclass")
240+
241+
async def get_notebook_checkpoint(self, checkpoint_id, path):
242+
"""Get the content of a checkpoint for a notebook.
243+
244+
Returns a dict of the form:
245+
{
246+
'type': 'notebook',
247+
'content': <output of nbformat.read>,
248+
}
249+
"""
250+
raise NotImplementedError("must be implemented in a subclass")

0 commit comments

Comments
 (0)