Is there a way to disable saving to checkpoints for Jupyter Notebooks?
Asked Answered
R

5

18

I am working in an environment where writing to the disk space with a folder name like .ipynb_checkpoints is disallowed.

Unfortunately, this is Jupyter Notebook's default path for Save and Checkpoint. Is there a way to configure Jupyter Notebook to not use the checkpoint feature or allow a different folder name?

Remscheid answered 17/8, 2018 at 2:51 Comment(0)
M
13

Not exactly an answer to your question, but perhaps close enough.

The path of the checkpoints folder is configurable so you could rename it to something allowed such as "_ipynb_checkpoints", or you could move it to a completely different folder.

You simply have to add

c.FileCheckpoints.checkpoint_dir = '_ipynb_checkpoints'

to jupyter_notebook_config.py

Metagalaxy answered 20/12, 2018 at 8:49 Comment(5)
where is this config file usually found?Marmara
@MonicaHeddneck Bit late, but this is in ~/.jupyter, and you can run jupyter notebook --generate-config to create the file. See jupyter-notebook.readthedocs.io/en/stable/config.htmlAwful
Well, you are almost there! Simply set c.FileCheckpoints.checkpoint_dir = '' - No folder is then created!Riker
Well, I saw later that if the above action is taken, instead of a folder, NB creates a backup file in the path of the opened .ipynb file, with the name '{filename}-checkpoint.ipynb'. I don't know how and if this can be prevented. But still, it is better than creating a whole folder!Riker
Update for this solution using Jupyter Lab? I don't see c.FileCheckpoints in jupyter-notebook-config.py, and I'm not even sure that's the right config for Jupyter Lab.Spoonfeed
A
6

You can uncheck Settings -> AutosaveDocuments to avoid autosave file, but it always create .ipynb_checkpoints folder when you open a file, I can not find a solution to avoid this behavior,there is a way that you can specify a folder to collect all the checkpoint files and delete them together.

  1. In jupyterlab, you can use jupyter notebook --generate-config to generate a config file named jupyter_notebook_config.py .
  2. Then you can edit this file: c.FileContentsManager.checkpoints_kwargs = {'root_dir': r'D:\'} .

Or you can just use cammand line option

jupyter lab --FileContentsManager.checkpoints_kwargs="root_dir"="D:/"
Adeline answered 18/1, 2022 at 14:19 Comment(2)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewRask
Thank you for this command line option, now the checkpoints are saved outside of the notebook folder and that works for me. jupyter lab --FileContentsManager.checkpoints_kwargs="root_dir"="/tmp"Earthwork
F
2

There are couple of ways to stop autosaves.

There is a contrib nbextension called AutoSaveTime if you have installed jupyter-contrib-nbextensions that adds an autosave time configuration on the toolbar of a notebook, just ensure:

"autosavetime/main": true

is set in your notebook.json configuration file.

Alternatively in a Cell, to change the autosave value for the current notebook, you can write:

%autosave 0

Or you can change your custom.js to make this permanent for all notebooks:

define([
    'base/js/namespace',
    'base/js/events'
    ],
    function(IPython, events) {
        events.on("notebook_loaded.Notebook",
            function () {
                IPython.notebook.set_autosave_interval(0);
            }
        );
    }
);
Frangipane answered 17/8, 2018 at 3:0 Comment(3)
Thanks! I tried that, but the problem is not so much with the Autosave, but the face that when I click on "Save and Checkpoints" , or CTRL+S, Jupyter Notebook will try to create the .ipynb_checkpoints folder and save checkpoints there. This is what's causing the error messages to occur because naming a folder with a preceeding . is prohibited in my environment. I'm looking for a solution to just save and overwrite current file, but not create checkpoints at all.Remscheid
Tried experimenting with save_hooks, but can't find a way to change the path of the checkpoints. jupyter-notebook.readthedocs.io/en/stable/extending/…Remscheid
Did you find a solution? I am facing the same issue working on a sharepoint drive.Metagalaxy
O
0

The literal answer is to add

c.FileContentsManager.checkpoints = false

to jupyter_notebook_config.py

Overthrow answered 7/5 at 4:44 Comment(0)
S
0

In Jupyter Notebook, choose Setting, click turn off Autosave Documents

Shrubby answered 24/7 at 16:36 Comment(2)
This answer seems to be a duplicate of this oneTormentil
Duplicated answer to previous answer answered by @HH0714.Neon

© 2022 - 2024 — McMap. All rights reserved.