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

Allow the execute preprocessor to make use of an existing kernel #852

Merged
merged 1 commit into from
Aug 9, 2018

Conversation

SylvainCorlay
Copy link
Member

@SylvainCorlay SylvainCorlay commented Aug 7, 2018

@Carreau this appears to be working and doing what I need.

@SylvainCorlay SylvainCorlay changed the title WIP: Allow the execute preprocessor to make use of an existing kernel Allow the execute preprocessor to make use of an existing kernel Aug 7, 2018
@Carreau
Copy link
Member

Carreau commented Aug 7, 2018

LGTM, does this allow you to both pass a already tarted kernel and not stop it at the end ?

@SylvainCorlay
Copy link
Member Author

Yes, if a kernel is passed to the preprocessor, it won't try to shut it down.

@SylvainCorlay
Copy link
Member Author

from nbconvert.preprocessors.execute import executenb, ExecutePreprocessor
from nbformat import read as nbread
from jupyter_client.manager import start_new_kernel
 
nb = nbread('parsee.ipynb', as_version=4)
kernel_name = nb.metadata.get('kernelspec', {}).get('name', 'python')
km, kc = start_new_kernel(kernel_name=kernel_name)
executenb(nb, kernel=(km, kc))
kc.execute_interactive('a')  # a is a variable defined in parsee.ipynb with 'a = 1'

@Carreau
Copy link
Member

Carreau commented Aug 8, 2018 via email

@SylvainCorlay SylvainCorlay changed the title Allow the execute preprocessor to make use of an existing kernel WIP. Allow the execute preprocessor to make use of an existing kernel Aug 8, 2018
@SylvainCorlay
Copy link
Member Author

It should not change anything for papermill because start_new_kernel still is there and behaves the same when you don't provide a kernel manager.

@Carreau
Copy link
Member

Carreau commented Aug 9, 2018

Ok, let's get that in.

@Carreau Carreau merged commit ee1e7e2 into jupyter:master Aug 9, 2018
@SylvainCorlay SylvainCorlay changed the title WIP. Allow the execute preprocessor to make use of an existing kernel Allow the execute preprocessor to make use of an existing kernel Aug 9, 2018
@SylvainCorlay SylvainCorlay deleted the used-kernel branch August 10, 2018 15:34
@mpacer mpacer added this to the 5.4 milestone Sep 4, 2018
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

Successfully merging this pull request may close these issues.

3 participants