python/ray/ml/checkpoint.py
def as_directory(self) -> Iterator[str]:
        """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.

        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.

        """
        if self._local_path:
            yield self._local_path
        else:
            temp_dir = self.to_directory()
            yield temp_dir
            shutil.rmtree(temp_dir, ignore_errors=True)
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.

        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.

        
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.
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 .
def as_directory(self) -> Iterator[str]:
        if self._local_path:
            yield self._local_path
        else:
            temp_dir = self.to_directory()
            yield temp_dir
            shutil.rmtree(temp_dir, ignore_errors=True)
def as_directory ( self ) -> Iterator [ str ] : if self . _local_path : yield self . _local_path else : temp_dir = self . to_directory ( ) yield temp_dir shutil . rmtree ( temp_dir , ignore_errors = True )
Return checkpoint directory path in a context.
Return checkpoint directory path in a context .
"""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.

        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.

        """
self
examples
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.
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 .