mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
use 'id' for checkpoint ID key
rather than redundant checkpoint.checkpoint_id
This commit is contained in:
parent
5a60141bed
commit
d1a36fe4c0
@ -278,7 +278,7 @@ class FileNotebookManager(NotebookManager):
|
||||
|
||||
# clear checkpoints
|
||||
for checkpoint in self.list_checkpoints(name, path):
|
||||
checkpoint_id = checkpoint['checkpoint_id']
|
||||
checkpoint_id = checkpoint['id']
|
||||
cp_path = self.get_checkpoint_path(checkpoint_id, name, path)
|
||||
if os.path.isfile(cp_path):
|
||||
self.log.debug("Unlinking checkpoint %s", cp_path)
|
||||
@ -315,7 +315,7 @@ class FileNotebookManager(NotebookManager):
|
||||
# Move the checkpoints
|
||||
old_checkpoints = self.list_checkpoints(old_name, old_path)
|
||||
for cp in old_checkpoints:
|
||||
checkpoint_id = cp['checkpoint_id']
|
||||
checkpoint_id = cp['id']
|
||||
old_cp_path = self.get_checkpoint_path(checkpoint_id, old_name, old_path)
|
||||
new_cp_path = self.get_checkpoint_path(checkpoint_id, new_name, new_path)
|
||||
if os.path.isfile(old_cp_path):
|
||||
@ -346,7 +346,7 @@ class FileNotebookManager(NotebookManager):
|
||||
stats = os.stat(cp_path)
|
||||
last_modified = tz.utcfromtimestamp(stats.st_mtime)
|
||||
info = dict(
|
||||
checkpoint_id = checkpoint_id,
|
||||
id = checkpoint_id,
|
||||
last_modified = last_modified,
|
||||
)
|
||||
return info
|
||||
|
@ -180,9 +180,9 @@ class NotebookCheckpointsHandler(IPythonHandler):
|
||||
nbm = self.notebook_manager
|
||||
checkpoint = nbm.create_checkpoint(name, path)
|
||||
data = json.dumps(checkpoint, default=date_default)
|
||||
location = url_path_join(self.base_project_url, u'/api/notebooks',
|
||||
path, name, 'checkpoints', checkpoint[u'checkpoint_id'])
|
||||
self.set_header(u'Location', location)
|
||||
location = url_path_join(self.base_project_url, 'api/notebooks',
|
||||
path, name, 'checkpoints', checkpoint['id'])
|
||||
self.set_header('Location', location)
|
||||
self.set_status(201)
|
||||
self.finish(data)
|
||||
|
||||
|
@ -229,8 +229,8 @@ class APITest(NotebookTestBase):
|
||||
r = self.nb_api.new_checkpoint('a.ipynb', 'foo')
|
||||
self.assertEqual(r.status_code, 201)
|
||||
cp1 = r.json()
|
||||
self.assertEqual(set(cp1), {'checkpoint_id', 'last_modified'})
|
||||
self.assertEqual(r.headers['Location'].split('/')[-1], cp1['checkpoint_id'])
|
||||
self.assertEqual(set(cp1), {'id', 'last_modified'})
|
||||
self.assertEqual(r.headers['Location'].split('/')[-1], cp1['id'])
|
||||
|
||||
# Modify it
|
||||
nbcontent = jsonapi.loads(resp.text)['content']
|
||||
@ -252,14 +252,14 @@ class APITest(NotebookTestBase):
|
||||
self.assertEqual(nb.worksheets[0].cells[0].source, 'Created by test')
|
||||
|
||||
# Restore cp1
|
||||
r = self.nb_api.restore_checkpoint('a.ipynb', 'foo', cp1['checkpoint_id'])
|
||||
r = self.nb_api.restore_checkpoint('a.ipynb', 'foo', cp1['id'])
|
||||
self.assertEqual(r.status_code, 204)
|
||||
nbcontent = self.nb_api.read('a.ipynb', 'foo').json()['content']
|
||||
nb = to_notebook_json(nbcontent)
|
||||
self.assertEqual(nb.worksheets, [])
|
||||
|
||||
# Delete cp1
|
||||
r = self.nb_api.delete_checkpoint('a.ipynb', 'foo', cp1['checkpoint_id'])
|
||||
r = self.nb_api.delete_checkpoint('a.ipynb', 'foo', cp1['id'])
|
||||
self.assertEqual(r.status_code, 204)
|
||||
cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json()
|
||||
self.assertEqual(cps, [])
|
||||
|
@ -2009,7 +2009,7 @@ var IPython = (function (IPython) {
|
||||
var found = false;
|
||||
for (var i = 0; i < this.checkpoints.length; i++) {
|
||||
var existing = this.checkpoints[i];
|
||||
if (existing.checkpoint_id == checkpoint.checkpoint_id) {
|
||||
if (existing.id == checkpoint.id) {
|
||||
found = true;
|
||||
this.checkpoints[i] = checkpoint;
|
||||
break;
|
||||
@ -2149,7 +2149,7 @@ var IPython = (function (IPython) {
|
||||
Revert : {
|
||||
class : "btn-danger",
|
||||
click : function () {
|
||||
that.restore_checkpoint(checkpoint.checkpoint_id);
|
||||
that.restore_checkpoint(checkpoint.id);
|
||||
}
|
||||
},
|
||||
Cancel : {}
|
||||
|
Loading…
Reference in New Issue
Block a user