jupytext
jupytext copied to clipboard
cli glob processing on windows
jupytext.paired_paths.InconsistentPath is thrown when using glob patterns on windows10 with jupytext cli Steps to reproduce:
jupytext.ymlconfiguration file:
default_jupytext_formats: "notebooks///ipynb,scripts///py:percent"
default_notebook_metadata_filter: "jupytext"
- put any
py:percentscript inside of scripts directory - run
jupytext --sync scripts/*.py
Expected:
ipynbcreated in the notebooks directory
Actual:
jupytext.paired_paths.InconsistentPath: Paired paths 'notebooks/example.ipynb','scripts/example.py' do not include the current notebook path 'scripts\example.py'. Current format is 'scripts///py:percent', and paired formats are 'notebooks///ipynb,scripts///py:percent'
The difference between expected path and received is: "scripts/example.py" - "scripts\example.py"
If we will run jupytext --sync scripts/example.py the behavior matches to the expected one.
Are there any workarounds to execute cli with glob on windows?
Thank you @delmarrerikaine for the clear report. I'll try to reproduce this with a test, and fix it.
Hi @delmarrerikaine , I was having a look at this. Is this test representative of your issue? https://github.com/mwouts/jupytext/blob/8244821e70fce94b947ebe1b260c9a2e99380bc9/tests/test_cli_config.py#L148-L161
The tests is in success at least here locally... soon we'll see on the CI.
And if I run the commands in an Anaconda Powershell Prompt, they seem to yield the expected result:

So maybe the problem is elsewhere... Can you let me know
- which version of Jupytext you are using?
- and, do you have anything specific in the
py:percentfile? Mine is like this:
# %%
1 + 1
Hi @mwouts, Thanks for looking into this! Your example is representative of my issue.
The difference between my and yours:
jupytext --sync scripts\*.py- produce provided errorjupytext --sync .\scripts\*.py- works as expected
Therefore my needs are resolved with this change. Thanks!
jupytext version is 1.6.0 nothing specific in py:percent file Please let me know if there are any other details I can provide.
Good news! Well then I think it is a matter of which console you are using, not of the glob expansion. Just to check, what is the outcome of jupytext --sync scripts\example.py? Do you need to do jupytext --sync .\scripts\example.py to get it to work?
I am using cmd
The following comands are working:
jupytext --sync .\scripts\example.py
jupytext --sync scripts/example.py
jupytext --sync ./scripts/example.py
jupytext --sync .\scripts\*.py
The following are failing with jupytext.paired_paths.InconsistentPath:
jupytext --sync scripts\example.py
jupytext --sync scripts\*.py
jupytext --sync ./scripts/*.py
jupytext --sync scripts/*.py
Perhaps it might be usefull to add a new error message if current notebook path differs from one of expected ones only by slash\backslash.
Interesting! Do when all fail with the same error message? Rather than a new error message I'd prefer to support \ as a path separator on Windows as well, that would solve your issue, right?
The:
jupytext --sync scripts\example.py
jupytext --sync scripts\*.py
jupytext --sync scripts/*.py
fails with:
jupytext.paired_paths.InconsistentPath: Paired paths 'notebooks/example.ipynb','scripts/example.py' do not include the current notebook path 'scripts\example.py'. Current format is 'scripts///py:percent', and paired formats are 'notebooks///ipynb,scripts///py:percent'
Therefore I believe support of \ as a path separator on Windows should solve this.
The jupytext --sync ./scripts/*.py fails with:
jupytext.paired_paths.InconsistentPath: Path './scripts\example.py' matches none of the export formats. Please make sure that jupytext.formats covers the current file (e.g. add 'py' to the export formats)
With the new tests above we do catch the four problems:
