jupytext icon indicating copy to clipboard operation
jupytext copied to clipboard

Document how to massively unpair ipynb files

Open mwouts opened this issue 3 years ago • 2 comments

We should add this to either the CLI documentation, or to the FAQ - removing the jupytext information from notebooks (hence the pairing) can be done with

jupytext --update-metadata '{"jupytext": null}' *.ipynb

The context on this question was the following: Jupytext is installed system wise, so the user cannot uninstall it, but he'd rather stop using it for a nbdev project (see also #542 ).

mwouts avatar Jul 28 '20 15:07 mwouts

Running this command throws an error if a notebook does not have the jupytext metadata key set:

jovyan@87275628c719:~/notebooks$ jupytext --update-metadata '{"jupytext": null}' Part*/*.ipynb
[jupytext] Reading Part 01 Notebooks/01.1 Getting started with IPython and Jupyter Notebooks - Bootcamp.ipynb in format ipynb
[jupytext] Updating notebook metadata with '{"jupytext": null}'
Traceback (most recent call last):
  File "/usr/local/bin/jupytext", line 8, in <module>
    sys.exit(jupytext())
  File "/home/jovyan/.local/lib/python3.8/site-packages/jupytext/cli.py", line 488, in jupytext
    exit_code += jupytext_single_file(nb_file, args, log)
  File "/home/jovyan/.local/lib/python3.8/site-packages/jupytext/cli.py", line 630, in jupytext_single_file
    recursive_update(notebook.metadata, args.update_metadata)
  File "/home/jovyan/.local/lib/python3.8/site-packages/jupytext/header.py", line 157, in recursive_update
    del target[key]
KeyError: 'jupytext'

psychemedia avatar Jan 09 '23 15:01 psychemedia

A workaround is to just set the sync as follows:

jupytext --set-formats ipynb Part*/*.ipynb

It would then also be possible to legitimately set the value null.

(Are there any side of settings the value to ipynb compare to null?

psychemedia avatar Jan 09 '23 15:01 psychemedia