jupytext
jupytext copied to clipboard
feat: add option to ignore some paths
Disclaimer: As I am pretty unfamiliar with the Jupytext codebase, this proposal may come across as poorly implemented. Before spending time devising a better implementation and adding tests, I'd like to explore whether the documented intent even makes sense... or not!
Assuming the following jupytext.toml configuration:
formats = "notebooks///ipynb,source///py:percent"
The scenario I've been attempting to tackle is the following.
I have a Jupyter Notebook (.ipynb) stored under notebooks/hello.ipynb, which thanks to Jupytext gets automatically synced with its Python counterpart at source/hello.py.
Now, copying notebooks/hello.ipynb over to export/hello.ipynb (via the GUI) will fail with the following error:
Paste Error
Unexpected error while saving file: export/hello.ipynb Path 'export/hello.ipynb' matches none of the export formats.
Please make sure that jupytext.formats covers the current file (e.g. add 'ipynb' to the export formats)
which makes sense, since export/ isn't part of the directory tree "covered" by Jupytext.
In my opinion, an expected behavior in this case could have been to allow the copy to result in an unpaired notebook.
So the proposed approach here is to introduce an ignored_paths option, allowing to define folders that aren't subject to Jupytext's notebook pairing.
Thoughts?
Thank you for making this pull request.
Did you know? You can try it on Binder: or
.
Also, the version of Jupytext developed in this PR can be installed with pip:
pip install git+https://github.com/lucas-bremond/jupytext.git@users/lucas/add-unpaired-folders
(this requires nodejs, see more at Developing Jupytext)
Thank you @lucas-bremond for this PR! Yep it makes sense to fix this. I will have a look when time permits.
For now I have the following remarks:
- It would be great to add a test that reproduces the issue. I can also do that later on (there are many examples in
test_contentsmanager.py) - Is there an error if you create a new notebook in
exportwith ajupytext.tomlfile like yours? If so we should address that too (I can have a look when time permits too) - Rather than ignoring the
exportdirectory, I would rather make sure that there is no pairing / no error if the notebook is moved/created in another directory thannotebooksorsource.