Show More
@@ -278,7 +278,7 b' class FileNotebookManager(NotebookManager):' | |||||
278 |
|
278 | |||
279 | # clear checkpoints |
|
279 | # clear checkpoints | |
280 | for checkpoint in self.list_checkpoints(name, path): |
|
280 | for checkpoint in self.list_checkpoints(name, path): | |
281 |
checkpoint_id = checkpoint[' |
|
281 | checkpoint_id = checkpoint['id'] | |
282 | cp_path = self.get_checkpoint_path(checkpoint_id, name, path) |
|
282 | cp_path = self.get_checkpoint_path(checkpoint_id, name, path) | |
283 | if os.path.isfile(cp_path): |
|
283 | if os.path.isfile(cp_path): | |
284 | self.log.debug("Unlinking checkpoint %s", cp_path) |
|
284 | self.log.debug("Unlinking checkpoint %s", cp_path) | |
@@ -315,7 +315,7 b' class FileNotebookManager(NotebookManager):' | |||||
315 | # Move the checkpoints |
|
315 | # Move the checkpoints | |
316 | old_checkpoints = self.list_checkpoints(old_name, old_path) |
|
316 | old_checkpoints = self.list_checkpoints(old_name, old_path) | |
317 | for cp in old_checkpoints: |
|
317 | for cp in old_checkpoints: | |
318 |
checkpoint_id = cp[' |
|
318 | checkpoint_id = cp['id'] | |
319 | old_cp_path = self.get_checkpoint_path(checkpoint_id, old_name, old_path) |
|
319 | old_cp_path = self.get_checkpoint_path(checkpoint_id, old_name, old_path) | |
320 | new_cp_path = self.get_checkpoint_path(checkpoint_id, new_name, new_path) |
|
320 | new_cp_path = self.get_checkpoint_path(checkpoint_id, new_name, new_path) | |
321 | if os.path.isfile(old_cp_path): |
|
321 | if os.path.isfile(old_cp_path): | |
@@ -346,7 +346,7 b' class FileNotebookManager(NotebookManager):' | |||||
346 | stats = os.stat(cp_path) |
|
346 | stats = os.stat(cp_path) | |
347 | last_modified = tz.utcfromtimestamp(stats.st_mtime) |
|
347 | last_modified = tz.utcfromtimestamp(stats.st_mtime) | |
348 | info = dict( |
|
348 | info = dict( | |
349 |
|
|
349 | id = checkpoint_id, | |
350 | last_modified = last_modified, |
|
350 | last_modified = last_modified, | |
351 | ) |
|
351 | ) | |
352 | return info |
|
352 | return info |
@@ -180,9 +180,9 b' class NotebookCheckpointsHandler(IPythonHandler):' | |||||
180 | nbm = self.notebook_manager |
|
180 | nbm = self.notebook_manager | |
181 | checkpoint = nbm.create_checkpoint(name, path) |
|
181 | checkpoint = nbm.create_checkpoint(name, path) | |
182 | data = json.dumps(checkpoint, default=date_default) |
|
182 | data = json.dumps(checkpoint, default=date_default) | |
183 |
location = url_path_join(self.base_project_url, |
|
183 | location = url_path_join(self.base_project_url, 'api/notebooks', | |
184 |
path, name, 'checkpoints', checkpoint[ |
|
184 | path, name, 'checkpoints', checkpoint['id']) | |
185 |
self.set_header( |
|
185 | self.set_header('Location', location) | |
186 | self.set_status(201) |
|
186 | self.set_status(201) | |
187 | self.finish(data) |
|
187 | self.finish(data) | |
188 |
|
188 |
@@ -229,8 +229,8 b' class APITest(NotebookTestBase):' | |||||
229 | r = self.nb_api.new_checkpoint('a.ipynb', 'foo') |
|
229 | r = self.nb_api.new_checkpoint('a.ipynb', 'foo') | |
230 | self.assertEqual(r.status_code, 201) |
|
230 | self.assertEqual(r.status_code, 201) | |
231 | cp1 = r.json() |
|
231 | cp1 = r.json() | |
232 |
self.assertEqual(set(cp1), {' |
|
232 | self.assertEqual(set(cp1), {'id', 'last_modified'}) | |
233 |
self.assertEqual(r.headers['Location'].split('/')[-1], cp1[' |
|
233 | self.assertEqual(r.headers['Location'].split('/')[-1], cp1['id']) | |
234 |
|
234 | |||
235 | # Modify it |
|
235 | # Modify it | |
236 | nbcontent = jsonapi.loads(resp.text)['content'] |
|
236 | nbcontent = jsonapi.loads(resp.text)['content'] | |
@@ -252,14 +252,14 b' class APITest(NotebookTestBase):' | |||||
252 | self.assertEqual(nb.worksheets[0].cells[0].source, 'Created by test') |
|
252 | self.assertEqual(nb.worksheets[0].cells[0].source, 'Created by test') | |
253 |
|
253 | |||
254 | # Restore cp1 |
|
254 | # Restore cp1 | |
255 |
r = self.nb_api.restore_checkpoint('a.ipynb', 'foo', cp1[' |
|
255 | r = self.nb_api.restore_checkpoint('a.ipynb', 'foo', cp1['id']) | |
256 | self.assertEqual(r.status_code, 204) |
|
256 | self.assertEqual(r.status_code, 204) | |
257 | nbcontent = self.nb_api.read('a.ipynb', 'foo').json()['content'] |
|
257 | nbcontent = self.nb_api.read('a.ipynb', 'foo').json()['content'] | |
258 | nb = to_notebook_json(nbcontent) |
|
258 | nb = to_notebook_json(nbcontent) | |
259 | self.assertEqual(nb.worksheets, []) |
|
259 | self.assertEqual(nb.worksheets, []) | |
260 |
|
260 | |||
261 | # Delete cp1 |
|
261 | # Delete cp1 | |
262 |
r = self.nb_api.delete_checkpoint('a.ipynb', 'foo', cp1[' |
|
262 | r = self.nb_api.delete_checkpoint('a.ipynb', 'foo', cp1['id']) | |
263 | self.assertEqual(r.status_code, 204) |
|
263 | self.assertEqual(r.status_code, 204) | |
264 | cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json() |
|
264 | cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json() | |
265 | self.assertEqual(cps, []) |
|
265 | self.assertEqual(cps, []) |
@@ -2009,7 +2009,7 b' var IPython = (function (IPython) {' | |||||
2009 | var found = false; |
|
2009 | var found = false; | |
2010 | for (var i = 0; i < this.checkpoints.length; i++) { |
|
2010 | for (var i = 0; i < this.checkpoints.length; i++) { | |
2011 | var existing = this.checkpoints[i]; |
|
2011 | var existing = this.checkpoints[i]; | |
2012 |
if (existing. |
|
2012 | if (existing.id == checkpoint.id) { | |
2013 | found = true; |
|
2013 | found = true; | |
2014 | this.checkpoints[i] = checkpoint; |
|
2014 | this.checkpoints[i] = checkpoint; | |
2015 | break; |
|
2015 | break; | |
@@ -2149,7 +2149,7 b' var IPython = (function (IPython) {' | |||||
2149 | Revert : { |
|
2149 | Revert : { | |
2150 | class : "btn-danger", |
|
2150 | class : "btn-danger", | |
2151 | click : function () { |
|
2151 | click : function () { | |
2152 |
that.restore_checkpoint(checkpoint. |
|
2152 | that.restore_checkpoint(checkpoint.id); | |
2153 | } |
|
2153 | } | |
2154 | }, |
|
2154 | }, | |
2155 | Cancel : {} |
|
2155 | Cancel : {} |
General Comments 0
You need to be logged in to leave comments.
Login now