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

jupytext gives incorrect warning "You have passed a file name to the '--to' option" #901

Closed
jli opened this issue Jan 4, 2022 · 3 comments

Comments

@jli
Copy link

jli commented Jan 4, 2022

I want to configure jupytext to save companion .py files for all .ipynb notebooks. I want the .py files to have a specific suffix, so that it's easy to identify those files.

This command works: jupytext --from ipynb --to __sidecar.py:percent <notebook file>
However, I get the following warning from jupytext:

[warning] You have passed a file name to the '--to' option, when a format description was expected. Maybe you want to use the '-o' option instead?

I'm guessing it's this code:

jupytext/jupytext/cli.py

Lines 463 to 466 in 57d83aa

warnings.warn(
"You have passed a file name to the '--to' option, "
"when a format description was expected. Maybe you want to use the '-o' option instead?"
)

And I'm guessing the issue is that the check "." in args.output_format is being triggered?

Is something wrong with my --to option? Based on the docs (https://jupytext.readthedocs.io/en/latest/config.html), I believe the format above (__sidecar.py:percent) is valid.

Is there a workaround I can use in the meantime? It seems that adding // could fix this, though I don't quite understand how to use it, or if that will cause side-effects?

@mwouts
Copy link
Owner

mwouts commented Jan 4, 2022

Hi @jli again,

Yes you're right, the warning in your case is a bit too much. It is triggered by this condition:

jupytext/jupytext/cli.py

Lines 450 to 457 in 57d83aa

# Warn if '--to' is used in place of '--output'
if (
not args.output
and args.output_format
and "." in args.output_format
and not args.output_format.startswith(".")
and "//" not in args.output_format
):

I believe I have not seen this in the Jupytext examples because in my examples the suffix start with a dot. I will see how to improve this, meanwhile you can either ignore the warning, or use a suffix that starts with ..

@jli
Copy link
Author

jli commented Jan 4, 2022

Ah, I see, so the example suffixes look like notebook_name.suffix.py? That seems like a reasonable workaround for us.

Thanks for the quick response!

@mwouts
Copy link
Owner

mwouts commented Jan 11, 2022

From version 1.13.6 on, the warning will not appear any more when the suffix start with either ., - or _. Thanks @jli for pointing out at this.

@mwouts mwouts closed this as completed Feb 4, 2022
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

No branches or pull requests

2 participants