Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions jupyterlab/jupyterlab_jupytext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from jupytext.contentsmanager import build_jupytext_contents_manager_class
except ImportError as err:
build_jupytext_contents_manager = reraise(err)
try:
from jupytext.async_contentsmanager import build_jupytext_async_contents_manager_class
except ImportError as err:
build_jupytext_async_contents_manager = reraise(err)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's the most prudent approach, thank you! The import problem was years ago though, so maybe it's gone, but it's safer that I follow-up on that later on.



def load_jupyter_server_extension(app): # pragma: no cover
Expand All @@ -24,24 +28,27 @@ def load_jupyter_server_extension(app): # pragma: no cover

# If possible, we derive a Jupytext CM from the current CM
base_class = app.contents_manager_class
if asyncio.iscoroutinefunction(base_class.get):
app.log.warning(
f"[Jupytext Server Extension] Async contents managers like {base_class.__name__} "
"are not supported at the moment "
"(https://github.com/mwouts/jupytext/issues/1020). "
"We will derive a contents manager from LargeFileManager instead."
)
from jupyter_server.services.contents.largefilemanager import ( # noqa
LargeFileManager,
)

base_class = LargeFileManager
# if asyncio.iscoroutinefunction(base_class.get):
# app.log.warning(
# f"[Jupytext Server Extension] Async contents managers like {base_class.__name__} "
# "are not supported at the moment "
# "(https://github.com/mwouts/jupytext/issues/1020). "
# "We will derive a contents manager from LargeFileManager instead."
# )
# from jupyter_server.services.contents.largefilemanager import ( # noqa
# LargeFileManager,
# )

# base_class = LargeFileManager

app.log.info(
"[Jupytext Server Extension] Deriving a JupytextContentsManager "
"from {}".format(base_class.__name__)
)
app.contents_manager_class = build_jupytext_contents_manager_class(base_class)
if asyncio.iscoroutinefunction(base_class.get):
app.contents_manager_class = build_jupytext_async_contents_manager_class(base_class)
else:
app.contents_manager_class = build_jupytext_contents_manager_class(base_class)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly what I had in mind! And we can delete the paragraph above.


try:
# And rerun selected init steps from https://github.com/jupyter/notebook/blob/
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Documentation = "https://jupytext.readthedocs.io"
# Test related dependencies
test = [
"pytest",
"pytest-asyncio",
"pytest-xdist",
"pytest-randomly"
]
Expand Down
5 changes: 5 additions & 0 deletions src/jupytext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
except ImportError as err:
TextFileContentsManager = reraise(err)

try:
from .async_contentsmanager import AsyncTextFileContentsManager
except ImportError as err:
AsyncTextFileContentsManager = reraise(err)

__all__ = [
"read",
"write",
Expand Down
Loading
Loading