Checkpoint.as_directory() Iterator[str][source]#

Return checkpoint directory path in a context.

This function makes checkpoint data available as a directory while avoiding unnecessary copies and left-over temporary data.

If the checkpoint is already a directory checkpoint, it will return the existing path. If it is not, it will create a temporary directory, which will be deleted after the context is exited.

Users should treat the returned checkpoint directory as read-only and avoid changing any data within it, as it might get deleted when exiting the context.


with checkpoint.as_directory() as checkpoint_dir:
    # Do some read-only processing of files within checkpoint_dir

# At this point, if a temporary directory was created, it will have
# been deleted.