Show More
@@ -679,41 +679,44 b' class NotebookHandler(IPythonHandler):' | |||
|
679 | 679 | self.set_status(204) |
|
680 | 680 | self.finish() |
|
681 | 681 | |
|
682 | class NotebookCheckpointHandler(AuthenticatedHandler): | |
|
683 | 682 | |
|
684 | SUPPORTED_METHODS = ('GET', 'POST', 'PUT', 'DELETE') | |
|
683 | class NotebookCheckpointsHandler(AuthenticatedHandler): | |
|
684 | ||
|
685 | SUPPORTED_METHODS = ('GET', 'POST') | |
|
685 | 686 | |
|
686 | 687 | @web.authenticated |
|
687 | 688 | def get(self, notebook_id): |
|
688 | 689 | """get lists checkpoints for a notebook""" |
|
689 | 690 | nbm = self.application.notebook_manager |
|
690 | 691 | checkpoints = nbm.list_checkpoints(notebook_id) |
|
691 | self.finish(checkpoints) | |
|
692 | data = jsonapi.dumps(checkpoints, default=date_default) | |
|
693 | self.finish(data) | |
|
692 | 694 | |
|
693 | 695 | @web.authenticated |
|
694 | 696 | def post(self, notebook_id): |
|
697 | """post creates a new checkpoint""" | |
|
698 | nbm = self.application.notebook_manager | |
|
699 | checkpoint = nbm.create_checkpoint(notebook_id) | |
|
700 | data = jsonapi.dumps(checkpoint, default=date_default) | |
|
701 | self.finish(data) | |
|
702 | ||
|
703 | ||
|
704 | class ModifyNotebookCheckpointsHandler(AuthenticatedHandler): | |
|
705 | ||
|
706 | SUPPORTED_METHODS = ('POST', 'DELETE') | |
|
707 | ||
|
708 | @web.authenticated | |
|
709 | def post(self, notebook_id, checkpoint_id): | |
|
695 | 710 | """post restores a notebook from a checkpoint""" |
|
696 | 711 | nbm = self.application.notebook_manager |
|
697 | checkpoint_id = self.get_argument('checkpoint', None) | |
|
698 | 712 | nbm.restore_checkpoint(notebook_id, checkpoint_id) |
|
699 | 713 | self.set_status(204) |
|
700 | 714 | self.finish() |
|
701 | 715 | |
|
702 | 716 | @web.authenticated |
|
703 |
def |
|
|
704 | """put saves the notebook, and creates a new checkpoint""" | |
|
705 | nbm = self.application.notebook_manager | |
|
706 | format = self.get_argument('format', default='json') | |
|
707 | name = self.get_argument('name', default=None) | |
|
708 | nbm.save_notebook(notebook_id, self.request.body, name=name, format=format) | |
|
709 | checkpoint = nbm.create_checkpoint(notebook_id) | |
|
710 | self.finish(checkpoint) | |
|
711 | ||
|
712 | @web.authenticated | |
|
713 | def delete(self, notebook_id): | |
|
717 | def delete(self, notebook_id, checkpoint_id): | |
|
714 | 718 | """delete clears a checkpoint for a given notebook""" |
|
715 | 719 | nbm = self.application.notebook_manager |
|
716 | checkpoint_id = self.get_argument('checkpoint', None) | |
|
717 | 720 | nbm.delte_checkpoint(notebook_id, checkpoint_id) |
|
718 | 721 | self.set_status(204) |
|
719 | 722 | self.finish() |
@@ -68,9 +68,9 b' from .handlers import (LoginHandler, LogoutHandler,' | |||
|
68 | 68 | ProjectDashboardHandler, NewHandler, NamedNotebookHandler, |
|
69 | 69 | MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler, StdinHandler, |
|
70 | 70 | ShellHandler, NotebookRootHandler, NotebookHandler, NotebookCopyHandler, |
|
71 | AuthenticatedFileHandler, MainClusterHandler, ClusterProfileHandler, | |
|
72 |
|
|
|
73 | NotebookRedirectHandler, NotebookCheckpointHandler, | |
|
71 | NotebookRedirectHandler, NotebookCheckpointsHandler, ModifyNotebookCheckpointsHandler, | |
|
72 | AuthenticatedFileHandler, FileFindHandler, | |
|
73 | MainClusterHandler, ClusterProfileHandler, ClusterActionHandler, | |
|
74 | 74 | ) |
|
75 | 75 | from .nbmanager import NotebookManager |
|
76 | 76 | from .filenbmanager import FileNotebookManager |
@@ -105,6 +105,7 b' _kernel_id_regex = r"(?P<kernel_id>\\w+-\\w+-\\w+-\\w+-\\w+)"' | |||
|
105 | 105 | _kernel_action_regex = r"(?P<action>restart|interrupt)" |
|
106 | 106 | _notebook_id_regex = r"(?P<notebook_id>\w+-\w+-\w+-\w+-\w+)" |
|
107 | 107 | _notebook_name_regex = r"(?P<notebook_name>.+\.ipynb)" |
|
108 | _checkpoint_id_regex = r"(?P<checkpoint_id>[\w-]+)" | |
|
108 | 109 | _profile_regex = r"(?P<profile>[^\/]+)" # there is almost no text that is invalid |
|
109 | 110 | _cluster_action_regex = r"(?P<action>start|stop)" |
|
110 | 111 | |
@@ -162,7 +163,10 b' class NotebookWebApplication(web.Application):' | |||
|
162 | 163 | (r"/kernels/%s/stdin" % _kernel_id_regex, StdinHandler), |
|
163 | 164 | (r"/notebooks", NotebookRootHandler), |
|
164 | 165 | (r"/notebooks/%s" % _notebook_id_regex, NotebookHandler), |
|
165 | (r"/notebooks/%s/checkpoint" % _notebook_id_regex, NotebookCheckpointHandler), | |
|
166 | (r"/notebooks/%s/checkpoints" % _notebook_id_regex, NotebookCheckpointsHandler), | |
|
167 | (r"/notebooks/%s/checkpoints/%s" % (_notebook_id_regex, _checkpoint_id_regex), | |
|
168 | ModifyNotebookCheckpointsHandler | |
|
169 | ), | |
|
166 | 170 | (r"/files/(.*)", AuthenticatedFileHandler, {'path' : notebook_manager.notebook_dir}), |
|
167 | 171 | (r"/clusters", MainClusterHandler), |
|
168 | 172 | (r"/clusters/%s/%s" % (_profile_regex, _cluster_action_regex), ClusterActionHandler), |
General Comments 0
You need to be logged in to leave comments.
Login now