Skip to content

Commit

Permalink
fix issues related to jupyter lab
Browse files Browse the repository at this point in the history
  • Loading branch information
miraculixx committed Oct 25, 2023
1 parent a3de3a0 commit 372f12b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
22 changes: 21 additions & 1 deletion omegaml/notebook/checkpoints.py
@@ -1,22 +1,42 @@
from IPython.utils.tz import utcnow
from jupyter_server.services.contents.checkpoints import GenericCheckpointsMixin, Checkpoints


class NoOpCheckpoints(GenericCheckpointsMixin, Checkpoints):
"""requires the following methods:"""
# source: https://jupyter-server.readthedocs.io/en/latest/developers/contents.html
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"""
12 changes: 5 additions & 7 deletions omegaml/notebook/omegacontentsmgr.py
@@ -1,9 +1,8 @@
import mimetypes
from base64 import encodebytes, decodebytes

import json
import mimetypes
import nbformat
import os
from base64 import encodebytes, decodebytes
from datetime import datetime
from io import BytesIO
from jupyter_server.services.contents.manager import ContentsManager
Expand All @@ -21,17 +20,16 @@ class OmegaStoreContentsManager(ContentsManager):
Adopted from notebook/services/contents/filemanager.py
This requires a properly configured omegaml instance.
see http://jupyter-notebook.readthedocs.io/en/stable/extending/contents.html
see https://jupyter-server.readthedocs.io/en/latest/developers/contents.html
"""

checkpoints_class = NoOpCheckpoints

def __init__(self, **kwargs):
# pass omega= for testing purpose
self._omega = kwargs.pop('omega', None)
super(OmegaStoreContentsManager, self).__init__(**kwargs)

def _checkpoints_class_default(self):
return NoOpCheckpoints

@property
def omega(self):
"""
Expand Down

0 comments on commit 372f12b

Please sign in to comment.