ray.tune.Checkpoint#
- class ray.tune.Checkpoint(path: str | PathLike, filesystem: pyarrow.fs.FileSystem | None = None)#
- Bases: - Checkpoint- A reference to data persisted as a directory in local or remote storage. - Access the checkpoint contents locally using - checkpoint.to_directory()or- checkpoint.as_directory.- path#
- Type:
- A path on the filesystem containing the checkpoint contents. 
 
 - filesystem#
- Type:
- PyArrow FileSystem that can be used to access data at the - path.
 
 - See also - ray.train.report
- Report a checkpoint during training (with Ray Train/Tune). 
- ray.train.get_checkpoint
- Get the latest checkpoint during training (for restoration). 
 - Saving and Loading Checkpoints, Configuring Persistent Storage - Examples - Creating a checkpoint using - Checkpoint.from_directory:- >>> from ray.train import Checkpoint >>> checkpoint = Checkpoint.from_directory("/tmp/example_checkpoint_dir") >>> checkpoint.filesystem <pyarrow._fs.LocalFileSystem object... >>> checkpoint.path '/tmp/example_checkpoint_dir' - Creating a checkpoint from a remote URI: - >>> checkpoint = Checkpoint("s3://bucket/path/to/checkpoint") >>> checkpoint.filesystem <pyarrow._s3fs.S3FileSystem object... >>> checkpoint.path 'bucket/path/to/checkpoint' - Creating a checkpoint with a custom filesystem: - >>> checkpoint = Checkpoint( ... path="bucket/path/to/checkpoint", ... filesystem=pyarrow.fs.S3FileSystem(), ... ) >>> checkpoint.filesystem <pyarrow._s3fs.S3FileSystem object... >>> checkpoint.path 'bucket/path/to/checkpoint' - Accessing a checkpoint’s contents: - >>> import os >>> with checkpoint.as_directory() as local_checkpoint_dir: ... print(os.listdir(local_checkpoint_dir)) ['model.pt', 'optimizer.pt', 'misc.pt'] - PublicAPI (beta): This API is in beta and may change before becoming stable. - Methods - Construct a Checkpoint. - Returns checkpoint contents in a local directory as a context. - Create checkpoint object from a local directory. - Return the metadata dict stored with the checkpoint. - Set the metadata stored with this checkpoint. - Write checkpoint data to a local directory. - Update the metadata stored with this checkpoint.