Closed choucavalier closed 1 year ago
Hey @tgy , thank you for your kind words! Good to see you here!
One possible approach (the one that I use personally) is to exclude the .ipynb
notebooks from version control, and to maintain the files in sync locally with a e.g. a jupytext.toml
config in the notebook
folder, with this content: formats = "ipynb,py:percent"
. The advantage of that approach is that the pre-commit hooks only apply to Python files, so they are a bit simpler to configure.
However you seem to have a preference for contributing the .ipynb
notebooks to the project, and to maintain them in sync with the .py:percent
files using the pre-commit hooks rather than a config file plus Jupyter. Have you tried to apply the reformatting tools and the pairing at the same time, using the --pipe
command? We have a few pre-commit examples in the tests
folder, maybe this one: test_pre_commit_3_sync_black_nbstripout.py
is the most similar to what you want to achieve?
thanks! indeed it does not really make sense to version the .ipynb
version alongside the .py
version. i was trying to accommodate people who actually like coding in notebooks
thanks for the detailed answer, and congrats again for this awesome project!
hi! thanks for this awesome project :) so much has been done since you first called me into your office (before jupytext was even born) to ask for my advice! it's really impressive
now i come for your advice!
i'm trying to set up
pre-commit
to have all notebooks under./notebooks/
synced with apy:percent
.py
filei ended up setting things up like this
i'm a bit confused by this set up. but basically what i want to achieve:
.ipynb
under./notebooks/
should have an associated.py
inpy:percent
format.ipynb
and.py
should match and be reformatted (isort
,ruff
,black
) before committhe problem is that i sometimes have to run
pre-commit
multiple times because either the.ipynb
is modified then synced, or the.py
is modified then synced... i think i'm a bit confused by my set up.what is the right way to set this up?