question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jupytext ignores lines starting with %

See original GitHub issue

I am using jupytext --to ipynb *.Rmd or jupytext --to Rmd *.ipynb to keep the pairs of Rmd and ipynb files in sync. This works nicely if I add code in either document and use the jupytext calls to copy these to the other file type.

However, it does not work if that line of code starts with either % or # %, as in %autosave 0 or # %autosave 0. Such lines of code are simply not transferred between the formats. As a result, since we only edit the ipynb file and make code review of the .Rmd file, such code edits go unnoticed.

Could you please make jupytext stop ignoring such code changes?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
mwoutscommented, May 28, 2020

Hello @tordbb , thanks for asking.

It is expected that Jupytext comments out magic commands (by default, because they don’t make sense in a .Rmd document), but it should not remove any line when changing from one format to the other. If you have a reproducible example I would like very much to have a look.

Now, you can change that behavior with the comment_magics option (jupytext --opt comment_magics=False).

You can also change that for a single line with e.g.

%autosave 0 #noescape
1reaction
aninehartocommented, Jun 22, 2020

I found the source of the error, so I managed to fix it 😃 Thanks for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently Asked Questions - Jupytext documentation
Yes! When you're done, reload the notebook in Jupyter. There, you will see the updated input cells combined with the matching output cells...
Read more >
Python Ignore lines in file that start with - Stack Overflow
Within my python script I open a file for reading, and want to process certain lines. I want to ignore lines that start...
Read more >
jupytext - PyPI
On the command line. jupytext converts Jupyter notebooks to their text representation, and back. ... We start with a Jupyter notebook.
Read more >
Jupyter notebooks as Markdown documents or Python scripts
ipynb file) itself. Why would you want to use Jupytext? There are several good reasons to consider using Jupytext. First, you may be...
Read more >
Creating an open-source book with Jupyter Book and Jupytext
Links:https://github.com/giswqs/cookiecutter-jupyter-bookhttps://geemap.org/workshops/GeoPython_2021/https://book.geemap.org/https://giswqs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found