Show More
@@ -679,41 +679,44 b' class NotebookHandler(IPythonHandler):' | |||||
679 | self.set_status(204) |
|
679 | self.set_status(204) | |
680 | self.finish() |
|
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 | @web.authenticated |
|
687 | @web.authenticated | |
687 | def get(self, notebook_id): |
|
688 | def get(self, notebook_id): | |
688 | """get lists checkpoints for a notebook""" |
|
689 | """get lists checkpoints for a notebook""" | |
689 | nbm = self.application.notebook_manager |
|
690 | nbm = self.application.notebook_manager | |
690 | checkpoints = nbm.list_checkpoints(notebook_id) |
|
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 | @web.authenticated |
|
695 | @web.authenticated | |
694 | def post(self, notebook_id): |
|
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 | """post restores a notebook from a checkpoint""" |
|
710 | """post restores a notebook from a checkpoint""" | |
696 | nbm = self.application.notebook_manager |
|
711 | nbm = self.application.notebook_manager | |
697 | checkpoint_id = self.get_argument('checkpoint', None) |
|
|||
698 | nbm.restore_checkpoint(notebook_id, checkpoint_id) |
|
712 | nbm.restore_checkpoint(notebook_id, checkpoint_id) | |
699 | self.set_status(204) |
|
713 | self.set_status(204) | |
700 | self.finish() |
|
714 | self.finish() | |
701 |
|
715 | |||
702 | @web.authenticated |
|
716 | @web.authenticated | |
703 |
def |
|
717 | def delete(self, notebook_id, checkpoint_id): | |
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): |
|
|||
714 | """delete clears a checkpoint for a given notebook""" |
|
718 | """delete clears a checkpoint for a given notebook""" | |
715 | nbm = self.application.notebook_manager |
|
719 | nbm = self.application.notebook_manager | |
716 | checkpoint_id = self.get_argument('checkpoint', None) |
|
|||
717 | nbm.delte_checkpoint(notebook_id, checkpoint_id) |
|
720 | nbm.delte_checkpoint(notebook_id, checkpoint_id) | |
718 | self.set_status(204) |
|
721 | self.set_status(204) | |
719 | self.finish() |
|
722 | self.finish() |
@@ -68,9 +68,9 b' from .handlers import (LoginHandler, LogoutHandler,' | |||||
68 | ProjectDashboardHandler, NewHandler, NamedNotebookHandler, |
|
68 | ProjectDashboardHandler, NewHandler, NamedNotebookHandler, | |
69 | MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler, StdinHandler, |
|
69 | MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler, StdinHandler, | |
70 | ShellHandler, NotebookRootHandler, NotebookHandler, NotebookCopyHandler, |
|
70 | ShellHandler, NotebookRootHandler, NotebookHandler, NotebookCopyHandler, | |
71 | AuthenticatedFileHandler, MainClusterHandler, ClusterProfileHandler, |
|
71 | NotebookRedirectHandler, NotebookCheckpointsHandler, ModifyNotebookCheckpointsHandler, | |
72 |
|
|
72 | AuthenticatedFileHandler, FileFindHandler, | |
73 | NotebookRedirectHandler, NotebookCheckpointHandler, |
|
73 | MainClusterHandler, ClusterProfileHandler, ClusterActionHandler, | |
74 | ) |
|
74 | ) | |
75 | from .nbmanager import NotebookManager |
|
75 | from .nbmanager import NotebookManager | |
76 | from .filenbmanager import FileNotebookManager |
|
76 | from .filenbmanager import FileNotebookManager | |
@@ -105,6 +105,7 b' _kernel_id_regex = r"(?P<kernel_id>\\w+-\\w+-\\w+-\\w+-\\w+)"' | |||||
105 | _kernel_action_regex = r"(?P<action>restart|interrupt)" |
|
105 | _kernel_action_regex = r"(?P<action>restart|interrupt)" | |
106 | _notebook_id_regex = r"(?P<notebook_id>\w+-\w+-\w+-\w+-\w+)" |
|
106 | _notebook_id_regex = r"(?P<notebook_id>\w+-\w+-\w+-\w+-\w+)" | |
107 | _notebook_name_regex = r"(?P<notebook_name>.+\.ipynb)" |
|
107 | _notebook_name_regex = r"(?P<notebook_name>.+\.ipynb)" | |
|
108 | _checkpoint_id_regex = r"(?P<checkpoint_id>[\w-]+)" | |||
108 | _profile_regex = r"(?P<profile>[^\/]+)" # there is almost no text that is invalid |
|
109 | _profile_regex = r"(?P<profile>[^\/]+)" # there is almost no text that is invalid | |
109 | _cluster_action_regex = r"(?P<action>start|stop)" |
|
110 | _cluster_action_regex = r"(?P<action>start|stop)" | |
110 |
|
111 | |||
@@ -162,7 +163,10 b' class NotebookWebApplication(web.Application):' | |||||
162 | (r"/kernels/%s/stdin" % _kernel_id_regex, StdinHandler), |
|
163 | (r"/kernels/%s/stdin" % _kernel_id_regex, StdinHandler), | |
163 | (r"/notebooks", NotebookRootHandler), |
|
164 | (r"/notebooks", NotebookRootHandler), | |
164 | (r"/notebooks/%s" % _notebook_id_regex, NotebookHandler), |
|
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 | (r"/files/(.*)", AuthenticatedFileHandler, {'path' : notebook_manager.notebook_dir}), |
|
170 | (r"/files/(.*)", AuthenticatedFileHandler, {'path' : notebook_manager.notebook_dir}), | |
167 | (r"/clusters", MainClusterHandler), |
|
171 | (r"/clusters", MainClusterHandler), | |
168 | (r"/clusters/%s/%s" % (_profile_regex, _cluster_action_regex), ClusterActionHandler), |
|
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