Skip to content

Fix invalid notebooks by keeping execution_count as null (Issue #19)#29

Merged
peytondmurray merged 2 commits intodeshaw:mainfrom
adsepuri35:advait/preserve-execution-count
Mar 16, 2026
Merged

Fix invalid notebooks by keeping execution_count as null (Issue #19)#29
peytondmurray merged 2 commits intodeshaw:mainfrom
adsepuri35:advait/preserve-execution-count

Conversation

@adsepuri35
Copy link
Copy Markdown
Contributor

Fixes Issue #19

When running nbstripout-fast with --keep-output and without --keep-count, the execution_count field was being removed. execution_count is required by nbformat, so we got invalid notebooks.

The PR sets execution_count to null instead of deleting it, keeping valid notebook structure.

Validation

cargo run -- --keep-output -t tests/test_notebook.ipynb > /tmp/stripped.ipynb

python3 - <<'EOF'
import nbformat
from nbformat.validator import validate
nb = nbformat.read('/tmp/stripped.ipynb', as_version=4)
validate(nb)
print("OK")
EOF

@mlucool mlucool requested a review from peytondmurray March 10, 2026 00:24
@peytondmurray peytondmurray merged commit ac9d35b into deshaw:main Mar 16, 2026
19 checks passed
@peytondmurray
Copy link
Copy Markdown
Collaborator

Thank you for the contribution! Merged.

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.

2 participants