Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix abstract checkpoint methods to match interface used #237

Merged
merged 1 commit into from
Jul 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions notebook/services/contents/checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class GenericCheckpointsMixin(object):
- get_notebook_checkpoint(self, checkpoint_id, path)

To create a generic CheckpointManager, add this mixin to a class that
implement the above three methods plus the remaining Checkpoints API
implement the above four methods plus the remaining Checkpoints API
methods:

- delete_checkpoint(self, checkpoint_id, path)
Expand Down Expand Up @@ -118,10 +118,25 @@ def create_notebook_checkpoint(self, nb, path):
"""
raise NotImplementedError("must be implemented in a subclass")

def get_checkpoint(self, checkpoint_id, path, type):
"""Get the content of a checkpoint.
def get_file_checkpoint(self, checkpoint_id, path):
"""Get the content of a checkpoint for a non-notebook file.

Returns an unvalidated model with the same structure as
the return value of ContentsManager.get
Returns a dict of the form:
{
'type': 'file',
'content': <str>,
'format': {'text','base64'},
}
"""
raise NotImplementedError("must be implemented in a subclass")

def get_notebook_checkpoint(self, checkpoint_id, path):
"""Get the content of a checkpoint for a notebook.

Returns a dict of the form:
{
'type': 'notebook',
'content': <output of nbformat.read>,
}
"""
raise NotImplementedError("must be implemented in a subclass")
5 changes: 3 additions & 2 deletions notebook/services/contents/filecheckpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class GenericFileCheckpoints(GenericCheckpointsMixin, FileCheckpoints):
ContentsManager.
"""
def create_file_checkpoint(self, content, format, path):
"""Create a checkpoint from the current content of a notebook."""
"""Create a checkpoint from the current content of a file."""
path = path.strip('/')
# only the one checkpoint ID:
checkpoint_id = u"checkpoint"
Expand All @@ -168,7 +168,7 @@ def create_notebook_checkpoint(self, nb, path):
return self.checkpoint_model(checkpoint_id, os_checkpoint_path)

def get_notebook_checkpoint(self, checkpoint_id, path):

"""Get a checkpoint for a notebook."""
path = path.strip('/')
self.log.info("restoring %s from checkpoint %s", path, checkpoint_id)
os_checkpoint_path = self.checkpoint_path(checkpoint_id, path)
Expand All @@ -185,6 +185,7 @@ def get_notebook_checkpoint(self, checkpoint_id, path):
}

def get_file_checkpoint(self, checkpoint_id, path):
"""Get a checkpoint for a file."""
path = path.strip('/')
self.log.info("restoring %s from checkpoint %s", path, checkpoint_id)
os_checkpoint_path = self.checkpoint_path(checkpoint_id, path)
Expand Down