def _get_checkpoint_notebooks(self, base): # Get the model for the current notebook: cm = self.contents_manager model = yield gen.maybe_future( cm.get(base, content=True, type='notebook')) remote_nb = model['content'] # Get the model for the checkpoint notebook: checkpoints = yield gen.maybe_future(cm.list_checkpoints(base)) if not checkpoints: # No checkpoints, indicate unchanged: self.log.info('No checkpoints for file: %r, %r', base, checkpoints) raise gen.Return((remote_nb, remote_nb)) self.log.debug('Checkpoints: %r', checkpoints) checkpoint = checkpoints[0] if isinstance(cm.checkpoints, GenericCheckpointsMixin): checkpoint_model = yield gen.maybe_future( cm.checkpoints.get_notebook_checkpoint(checkpoint, base)) base_nb = checkpoint_model['content'] elif isinstance(cm.checkpoints, FileCheckpoints): path = yield gen.maybe_future( cm.checkpoints.checkpoint_path(checkpoint['id'], base)) base_nb = read_notebook(path, on_null='minimal') else: raise RuntimeError('Unknown checkpoint handler interface') raise gen.Return((base_nb, remote_nb))
def _get_checkpoint_notebooks(self, base): # Get the model for the current notebook: cm = self.contents_manager model = yield gen.maybe_future(cm.get(base, content=True, type='notebook')) remote_nb = model['content'] # Get the model for the checkpoint notebook: checkpoints = yield gen.maybe_future(cm.list_checkpoints(base)) if not checkpoints: # No checkpoints, indicate unchanged: self.log.info('No checkpoints for file: %r, %r', base, checkpoints) raise gen.Return((remote_nb, remote_nb)) self.log.debug('Checkpoints: %r', checkpoints) checkpoint = checkpoints[0] if isinstance(cm.checkpoints, GenericCheckpointsMixin): checkpoint_model = yield gen.maybe_future( cm.checkpoints.get_notebook_checkpoint(checkpoint, base)) base_nb = checkpoint_model['content'] elif isinstance(cm.checkpoints, FileCheckpoints): path = yield gen.maybe_future( cm.checkpoints.checkpoint_path(checkpoint['id'], base)) base_nb = read_notebook(path, on_null='minimal') else: raise RuntimeError('Unknown checkpoint handler interface') raise gen.Return((base_nb, remote_nb))
def shutdown_request(self, stream, ident, parent): if os.environ.get("NO_SHUTDOWN_REPLY") != "1": yield gen.maybe_future(super().shutdown_request( stream, ident, parent))