-
Notifications
You must be signed in to change notification settings - Fork 405
Add async contents manager support #1328
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2ef9eb6
add-async-support
Darshan808 40e7c40
add-pytest-asyncio
Darshan808 9a321d9
fix-pre-commit
Darshan808 c40a44b
merge-two-content-manager-files-and-tests
Darshan808 6cacd97
Add an asyncio marker
mwouts aea406f
Add jupyter_server as a dependency
mwouts 7370eb5
Simplify the imports now that jupyter_server is a dependency
mwouts 074a396
jupytext only provides TextFileContentsManager
mwouts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
||
|
||
def load_jupyter_server_extension(app): # pragma: no cover | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.