Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom blacklist metadata fields #92

Merged
merged 15 commits into from
Mar 26, 2019
Merged

custom blacklist metadata fields #92

merged 15 commits into from
Mar 26, 2019

Conversation

casperdcl
Copy link
Contributor

@casperdcl casperdcl commented Feb 5, 2019

Complements #86

  • support metadata
  • support cell.metadata
  • fix strip output extension data/metadata #85
    • custom top level metadata (e.g. metadata.toc)
    • custom top levels cell.metadata (e.g. cell.metadata.heading_collapsed
  • fix Metadata python version attribute #72
    • top-level
      • metadata.kernel_spec
      • metadata.language_info
    • nested only
      • metadata.kernel_spec.display_name
      • metadata.kernel_spec.name
      • metadata.language_info.codemirror_mode.version
      • metadata.language_info.pygments_lexer
      • metadata.language_info.version
  • possibly support non-metadata fields?
  • add tests
    • modularise/package to fix tests
  • add documentation
  • bump version

This is configurable via git config (--global) filter.nbstripout.extrakeys. An example would be:

git config --global filter.nbstripout.extrakeys \
  'metadata.toc cell.metadata.heading_collapsed cell.metadata.hidden cell.metadata.code_folding'

nbstripout.py Outdated Show resolved Hide resolved
nbstripout.py Outdated Show resolved Hide resolved
nbstripout.py Outdated Show resolved Hide resolved
nbstripout.py Show resolved Hide resolved
nbstripout.py Outdated Show resolved Hide resolved
nbstripout.py Outdated Show resolved Hide resolved
tests/test-git.t Outdated Show resolved Hide resolved
@kynan
Copy link
Owner

kynan commented Feb 12, 2019

Python 3 tests are failing now, however I can't quite see how that's related to your changes.

pytest.ini Outdated Show resolved Hide resolved
@dnhuizen
Copy link

This is a much needed feature, thanks for jumping on this: With Papermill gaining in popularity it is great to be able to strip out Papermill related metadata

@casperdcl
Copy link
Contributor Author

OK @kynan @dnhuizen I think this is ready for merge. Should really bump the version number when that's done.

@kynan kynan merged commit 7fdb961 into kynan:master Mar 26, 2019
@kynan
Copy link
Owner

kynan commented Mar 26, 2019

Thanks for your contribution!

@amard33p
Copy link

Is it possible to filter the key nbformat_minor with this feature?

@kynan
Copy link
Owner

kynan commented May 9, 2020

@amard33p yes, should be. Is this a per-cell key? A "global" key?

@amard33p
Copy link

amard33p commented May 9, 2020

@amard33p yes, should be. Is this a per-cell key? A "global" key?

Not sure about that...but you can see it in the diff here: #110 (comment)

@kynan
Copy link
Owner

kynan commented May 10, 2020

Turns out nbformat_minor is actually a "top level" key and required, so stripping it would likely break the notebook.

ooiM added a commit to ooiM/nbstripout that referenced this pull request Jun 2, 2020
Custom blacklist metadata fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

strip output extension data/metadata Metadata python version attribute
4 participants