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

Metadata keys containing periods are unstrippable #143

Closed
baldwint opened this issue Jan 12, 2021 · 2 comments · Fixed by #144
Closed

Metadata keys containing periods are unstrippable #143

baldwint opened this issue Jan 12, 2021 · 2 comments · Fixed by #144

Comments

@baldwint
Copy link
Contributor

I work with databricks notebooks, which (when exported to the ipynb format) add metadata fields with keys:

  • application/vnd.databricks.v1+cell
  • application/vnd.databricks.v1+notebook

at the cell and notebook levels, respectively.

Stripping these does not work using this tool because nbstripout interprets the period . as a dictionary nesting delimiter when I pass these names as arguments to the extra keys argument.

For example, nbstripout --extra-keys='cell.metadata.application/vnd.databricks.v1+cell metadata.application/vnd.databricks.v1+notebook' my_notebook.ipynb will not work.

I have a modified version of nbstripout that fixes the issue and I will open a pull request for it.

@robertofierimonte
Copy link

robertofierimonte commented Sep 3, 2024

Hey @kynan, @baldwint how do I enable these extra keys filters for period keys when using the tools as a pre-commit?

This is my pre-commit config but it does not seem to strip out Databricks metadata:

- repo: https://github.com/kynan/nbstripout
    rev: 0.7.1
    hooks:
        - id: nbstripout
           args: ["--extra-keys='metadata.application/vnd.databricks.v1+notebook cell.metadata.application/vnd.databricks.v1+cell'"]

I can strip out the notebooks fine if I run nbstripout with the extra keys from the CLI.

@kynan
Copy link
Owner

kynan commented Sep 18, 2024

@robertofierimonte Not sure what might be going on there. Do you have a sample Databricks notebook to reproduce this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants