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

Async / asynchronous execution #1092

Open
maartenbreddels opened this issue Aug 23, 2019 · 10 comments
Open

Async / asynchronous execution #1092

maartenbreddels opened this issue Aug 23, 2019 · 10 comments

Comments

@maartenbreddels
Copy link
Collaborator

In voila, we run into a performance problem because nbconvert blocks during the execution of cells voila-dashboards/voila#363. This execution is handled in the tornado handler, causing all other trafic to stop/block.

Are there plans to have nbconvert use the tornado/zmq/ioloop and have a async way of generating cells results?

@MSeal
Copy link
Contributor

MSeal commented Aug 23, 2019

Do you mean for the ExecutePreprocessor or any template conversion in general?

From #1045 we were planning on pulling the execute preprocessor code out of nbconvert, which would be a good opportunity to make it async aware. For other conversions async would probably also be possible in nbconvert 6.0 as we'll be jumping to python 3 only and able to make more dramatic changes in that process.

@bollwyvl
Copy link
Contributor

bollwyvl commented Aug 23, 2019 via email

@kevin-bates
Copy link
Member

Interesting. FWIW - @takluyver asked me to look into getting ExecutePreprocessor (relative to #809) working in a synchronous manner given that we decided to make the new kernel management package only async (see this comment).

But, given this conversation, would it be more worthwhile to see how this behaves in an async manner anyway (also relative to work done in takluyver/jupyter_kernel_mgmt#23)?

Not sure how this effort, in either case, would be affected by #1045 but I think some good data points can be learned in any event.

@MSeal
Copy link
Contributor

MSeal commented Aug 28, 2019

@mpacer had the most interest in spearheading a separate execute package that nbconvert and papermill both imported. I believe she also wanted to support async and synchronous use-cases in this change.

@maartenbreddels
Copy link
Collaborator Author

great. I've been doing some experimentation with using asyncio with voila, and it seems to be working great (tornado is much more responsive). I requires changes/features in jupyter_client, and I think we'd want to not develop this inside of nbconvert. (No PR's open yet)

@mpacer
Copy link
Member

mpacer commented Aug 28, 2019

I'm definitely interested in this, and appreciate folks bringing up this exciting topic!

I am not sure how many cycles I will have free to spearhead it in a reasonable time-frame.

@maartenbreddels I realize you don't have any PRs in nbconvert or jupyter_client, but is there somewhere where we all could look at the code to more fully grok how you're using asyncio with voila?

@mpacer
Copy link
Member

mpacer commented Aug 28, 2019

Seems like using tornado's run_on_executor or a pool, as on nbviewer, might be appropriate for the voila case.

I think that might be a decent stop-gap measure, @bollwyvl could you link to the code on nbviewer that could give folks a starting place for how to implement this for voila?

@maartenbreddels
Copy link
Collaborator Author

Yes, I plan to open a WIP PR for that on Friday, I have to clean up the code a bit, it's a lot of copy/paste + adding async and await at many places. But I'd rather have a bad PR open to start experimenting/discussing.

@maartenbreddels
Copy link
Collaborator Author

Seems like using tornado's run_on_executor or a pool, as on nbviewer, might be appropriate for the voila case.

I think that might be a decent stop-gap measure, @bollwyvl could you link to the code on nbviewer that could give folks a starting place for how to implement this for voila?

@jtpio had a nice PR on that: https://github.com/QuantStack/voila/pull/364/files

But this solution will not work for us since we want to execute cell by cell (async) to allow progressive rendering. What is done in that PR will return the execution after it's done, not after each cell execution.

@maartenbreddels
Copy link
Collaborator Author

A POC for an async jupyter client is jupyter/jupyter_client#471
And voila is using it here: voila-dashboards/voila#374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants