-
Notifications
You must be signed in to change notification settings - Fork 395
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
base: main
Are you sure you want to change the base?
Conversation
Thank you for making this pull request. Did you know? You can try it on Binder: Also, the version of Jupytext developed in this PR can be installed with
(this requires |
@mwouts As we begin merging these two files, should we wrap all asynchronous functions (that might be synchronous in the synchronous contents manager) using Looking forward to your thoughts! |
Wow, thank you @Darshan808 , this is truly amazing!! Let me have a look! |
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.
Thank you @Darshan808 , I love what I see so far!
As we begin merging these two files, should we wrap all asynchronous functions (that might be synchronous in the synchronous contents manager) using
ensure_async()
, similar to what was done in #1021?
Do you think it would be possible to do so? It would be great indeed if we had a more local change - easier to review, and just one file to maintain later on. But I must admit that it's precisely what I was not able to do two years ago so no obligation at all!
try: | ||
from jupytext.async_contentsmanager import build_jupytext_async_contents_manager_class | ||
except ImportError as err: | ||
build_jupytext_async_contents_manager = reraise(err) |
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.
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 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.
Re the failing pre-commit hook on the CI you probably just need |
@mwouts |
Locally I checked only |
Hi @Darshan808 , thanks for the update, and no worries for the remaining failures, that's a big change you know! Also I hope you're fine with me pushing a few commits here. One thing that we need to confirm is the following: are we fine with Async contents manager are a bit more complicated to use in tests, so that could be an incentive to provide a sync version, but I think that it has been a while since async contents manager were introduced so it's probably fine to have just them. In case we wanted both, do you think we could write a second function e.g. |
which is derivated from AsyncLargeFileManager
Yes - I think that relates to my comment above, now every contents manager class returned by I'd recommend to not worry about the remaining tests for now, but rather chat a bit more about whether we want/can provide a sync contents manager (assuming e.g. the base class is sync). |
Re creating a class with synchronous methods I have tried this: e198928:
but then I run into |
I've been thinking about this and I am tempted to try the following:
Let me know what you think! => I've created that PR: #1329 (did not have the time to run all tests yet) |
Fixes #1316
This PR introduces support for an async contents manager. As suggested by @mwouts in #1316, a separate function,
build_jupytext_async_contents_manager
, has been implemented in a new file,async_contentsmanager.py
.To ensure full test coverage, the existing tests have been duplicated into
test_async_contentsmanager.py
. Currently, all tests are passing! ✅