Skip to content

Configure nbstripout pre-commit hook to strip notebook metadata#21

Merged
accorvin merged 1 commit into
red-hat-data-services:mainfrom
tarun-etikala:nbstripout-hook
Dec 1, 2025
Merged

Configure nbstripout pre-commit hook to strip notebook metadata#21
accorvin merged 1 commit into
red-hat-data-services:mainfrom
tarun-etikala:nbstripout-hook

Conversation

@tarun-etikala
Copy link
Copy Markdown
Contributor

Adds nbstripout configuration to the pre-commit hooks to automatically clean Jupyter notebooks of environment-specific metadata, execution outputs, and UI preferences while preserving cell IDs. This ensures cleaner git diffs, smaller notebooks, and fewer merge conflicts.

Related Tickets

Type of change

  • New feature (non-breaking change which adds functionality)

@accorvin
Copy link
Copy Markdown
Member

accorvin commented Dec 1, 2025

Will this remove logging for executed cells? I think it could be very valid to want that data to be preserved in git so that examples can show expected output.

Copy link
Copy Markdown
Contributor

@shricharan-ks shricharan-ks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tarun-etikala
Copy link
Copy Markdown
Contributor Author

Will this remove logging for executed cells? I think it could be very valid to want that data to be preserved in git so that examples can show expected output.

By default, nbstripout removes all the notebook outputs but some of the logs which are required can be preserved by tagging specific cells with keep_output or can exclude complete notebook.
It is a good practice to remove the cell outputs to avoid messy merge conflicts, repository bloat with png(plots). But we can have the keep_output tag to commit essential output to display an expected output whenever required.

@accorvin accorvin merged commit d3ba4bd into red-hat-data-services:main Dec 1, 2025
3 checks passed
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.

3 participants