Skip to content

Commit 5868765

Browse files
martinRenouMSeal
andauthored
Always upgrade the Notebook before writing into it (#691)
Co-authored-by: Matthew Seal <[email protected]>
1 parent 6921f8a commit 5868765

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

papermill/execute.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ def raise_for_execution_errors(nb, output_path):
223223
error_anchor_cell = nbformat.v4.new_markdown_cell(ERROR_ANCHOR_MSG)
224224
error_anchor_cell.metadata['tags'] = [ERROR_MARKER_TAG]
225225

226+
# Upgrade the Notebook to the latest v4 before writing into it
227+
nb = nbformat.v4.upgrade(nb)
228+
226229
# put the anchor before the cell with the error, before all the indices change due to the
227230
# heading-prepending
228231
nb.cells.insert(error.cell_index, error_anchor_cell)

papermill/parameterize.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def parameterize_notebook(
8989
# Generate parameter content based on the kernel_name
9090
param_content = translate_parameters(kernel_name, language, parameters, comment)
9191

92+
# Upgrade the Notebook to the latest v4 before writing into it
93+
nb = nbformat.v4.upgrade(nb)
94+
9295
newcell = nbformat.v4.new_code_cell(source=param_content)
9396
newcell.metadata['tags'] = ['injected-parameters']
9497

0 commit comments

Comments
 (0)