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

Projects
None yet
3 participants
@SylvainCorlay
Copy link
Member

SylvainCorlay commented Aug 7, 2018

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

@SylvainCorlay SylvainCorlay force-pushed the SylvainCorlay:used-kernel branch from 5de5123 to c8a8a36 Aug 7, 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 7, 2018

@Carreau

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Member Author

SylvainCorlay commented Aug 7, 2018

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

@SylvainCorlay

This comment has been minimized.

Copy link
Member Author

SylvainCorlay commented Aug 7, 2018

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

This comment has been minimized.

Copy link
Contributor

Carreau commented Aug 8, 2018

@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 SylvainCorlay force-pushed the SylvainCorlay:used-kernel branch from c8a8a36 to 4290236 Aug 8, 2018

@SylvainCorlay

This comment has been minimized.

Copy link
Member Author

SylvainCorlay commented Aug 8, 2018

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.

@SylvainCorlay SylvainCorlay force-pushed the SylvainCorlay:used-kernel branch from 4290236 to 7655d9a Aug 8, 2018

@Carreau

This comment has been minimized.

Copy link
Contributor

Carreau commented Aug 9, 2018

Ok, let's get that in.

@Carreau Carreau merged commit ee1e7e2 into jupyter:master Aug 9, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@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 SylvainCorlay:used-kernel branch Aug 10, 2018

@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