Skip to content

Commit f6c0668

Browse files
committed
Enabling absolute checkpoint dir
Sometimes, we don't want the checkpoints to be saved into our working directory. Instead, we may want to recreate the project structure inside a separate folder (e.g.: /home/{user}/.cache) like some software are doing.
1 parent 9106e05 commit f6c0668

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jupyter_server/services/contents/filecheckpoints.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class FileCheckpoints(FileManagerMixin, Checkpoints):
3434
config=True,
3535
help="""The directory name in which to keep file checkpoints
3636
37-
This is a path relative to the file's own directory.
37+
This path can either be relative or absolute.
38+
If it is a relative path, the checkpoint will be saved to the file's own directory.
3839
3940
By default, it is .ipynb_checkpoints
4041
""",
@@ -114,7 +115,10 @@ def checkpoint_path(self, checkpoint_id, path):
114115
ext=ext,
115116
)
116117
os_path = self._get_os_path(path=parent)
117-
cp_dir = os.path.join(os_path, self.checkpoint_dir)
118+
if os.path.isabs(self.checkpoint_dir):
119+
cp_dir = os.path.join(self.checkpoint_dir, parent)
120+
else:
121+
cp_dir = os.path.join(os_path, self.checkpoint_dir)
118122
with self.perm_to_403():
119123
ensure_dir_exists(cp_dir)
120124
cp_path = os.path.join(cp_dir, filename)

0 commit comments

Comments
 (0)