Implement get_checkpoint to allow content retrieval without restoration#1592
Open
mariam851 wants to merge 2 commits intojupyter-server:mainfrom
Open
Implement get_checkpoint to allow content retrieval without restoration#1592mariam851 wants to merge 2 commits intojupyter-server:mainfrom
mariam851 wants to merge 2 commits intojupyter-server:mainfrom
Conversation
Contributor
|
Thanks for the PR! Since you have tested this with pytest, can you make sure to include tests for these methods in the PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Problem:
Currently, FileCheckpoints and AsyncFileCheckpoints do not implement the get_checkpoint method. This makes it impossible to retrieve the content of a specific checkpoint without performing a full restoration, which can lead to data loss of the current unsaved work.
The Solution:
This PR implements the get_checkpoint method in both synchronous and asynchronous classes.
Key Changes:
Direct File Access: Used internal _read_file and _read_notebook methods to read checkpoint data directly from the filesystem.
Path Handling: Implemented proper OS path to API path mapping to ensure compatibility across different operating systems, especially Windows.
Bypassing Hidden Directory Restrictions: By reading files directly, we bypass the ContentsManager 404 errors that occur when trying to access the hidden .ipynb_checkpoints directory via the standard API.
Testing:
I have verified the implementation using pytest and manual testing:
Synchronous test: Successfully retrieved versioned content of .txt files.
Asynchronous test: Successfully retrieved content using AsyncFileCheckpoints.
Windows Compatibility: Confirmed that path separators are handled correctly.