Skip to content

Commit

Permalink
Enabling absolute checkpoint dir
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lade-odoo committed May 26, 2023
1 parent 9106e05 commit f6c0668
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jupyter_server/services/contents/filecheckpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class FileCheckpoints(FileManagerMixin, Checkpoints):
config=True,
help="""The directory name in which to keep file checkpoints
This is a path relative to the file's own directory.
This path can either be relative or absolute.
If it is a relative path, the checkpoint will be saved to the file's own directory.
By default, it is .ipynb_checkpoints
""",
Expand Down Expand Up @@ -114,7 +115,10 @@ def checkpoint_path(self, checkpoint_id, path):
ext=ext,
)
os_path = self._get_os_path(path=parent)
cp_dir = os.path.join(os_path, self.checkpoint_dir)
if os.path.isabs(self.checkpoint_dir):
cp_dir = os.path.join(self.checkpoint_dir, parent)
else:
cp_dir = os.path.join(os_path, self.checkpoint_dir)
with self.perm_to_403():
ensure_dir_exists(cp_dir)
cp_path = os.path.join(cp_dir, filename)
Expand Down

0 comments on commit f6c0668

Please sign in to comment.