jupyter / jupyter/nbformat

Papermill Incompatibility with VS Code Generated Notebooks

Open
#393 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
313
Forks
176
PR merge metrics
No merged PRs in 30d

Description

Hi :) Not necessarily a "bug", but more of a suggestion for the API - currently, `nbformat.v4.upgrade` outputs None if the notebook is already in v4, which might be a reasonable thing to do (to indicate that no change is necessary), but note that `papermill` does the following

```
# Upgrade the Notebook to the latest v4 before writing into it
nb = nbformat.v4.upgrade(nb)
```

without a check for None. This means if the notebook was already in v4 papermill breaks (which I discovered due to, well, papermill breaking!

So the solutions are either to modify papermill, or (and this is where I'd ask for your advice), maybe the upgrade function should just return nb? For what it's worth, this is the current code (`nbformat/v4/convert.py`, line 73)

```
elif from_version == 4:
if from_minor == nbformat_minor:
return
```

but when I delete the return line, Copilot prefers to fill in

```
elif from_version == 4:
if from_minor == nbformat_minor:
return nb
```

which might be a somewhat objective way to show that this is the more intuitive API?

Contributor guide

Open the contributing guide

Research direction

Start with nbformat/v4/convert.py around line 73 and trace the already-v4 branch. Compare its return value with papermill’s shown nbformat.v4.upgrade call, then determine and verify the intended behavior for an already-v4 notebook. Done means the API and its consumer no longer disagree about the upgrade result.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.