ray.train.Checkpoint.as_directory#
- Checkpoint.as_directory() Iterator[str] [source]#
Returns checkpoint contents in a local directory as a context.
This function makes checkpoint data available as a directory while avoiding unnecessary copies and left-over temporary data.
If the checkpoint points to a local directory, this method just returns the local directory path without making a copy, and nothing will be cleaned up after exiting the context.
If the checkpoint points to a remote directory, this method will download the checkpoint to a local temporary directory and return the path to the temporary directory.
If multiple processes on the same node call this method simultaneously, only a single process will perform the download, while the others wait for the download to finish. Once the download finishes, all processes receive the same local (temporary) directory to read from.
Once all processes have finished working with the checkpoint, the temporary directory is cleaned up.
Users should treat the returned checkpoint directory as read-only and avoid changing any data within it, as it may be deleted when exiting the context.
Example:
with checkpoint.as_directory() as checkpoint_dir: # Do some read-only processing of files within checkpoint_dir pass # At this point, if a temporary directory was created, it will have # been deleted.