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

feat: add option to ignore some paths #1199

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lucas-bremond
Copy link

@lucas-bremond lucas-bremond commented Jan 5, 2024

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?

Copy link

github-actions bot commented Jan 5, 2024

Thank you for making this pull request.

Did you know? You can try it on Binder: Binder:lab or Binder:notebook.

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)

@mwouts
Copy link
Owner

mwouts commented Jan 7, 2024

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:

  1. 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)
  2. Is there an error if you create a new notebook in export with a jupytext.toml file like yours? If so we should address that too (I can have a look when time permits too)
  3. Rather than ignoring the export directory, I would rather make sure that there is no pairing / no error if the notebook is moved/created in another directory than notebooks or source.

@mwouts mwouts added this to the 1.17.0 milestone Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants