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 custom implementations of nb_kernel_name and nb_language in papermill engines #676

Conversation

rohitsanj
Copy link
Member

@rohitsanj rohitsanj commented Aug 4, 2022

Context behind this PR

At Noteable, we came across a use-case where parametrized executions with a custom Noteable engine were not working because papermill expects the kernel_name to be present in the kernelspec of the notebook if kernel_name was not explicitly passed in as a kwarg. It throws a ValueError with the message "No kernel name found in notebook and no override provided.". Like so,

>>> pm.execute_notebook(
        f'noteable://{file_id}', 
        'foo.ipynb', 
        engine_name='noteable'
        # custom Noteable kwargs
        file=file, 
        client=client, 
        log_output=True,
    )
...
ValueError: No kernel name found in notebook and no override provided.

What does this PR do?

This PR allows the extended engine to define custom business logic for the following:

  • fetching kernel name from the notebook object by implementing the nb_kernel_name method
  • fetching programming language from the notebook object by implementing the nb_language method

@codecov
Copy link

codecov bot commented Aug 4, 2022

Codecov Report

Merging #676 (c4271aa) into main (98013f0) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #676      +/-   ##
==========================================
+ Coverage   91.72%   91.78%   +0.05%     
==========================================
  Files          17       17              
  Lines        1583     1594      +11     
==========================================
+ Hits         1452     1463      +11     
  Misses        131      131              
Impacted Files Coverage Δ
papermill/engines.py 98.37% <100.00%> (+0.09%) ⬆️
papermill/execute.py 100.00% <100.00%> (ø)
papermill/parameterize.py 98.00% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98013f0...c4271aa. Read the comment docs.

@rohitsanj rohitsanj marked this pull request as ready for review August 4, 2022 22:47
@rohitsanj rohitsanj marked this pull request as draft August 4, 2022 23:16
@rohitsanj rohitsanj marked this pull request as ready for review August 4, 2022 23:41
@MSeal MSeal merged commit 9f02383 into nteract:main Aug 8, 2022
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.

None yet

2 participants