Skip to content

Commit

Permalink
Allow to import from either jupyter_server or notebook packages
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezg authored May 4, 2023
1 parent 8239217 commit 60819d1
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions s3contents/ipycompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,23 @@
Checkpoints,
GenericCheckpointsMixin,
)
from notebook.services.contents.filecheckpoints import GenericFileCheckpoints
from notebook.services.contents.filemanager import FileContentsManager
from notebook.services.contents.manager import ContentsManager

# Ref. https://github.com/jupyter/nbdime/blob/c82362344e596efdc4f54c927d90338940e0fa41/nbdime/webapp/nb_server_extension.py#L16-L33
# This allows solving conflicts between the class import from either notebook or jupyter_server
try:
from notebook.services.contents.filecheckpoints import GenericFileCheckpoints
from notebook.services.contents.filemanager import FileContentsManager
from notebook.services.contents.manager import ContentsManager
except ModuleNotFoundError:
pass

try:
from jupyter_server.services.contents.filecheckpoints import GenericFileCheckpoints
from jupyter_server.services.contents.filemanager import FileContentsManager
from jupyter_server.services.contents.manager import ContentsManager
except ModuleNotFoundError:
pass

from notebook.utils import to_os_path
from traitlets import (
Any,
Expand Down

0 comments on commit 60819d1

Please sign in to comment.