You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementing a NoOpCheckpoints checkpoints class for a custom ContentsManager results in a Unhandled error being raised when opening a notebook in Jupyter Lab.
Reproduce
Create a new ContentsManager class (e.g. subclass FileContentsManager)
Create the NoOpCheckpoints as shown in the documentation
Set the checkpoints_class = NoOpCheckpoints trait
Run Jupyter lab and try creating a new notebook
This will result in client error shown below (screenshot) and in the severs' log (traceback in command line output)
Expected behavior
This should work, or the documentation for NoOpCheckpoints should be changed.
Context
This used to work. I did not manage to find the jupyter part and version (client or server) that has introduced the issue.
Operating System and version: Linux Mint 21.2 Victoria base: Ubuntu 22.04 jammy
Python 3.10.12,
Browser and version: Google Chrome Version 118.0.5993.88 (Official Build) (64-bit)
[W 2023-10-25 11:57:18.899 ServerApp] wrote error: 'Unhandled error'
Traceback (most recent call last):
File "/.../lib/python3.10/site-packages/tornado/web.py", line 1786, in _execute
result = await result
File "/.../python3.10/site-packages/jupyter_server/services/contents/handlers.py", line 311, in post
url_escape(checkpoint["id"]),
TypeError: 'NoneType' object is not subscriptable
[E 2023-10-25 11:57:18.900 ServerApp] {
"Host": "localhost:8888",
"Accept": "*/*",
"Referer": "http://localhost:8888/lab/workspaces/auto-i/tree/Untitled.ipynb",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"
Browser Output
Paste the output from your browser Javascript console here, if applicable.
The text was updated successfully, but these errors were encountered:
Changing the NoOpsCheckpoints implementation slightly removes the issue (added the checkpoint_model() method and called this method in create_file_checkpoint() and create_notebook_checkpoint(), hint taken from FileContentsManager)
from IPython.utils.tz import utcnow
from jupyter_server.services.contents.checkpoints import GenericCheckpointsMixin, Checkpoints
class NoOpCheckpoints(GenericCheckpointsMixin, Checkpoints):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.log.info("**** NoOpCheckpoints initialized")
def checkpoint_model(self):
info = {
"id": "",
"last_modified": utcnow()
}
return info
def create_file_checkpoint(self, content, format, path):
""" -> checkpoint model"""
return self.checkpoint_model()
def create_notebook_checkpoint(self, nb, path):
""" -> checkpoint model"""
return self.checkpoint_model()
def get_file_checkpoint(self, checkpoint_id, path):
""" -> {'type': 'file', 'content': <str>, 'format': {'text', 'base64'}}"""
def get_notebook_checkpoint(self, checkpoint_id, path):
""" -> {'type': 'notebook', 'content': <output of nbformat.read>}"""
def delete_checkpoint(self, checkpoint_id, path):
"""deletes a checkpoint for a file"""
def list_checkpoints(self, path):
"""returns a list of checkpoint models for a given file,
default just does one per file
"""
return []
def rename_checkpoint(self, checkpoint_id, old_path, new_path):
"""renames checkpoint from old path to new path"""
Description
Implementing a
NoOpCheckpoints
checkpoints class for a custom ContentsManager results in aUnhandled error
being raised when opening a notebook in Jupyter Lab.Reproduce
NoOpCheckpoints
as shown in the documentationcheckpoints_class = NoOpCheckpoints
traitExpected behavior
This should work, or the documentation for
NoOpCheckpoints
should be changed.Context
This used to work. I did not manage to find the jupyter part and version (client or server) that has introduced the issue.
Troubleshoot Output
Command Line Output
Browser Output
The text was updated successfully, but these errors were encountered: