mwouts / jupytext

Jupyter Notebooks as Markdown Documents, Julia, Python or R scripts
https://jupytext.readthedocs.io
MIT License
6.65k stars 386 forks source link

Avoid updating jupytext_version? #1007

Closed tbenthompson closed 2 years ago

tbenthompson commented 2 years ago

I'm using the precommit hook to copy ipynb files to markdown for easier PR commenting.

  - repo: https://github.com/mwouts/jupytext
    rev: v1.14.1
    hooks:
      - id: jupytext
        args: [--from, ipynb, --to, "md"]

When updating the rev on this hook, the result is that every notebook markdown file in my repository see its jupytext_version updated.

-      jupytext_version: 1.13.8
+      jupytext_version: 1.14.1

This creates a lot of unnecessary noise!

Is there a way to avoid updating the markdown files when the only changed line would be the jupytext_version?

Thanks!!

mwouts commented 2 years ago

Hello @tbenthompson , thank you for sharing this. To avoid such changes you can use this metadata filter:

notebook_metadata_filter = "-jupytext.text_representation.jupytext_version"

Now I am not sure what is the best way to set the filter. If you use a jupytext.toml file then you could put it there, but if you don't then maybe you will want to set the metadata filter in the notebooks directly using the hook? Let us know how it goes for you.

tbenthompson commented 2 years ago

Oh this is great! Thank you. Sorry I missed this before.