- Adds a `GenericCheckpointMixin` as a helper for implementing the two
boundary-traversing Checkpoint API methods, `create_checkpoint` and
`restore_checkpoint`.
- `GenericFileCheckpointManager` is implemented as a subclass of
`FileCheckpointManager` using `GenericCheckpointMixin`. Note that
this is the safe subtyping relationship because of method
signature *contra*variance: `FileCheckpointManager` accepts
`FileContentsManager` in its method signatures type, whereas
`GenericFileCheckpointManager` accepts any `ContentsManager`.
- Moved Checkpoint-related classes to their own files.
On `create_checkpoint` and `restore_checkpoint`, pass a path and a
`ContentsManager` to `CheckpointManager` instead of an already-loaded
model.
The `CheckpointManager` base class provides a correct implementation of
these methods that's generic across any ContentsManager, but subclasses
are free to specialize when the storage backend of `ContentsManager` is
shared.
multiplex on a 'channel' key in message,
rather than separate websockets.
Unlike zmq, there aren't different message patterns that require the channels to be separate.
Reduces FD count by factor of 3 and connection complexity in js.
Changed the public checkpoint API to:
- `create_checkpoint(self, nb, path)`
- `get_checkpoint_content(self, checkpoint_id, path)`
- `rename_checkpoint(self, checkpoint_id, old_path, new_path)`
- `delete_checkpoint(self, checkpoint_id, path)`
- `list_checkpoints(self, path)`
All paths in the above are API-style paths, and the `nb` argument to
`create_checkpoint` is a dictionary suitable for passing to
`nbformat.write`.
The new `get_checkpoint_content` method returns an unvalidated notebook
content dictionary. It is used by `ContentManager.restore_checkpoint`
to load content to be written via `save`.
- Add a `CheckpointManager` base class and infrastructure for creating a
`checkpoint_manager` instance attribute on `ContentsManager`.
- Provide default implementations of `delete` and `rename` in the base
`ContentsManager` class. `ContentsManager` subclasses are now
required to implement `delete_file` and `rename_file`. These methods
no longer need to manage checkpoints.
- Move checkpoint-related functionality from `FileContentsManager` to a
dedicated `FileCheckpointManager` subclass.
- Move shared filesystem interaction logic into `FileManagerMixin`
used by both `FileContentsManager` and `FileCheckpointManager`.
- Minor tweaks to ContentsManager tests to get methods from the right
object.
The purpose of this change is to provide an API for users to replace
just the checkpoint logic associated with a particular
`ContentsManager`. In particular, this change makes it possible to
easily support remote storage of checkpoints while otherwise retaining
normal filesystem interactions.