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

Exclude file for wild card star sync #986

Open
yasirroni opened this issue Jul 28, 2022 · 5 comments · May be fixed by #988
Open

Exclude file for wild card star sync #986

yasirroni opened this issue Jul 28, 2022 · 5 comments · May be fixed by #988

Comments

@yasirroni
Copy link

I'm using this commands for my workflow:

jupytext --set-formats ipynb,py:percent notebooks/*.ipynb  # only the first time
jupytext --sync notebooks/*  # after i'm working

It works well. Sadly, there is another file in notebooks/ that is not .ipynb and .py, like folders or whatever extensions.

The jupytext --set-formats ipynb,py:percent notebooks/*.ipynb is great for initiate the sync, while jupytext --sync notebooks/* is great for syncing.

Changing the jupytext --sync notebooks/* to jupytext --sync notebooks/*.ipynb make the sync only work one way (if the .py files updated, jupytext revert the update).

A solution is to support exclude list:

jupytext --sync notebooks/*  --exclude *.c,*.md,archive/
@mwouts
Copy link
Owner

mwouts commented Jul 29, 2022

Hello @yasirroni , thanks for reaching out.

I have a few comments/questions on the above

  1. I am willing to fix jupytext --sync notebooks/*.ipynb - it should not revert the .py file!
  2. What is exactly the problem with jupytext --sync notebooks/* when non-paired files are present? I would expect the command to do nothing on non-paired files
  3. Out of curiosity, why are you not using a jupytext.toml file with formats = "ipynb,py:percent"? (It would make the first command unnecessary)

@yasirroni
Copy link
Author

  1. Good.
  2. It does nothing. Just warning message, but it hurts my eyes.
  3. I only use the first command once every time a new notebook is created. Will that toml file always sync already synced file and initiate a sync (creating new .py file) for new notebook? How to use it then?

@mwouts
Copy link
Owner

mwouts commented Jul 29, 2022

Thank you @yasirroni for your prompt reply.

For 2, does the --quiet option remove the warning? If not, would you like to use --quiet or would you prefer another option like --ignore-unpaired-files?

Re 3 yes the value in the confit file override "formats" for notebooks that don't have a value, so you won't need the --set-formats command any more

@yasirroni
Copy link
Author

  1. I don't like quite and prefer verbosity. About --ignore-unpaired-files, what is the intended behaviour of --sync? It didn't ignore unpaired? Then, what happen to single unpaired .ipynb file? It will create new .py file? With what format? It really depends on your design and what is intended behaviour.

For me, --ignore or --except following with list of file is preferred to abstract wildcard (since Jupytext support wildcard).

An ignore parameters will also help config file, for example someone what to pair all .py files except init.py

  1. Nice, I will use config file and then only use the sync, since sync is smart enough to check whether the ipynb file or py file is newer.

@mwouts
Copy link
Owner

mwouts commented Aug 14, 2022

Hi @yasirroni , I tried to implement a new ignore argument, but I am not sure if globs are a good fit here, as they seem strongly linked to the underlying file system. Do you see how to answer the "TODO list" on the PR #988 ? If not, do you think using regular expressions for ignore, rather than globs, would be a good option?

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 a pull request may close this issue.

2 participants