Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add async contents manager support #1328

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
22 changes: 1 addition & 21 deletions jupyterlab/jupyterlab_jupytext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
"""Jupyter server and lab extension entry points"""

import asyncio

from jupytext.reraise import reraise

try:
from jupytext.contentsmanager import build_jupytext_contents_manager_class
except ImportError as err:
build_jupytext_contents_manager = reraise(err)
from jupytext.contentsmanager import build_jupytext_contents_manager_class


def load_jupyter_server_extension(app): # pragma: no cover
Expand All @@ -22,20 +15,7 @@ def load_jupyter_server_extension(app): # pragma: no cover
# The server extension call is too late!
# The contents manager was set at NotebookApp.init_configurables

# 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

app.log.info(
"[Jupytext Server Extension] Deriving a JupytextContentsManager "
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ classifiers = [
]
dependencies = [
"nbformat",
"jupyter_server",
"mdit-py-plugins",
"markdown-it-py>=1.0",
"packaging",
Expand All @@ -50,6 +51,7 @@ Documentation = "https://jupytext.readthedocs.io"
# Test related dependencies
test = [
"pytest",
"pytest-asyncio",
"pytest-xdist",
"pytest-randomly"
]
Expand Down Expand Up @@ -205,6 +207,7 @@ markers = [
"requires_ir_kernel",
"skip_on_windows",
"pre_commit",
"asyncio"
]
filterwarnings = [
# Uncomment this "error" to turn all unfiltered warnings into errors
Expand Down
15 changes: 4 additions & 11 deletions src/jupytext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
"""Read and write Jupyter notebooks as text files"""

from .contentsmanager import (
TextFileContentsManager,
build_jupytext_contents_manager_class,
)
from .formats import NOTEBOOK_EXTENSIONS, get_format_implementation, guess_format
from .jupytext import read, reads, write, writes
from .reraise import reraise
from .version import __version__

try:
from .contentsmanager import build_jupytext_contents_manager_class
except ImportError as err:
build_jupytext_contents_manager_class = reraise(err)

try:
from .contentsmanager import TextFileContentsManager
except ImportError as err:
TextFileContentsManager = reraise(err)

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