Commit Graph

376 Commits

Author SHA1 Message Date
Min RK
121d495424 protect websocket against errant messages
- message handler being triggered after stream is closed (no channels)
- messages sent to invalid channels
2015-01-26 11:11:13 -08:00
Min RK
ad83e79ea5 allow requesting contents without body
adds `?content=0` to only fetch the metadata in the model.

The REST API now exposes all arguments to ContentsManager.get.
2015-01-24 12:46:15 -08:00
Brian E. Granger
ab83599d36 Merge pull request #7389 from minrk/one-websocket
use single WebSocket connection for all channels
2015-01-09 11:37:51 -08:00
Min RK
3cf6eacc86 Merge pull request #7324 from quantopian/separate-checkpoint-manager
DEV: Refactor checkpoint logic out of FileContentsManager into a separate class.
2015-01-09 10:17:15 -08:00
Scott Sanderson
64e5c49608 DEV: Break get_checkpoint into separate methods.
One for notebooks and one for checkpoints.
2015-01-08 17:00:53 -05:00
Scott Sanderson
2569c3069d STY: s/CheckpointManager/Checkpoints
It's easy to confuse CheckpointManager and ContentsManager.
2015-01-08 14:41:46 -05:00
Scott Sanderson
021e2da495 DEV: Separate FileCheckpointManager and GenericFileCheckpointManager.
- 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.
2015-01-08 14:07:17 -05:00
Scott Sanderson
12fe97e2af DEV: Allow CheckpointManagers to optimize for shared backends.
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.
2015-01-07 21:23:55 -05:00
Scott Sanderson
55d4e20aaf DEV: Remove ContentsManager.walk. 2015-01-07 16:13:42 -05:00
Scott Sanderson
2b73f1e620 DEV: Implement os.walk analog for ContentsManagers. 2015-01-06 23:59:31 -05:00
Scott Sanderson
1e2e86dcca MAINT: Return dicts from CheckpointManager.get_checkpoint.
The output is going to get converted to a dict anyway, and this makes it
easier to pipe output from a CheckpointManager directly to a
ContentsManager.
2015-01-06 14:28:59 -05:00
Min RK
1cac03528b use single WebSocket connection for all channels
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.
2015-01-06 11:15:15 -08:00
Scott Sanderson
7030a8717a DEV: Add full support for non-notebook checkpoints. 2015-01-01 20:52:00 -05:00
Scott Sanderson
23837e9ad4 DEV: Remove unnecessary notary calls. 2015-01-01 20:49:35 -05:00
Min RK
67abf3ddab update kernelspec test
to expect Python display name
2014-12-30 13:23:05 -08:00
Scott Sanderson
631a68d83e TEST: Test separate roots for Contents and Checkpoints. 2014-12-29 07:01:39 -05:00
Scott Sanderson
f71f216880 DEV: More checkpoint API refactoring.
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`.
2014-12-29 07:00:30 -05:00
Matthias Bussonnier
c1d9f4d436 Merge pull request #7283 from minrk/kernel-spec-model
add resource URLs to kernelspec model
2014-12-28 16:38:50 +01:00
Scott Sanderson
dc295f67bd MAINT: Add missing config=Trues. 2014-12-27 00:48:57 -05:00
Scott Sanderson
4da8a30f20 DEV: Refactor checkpoint logic from FileContentsManager.
- 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.
2014-12-27 00:23:14 -05:00
Scott Sanderson
9aad3c631f MAINT: Move update from FileContentsManager to ContentsManager.
The implementation in FileContentsManager is written entirely in terms
of the required API, and is sensible for other ContentsManager
implementations.
2014-12-25 13:17:10 -05:00
Min RK
e7b6d5dec3 update kernelspec model tests 2014-12-21 14:59:55 -08:00
Min RK
a417785c5e add resource URLs to kernelspec model
- move kernelspec itself to model.spec
- add resources top-level key with resource URLs
- no more 404s or HEAD requests under normal circumstances
2014-12-21 14:41:12 -08:00
Min RK
ad995dfdb8 Merge pull request #7244 from minrk/rm-signature
don't store signatures in notebooks
2014-12-20 16:47:05 -08:00
Min RK
db5147998d docstring on test_dir 2014-12-19 12:26:16 -08:00
Min RK
00e4ad59c0 add counter to new notebooks in test_manager
ensures brand new notebooks are untrusted

previously, all new notebooks were identical,
so once one was trusted, they would all start trusted.
2014-12-17 14:27:38 -08:00
Scott Sanderson
a1ad9abe51 MAINT: Unicode literal in assertDictContainsSubset 2014-12-17 11:38:46 -08:00
Scott Sanderson
4a2149d1c3 TEST: Add a non-notebook file to directory test. 2014-12-17 11:38:46 -08:00
Scott Sanderson
af7d1cdb50 STY: Define dirs as a single expression. 2014-12-17 11:38:46 -08:00
Scott Sanderson
f7cf204b25 BUG: Convert to bytes before comparing binary blobs. 2014-12-17 11:38:46 -08:00
Scott Sanderson
e9b81b6c7a TEST: Verify base64 return values after decoding. 2014-12-17 11:38:45 -08:00
Scott Sanderson
fcc1bbecb3 MAINT: Remove unused blob and b64_blob attributes. 2014-12-17 11:38:45 -08:00
Scott Sanderson
f20a7b41cb TEST: Abstract out directory/file deletion methods. 2014-12-17 11:38:45 -08:00
Scott Sanderson
46f299ccf2 TEST: Refactor symlink tests. 2014-12-17 11:38:45 -08:00
Min RK
a4b47e7e8a move symlink tests to TestFileManager 2014-12-17 11:38:45 -08:00
Scott Sanderson
61c2e0442f TEST: Add checks for subdirectory name splitting.
Previously the tests failed to catch a bug where a ContentsManager
didn't split name from path in a nested subdirectory.
2014-12-17 11:38:45 -08:00
Scott Sanderson
c7ca3066ec TEST: More fine-grained test for directory contents.
Verify that each entry in a directory listing matches the result of a
content-less direct get.
2014-12-17 11:38:45 -08:00
Scott Sanderson
23e5e6da4f TEST: Expect a 404 on delete of non-existent file. 2014-12-17 11:38:45 -08:00
Scott Sanderson
6bfab2de08 BUG: Allow for the possibility that to_path is empty string.
This is a legal input for representing the root directory.
2014-12-17 11:38:45 -08:00
Scott Sanderson
44805b94db BUG: Sanitize to_path in ContentsManager.copy.
Without this, one of the test cases in `test_copy` attempts a copy to a
directory that starts with a leading double-slash.
2014-12-17 11:38:45 -08:00
Scott Sanderson
7ab1bf7487 BUG: Set default mimetype when base64 is requested 2014-12-17 11:38:44 -08:00
Min RK
c166a05f5d abstract some methods in contents service tests
should allow re-use for ContentsManager subclasses
2014-12-17 11:38:44 -08:00
Min RK
dc70ae6b07 allow ContentsManager methods to return Futures
mainly adding `@gen.coroutine` and `yield gen.maybe_future` all over the place.

No FileContentsManager methods are actually async at this point.
2014-12-16 15:01:59 -08:00
Matthias Bussonnier
efbe695523 Merge pull request #7226 from takluyver/win-sleep-session-tests
Add a brief sleep after shutting down sessions in test teardown
2014-12-16 10:33:53 +01:00
Matthias Bussonnier
5829ceacb9 s/Json/JSON/g **/*.py 2014-12-15 21:54:54 +01:00
Thomas Kluyver
0178e2add0 Add a brief sleep after shutting down sessions in test teardown
This fixes a test failure for me on my Windows VM. See the comment for
details.
2014-12-15 12:45:45 -08:00
Matthias Bussonnier
4bd9ac7882 Add json in the base config manager name 2014-12-14 13:21:33 +01:00
Bussonnier Matthias
6f38f7b014 generalise manager 2014-12-14 13:20:04 +01:00
Min RK
42a92d4794 Merge pull request #6896 from minrk/save-hooks
Proposal: add pre/post-save hooks
2014-12-12 11:14:18 -08:00
Thomas Kluyver
f2e1b6f65f Merge pull request #7145 from minrk/type____
ContentsManager type kwarg to match model key
2014-12-10 14:28:32 -08:00