mwouts / jupytext

Jupyter Notebooks as Markdown Documents, Julia, Python or R scripts
https://jupytext.readthedocs.io
MIT License
6.66k stars 386 forks source link

Document how to massively unpair ipynb files #577

Open mwouts opened 4 years ago

mwouts commented 4 years ago

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 ).

psychemedia commented 1 year ago

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 commented 1 year ago

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?