after jupytext --to py:percent notebook.ipynb python script still have uncommented ipython magic. Is it expected behaviour? I am using jupytext 0.8.4
Hello Daniel,
Well, this in line with the documentation. And you can comment the magics even for the percent format using the comment_magics option.
Still, since you are asking this may not be the optimal choice! May I ask which editor you use to open the resulting percent script?
The motivation for the current behavior is that two editors (Hydrogen and VScode) execute the percent cells using Jupyter kernels, which do understand these magic commands.
thanks for pointing me to it, I used #escape to solve this problem. Maybe would be useful to point to it in Command line conversion section in percent command? Something like that
jupytext --to py:percent notebook.ipynb # create a notebook.py file in the double percent format (retain magic, use comment_magics option (see below)) to comment it)
People who want to convert ipynb may not read whole documentation before doing it (like me)
Or maybe is possible to add this comment option as a flag?
I am using Spyder, what I am reading is they dont plan to resolve this "problem" (the issue is here https://github.com/spyder-ide/spyder/issues/1643)
I see! Thanks for your feedback. Is it ok for you if I update the documentation, and add a comment_magic argument to jupytext command line?
yes, this is ok! Thanks!
after adding c.ContentsManager.comment_magics = True to config files I still get ipython magic in the python file after conversion using jupytext --to py:percent notebook.ipynb
Hello @danieltomasz, well, the configuration file is for Jupyter notebook. It is not read by jupytext command line. I had no time yet to add the comment_magic argument to the command line, but I am still willing to do that!
Meanwhile, you could either use Jupytext from within Jupyter, or add a comment_magic metadata in your notebook metadata, in the jupytext section.
Thanks for clarification!
Jupyter magics commands will now be commented per default in the percent format (Hydrogen users will have the comment-magics argument on the command line). @danieltomasz , would you like to test the next release candidate, available on pypi?
pip install jupytext==0.8.6rc0
yes, i will try to test it!
So far 0.8.6rc0 comment magic is working. How to use comment-magics arguments with command line for produce script with uncommented magic?
I dont know if it is related to comment magic, but since we discussing 0.8.6rc0:
When I delete paired .py file I am getting " Server connection error: Invalid response: 500 Internal Server Error" from paired notebook (when paired ipynb is open in Jupyter Lab) and the related .py file is not saved.
When I manually provide .py by converting it from .ipynb everything is ok again.
shouldn't the jupytex automatically recreate py file from paired .ipynb file when .py file is deleted? What is the expected behaviour? If yes I create new issue.
Thanks Daniel!
How to use comment-magics arguments with command line for produce script with uncommented magic?
Can you give a try to the third line of the CLI examples ? I.e.
jupytext --to py:percent --comment-magics false notebook.ipynb
Shouldn't the jupytex automatically recreate py file from paired .ipynb file when .py file is deleted? What is the expected behaviour?
Yes! It should. Is this an issue you observed before the RC? If not, can I ask you to try the latest 0.8.6 version from GitHub? Yesterday I added a commit that may fix your issue. Please let me know - and thanks for testing the RC!
@danieltomasz , a new RC is available:
pip install jupytext==0.8.6rc1
Could you please let me know if you still have the issue of the .py file not being re-created? Thanks.
I am sorry for delay with answer, everything is working now as expected ( I also tested the --comment-magics false flag )
Thanks Daniel! No worries, we have time - working without a deadline is precious!!
So I think we're ready for releasing this - I will probably do this in the evening.
Available in version 0.8.6.
Most helpful comment
I see! Thanks for your feedback. Is it ok for you if I update the documentation, and add a
comment_magicargument tojupytextcommand line?