[PRECOMMIT] JuPyText does not preserve ids during pre-commit hook bidirectional sync.
See original GitHub issueI recently tried to upgrade habitat_sim to use the new pre-commit hook, but found that the ID is not preserved in the cells with a bidirectional update.
pre-commit hook settings
- repo: https://github.com/mwouts/jupytext/
rev: v1.11.1
hooks:
- id: jupytext
files: '^examples/tutorials/(colabs|nb_python)/(.*\.py|.*\.ipynb)$'
args: [--update-metadata, '{"jupytext":{"notebook_metadata_filter":"all", "cell_metadata_filter":"-all"}, "accelerator":"GPU"}', --set-formats, 'nb_python//py:percent,colabs//ipynb,', --pipe, black, --pipe, 'isort - --treat-comment-as-code "# %%"', --pipe-fmt, 'py:percent', --sync]
additional_dependencies:
- black
- isort
I also tried this simplified version here:
- repo: https://github.com/mwouts/jupytext/
rev: v1.11.1
hooks:
- id: jupytext
files: '^examples/tutorials/nb_python/.*\.py$'
args: [--update-metadata, '{"jupytext":{"notebook_metadata_filter":"all", "cell_metadata_filter":"-all"}, "accelerator":"GPU"}', --set-formats, 'nb_python//py:percent,colabs//ipynb,', --pipe, black, --pipe, 'isort - --treat-comment-as-code "# %%"', --pipe-fmt, 'py:percent', --sync]
additional_dependencies:
- black
- isort
but ran into the same problem where it would keep updating the id every time pre-commit is run.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Supported hooks - pre-commit
reorder-python-imports - This hook reorders imports in python files. ... forbid-html-img-without-alt-text - List every <img> tag without a alt= or ...
Read more >Using as a pre-commit hook - Jupytext documentation
Tested examples of how to use the pre-commit hook are available in our tests - see for instance test_pre_commit_1_sync_with_config.py.
Read more >Jupytext pre-commit config when notebooks are ignored in git
gitignore file, which means that notebooks are ignored (because of git size issues), but I want pre-commit to automatically create/sync python ...
Read more >Proceedings of the 21st Python in Science Conference
its application is not limited to astronomy, but suitable for much of scientific and engineering data, as well as models. We finish.
Read more >What if Git worked with programming languages? - Hacker News
Not every file in source control is source code. Not every programming language's grammar maps to an abstract syntax tree.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh interesting! I’ve seen people using
to avoid this impact on their text notebooks (yet I am not sure I would recommend that because then I can’t provide version compatibility)
Let me know if there is anything else I can do to help.
My best guess is it was this corner case.
Basically it was happening before / after this PR: https://github.com/facebookresearch/habitat-sim/pull/1200 (with the nbconvert constraint removed).