-
Notifications
You must be signed in to change notification settings - Fork 83
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
Move Files and Directories #64
Changes from all commits
2de2bd3
e82e744
3c563be
4fb66e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ htmlcov/ | |
.noseids | ||
nosetests.xml | ||
coverage.xml | ||
/.pytest_cache/* | ||
|
||
# Translations | ||
*.mo | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,6 +197,40 @@ def test_delete_non_empty_dir(self): | |
# be deleted) | ||
super(_APITestBase, self).test_delete_non_empty_dir() | ||
|
||
def test_checkpoints_move_with_file(self): | ||
# Create a checkpoint of initial state. | ||
response = self.api.new_checkpoint('foo/a.ipynb') | ||
response_json = response.json() | ||
|
||
# Move the file down. | ||
self.api.rename('foo/a.ipynb', 'foo/bar/a.ipynb') | ||
|
||
# Looking for checkpoints in the old location should yield no results. | ||
self.assertEqual(self.api.get_checkpoints('foo/a.ipynb').json(), []) | ||
|
||
# Looking for checkpoints in the new location should work. | ||
checkpoints = self.api.get_checkpoints('foo/bar/a.ipynb').json() | ||
self.assertEqual(checkpoints, [response_json]) | ||
|
||
# Rename the directory that the file is in. | ||
self.api.rename('foo/bar', 'foo/car') | ||
self.assertEqual( | ||
self.api.get_checkpoints('foo/bar/a.ipynb').json(), | ||
[], | ||
) | ||
checkpoints = self.api.get_checkpoints('foo/car/a.ipynb').json() | ||
self.assertEqual(checkpoints, [response_json]) | ||
|
||
# Now move the directory that the file is in. | ||
self.make_dir('foo/buz') | ||
self.api.rename('foo/car', 'foo/buz/car') | ||
self.assertEqual( | ||
self.api.get_checkpoints('foo/car/a.ipynb').json(), | ||
[], | ||
) | ||
checkpoints = self.api.get_checkpoints('foo/buz/car/a.ipynb').json() | ||
self.assertEqual(checkpoints, [response_json]) | ||
|
||
|
||
def _test_delete_non_empty_dir_fail(self, path): | ||
with assert_http_error(400): | ||
|
@@ -374,6 +408,18 @@ def teardown_class(cls): | |
super(PostgresContentsFileCheckpointsAPITest, cls).teardown_class() | ||
cls.td.cleanup() | ||
|
||
def test_checkpoints_move_with_file(self): | ||
# This test fails for this suite because the FileCheckpoints class is | ||
# not recognizing any checkpoints when renaming a directory. See: | ||
# https://github.com/jupyter/notebook/blob/bd6396d31e56f311e4022215 | ||
# 25f9db7686834150/notebook/services/contents/filecheckpoints.py#L9 | ||
# 8-L99 | ||
# It looks like this is a bug upstream, as I can imagine that method | ||
# wanting to list out all checkpoints for the given path if the path is | ||
# a directory. For now we filed an issue to track this: | ||
# https://github.com/quantopian/pgcontents/issues/68 | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this test fails for this case because the FileCheckpoints class is not recognizing any checkpoints when renaming a file. See https://github.com/jupyter/notebook/blob/master/notebook/services/contents/filecheckpoints.py#L98-L99. I'm not sure what to do about this without making upstream changes, but I can imagine that method wanting to list out all checkpoints for the given path if the path is a directory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, yeah, that looks like it's a bug upstream. I opened #68 to track this. Can you add a comment pointing to that issue? I'll push an issue and/or bugfix upstream. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya I'll add a comment. |
||
|
||
|
||
def postgres_checkpoints_config(): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do uncaught exceptions not get logged by default by tornado? I thought they did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like they do (I didn't know this), I'm just going to remove this
except
clause entirely.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, despite this fact, I think the manual logging here is clearer/more explicit about there being an issue in our code and about what exact rename call caused the problem. So I don't think it hurts to keep this. I also noticed this is what
save
does above.