Skip to content

Commit

Permalink
Changed parameter inspection to reuse utils funcs (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSeal authored Nov 2, 2023
1 parent a9d2686 commit 8f16a9f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## Unreleased

- Changed parameter inspection to raise the same error messages as other pathways for missing kernel name and language

## 2.5.0

- Added support for python 3.11 and 3.12 [PR #733](https://github.com/nteract/papermill/pull/733)
Expand Down
2 changes: 1 addition & 1 deletion papermill/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def execute_notebook(

# Parameterize the Notebook.
if parameters:
parameter_predefined = _infer_parameters(nb)
parameter_predefined = _infer_parameters(nb, name=kernel_name, language=language)
parameter_predefined = {p.name for p in parameter_predefined}
for p in parameters:
if p not in parameter_predefined:
Expand Down
9 changes: 5 additions & 4 deletions papermill/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .log import logger
from .parameterize import add_builtin_parameters, parameterize_path
from .translators import papermill_translators
from .utils import any_tagged_cell, find_first_tagged_cell_index
from .utils import any_tagged_cell, find_first_tagged_cell_index, nb_kernel_name, nb_language


def _open_notebook(notebook_path, parameters):
Expand All @@ -19,7 +19,7 @@ def _open_notebook(notebook_path, parameters):
return load_notebook_node(input_path)


def _infer_parameters(nb):
def _infer_parameters(nb, name=None, language=None):
"""Infer the notebook parameters.
Parameters
Expand All @@ -38,8 +38,9 @@ def _infer_parameters(nb):
if parameter_cell_idx < 0:
return params
parameter_cell = nb.cells[parameter_cell_idx]
kernel_name = nb.metadata.kernelspec.name
language = nb.metadata.kernelspec.language

kernel_name = nb_kernel_name(nb, name)
language = nb_language(nb, language)

translator = papermill_translators.find_translator(kernel_name, language)
try:
Expand Down

0 comments on commit 8f16a9f

Please sign in to comment.