jupytext icon indicating copy to clipboard operation
jupytext copied to clipboard

cli glob processing on windows

Open delmarrerikaine opened this issue 5 years ago • 8 comments

jupytext.paired_paths.InconsistentPath is thrown when using glob patterns on windows10 with jupytext cli Steps to reproduce:

  1. jupytext.yml configuration file:
default_jupytext_formats: "notebooks///ipynb,scripts///py:percent"
default_notebook_metadata_filter: "jupytext"
  1. put any py:percent script inside of scripts directory
  2. run jupytext --sync scripts/*.py

Expected:

  • ipynb created 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?

delmarrerikaine avatar Sep 22 '20 12:09 delmarrerikaine

Thank you @delmarrerikaine for the clear report. I'll try to reproduce this with a test, and fix it.

mwouts avatar Sep 22 '20 15:09 mwouts

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: image

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:percent file? Mine is like this:
# %%
1 + 1

mwouts avatar Sep 30 '20 19:09 mwouts

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 error
  • jupytext --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.

delmarrerikaine avatar Oct 01 '20 08:10 delmarrerikaine

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?

mwouts avatar Oct 01 '20 20:10 mwouts

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.

delmarrerikaine avatar Oct 02 '20 08:10 delmarrerikaine

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?

mwouts avatar Oct 02 '20 10:10 mwouts

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)

delmarrerikaine avatar Oct 02 '20 11:10 delmarrerikaine

With the new tests above we do catch the four problems: image

mwouts avatar Oct 04 '20 17:10 mwouts