Skip to content

Support stripping specified output representations - #1664

Merged
jph00 merged 1 commit into
mainfrom
strip-outputs
Nov 5, 2026
Merged

jph00 merged 1 commit into
mainfrom
strip-outputs

Conversation

@jackhogan

Copy link
Copy Markdown
Contributor

Add support for nbdev-clean removing output representations that a display object marks for stripping.

An output whose metadata carries {"nbdev": {"strip": ["text/html"]}} loses those mimetypes on clean and keeps the rest. A display object sets the flag by returning (data, metadata) from _repr_mimebundle_, which IPython forwards into the output's metadata. The stripping happens before output metadata is filtered, so no allowed_out_metadata_keys entry is needed.

This is for rich outputs that are large, change on every run creating messy diffs, and have a small fallback beside them: e.g. an HTML bundle next to a Markdown or PNG representation. Today a project either commits the bundle or clears every output with clear_all. With the flag, the notebook on disk and github can keep the small representation and the large one is regenerated by running the notebook.

@jackhogan jackhogan self-assigned this Nov 5, 2026
@jackhogan jackhogan added the enhancement New feature or request label Nov 5, 2026
@jackhogan
jackhogan requested a review from jph00 November 5, 2026 16:16
@jph00

jph00 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

This is a really smart approach :)

@jph00
jph00 merged commit 9f3bce3 into main Nov 5, 2026
16 checks passed
@jph00
jph00 deleted the strip-outputs branch November 5, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants