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.
- `ContentsManager.pre_save_hook` runs on the path and model with content
- `FileContentsManager.post_save_hook` runs on the filesystem path and model without content
- use pre_save_hook for things like stripping output
- use post_save_hook for things like nbconvert --to python
file_to_run and notebook_dir would collide, with possible dictionary
ordering randomness depending on how they were passed.
With this change, the default value of notebook_dir is pulled from
file_to_run, instead of pushing the value when file_to_run is changed.
This makes it possible to specify both and have the server behave as
expected.
- various docstrings, comments clarified and updated
- misc typos
- fix and test creating an untitled directory via POST
- only define `message` if there's something to say
- path is full path (including name)
- name is only used for read-only convenience, and plays no role in any API
- remove 'untitled upload' (POST with content and no path)
- failed validation doesn't prevent save/load,
but the user is now warned about it.
- there is now a warning dialog if fromJSON fails,
rather than the usual silent failure.
Ping @fperez, this should avoid issues with corrupted/lost notebooks
when the disk is full, though I haven't worked out how to test it just
yet.
Closes gh-6254
- clarified docstrings and errors
- still more notebook/file renames
- configurable untitled names
- copy_from can be full path
- fix running, upload, new-tab behaviors in dashboard
Yay, review!