python/ray/ml/checkpoint.py
def to_dict(self) -> dict:
        """Return checkpoint data as dictionary.

        Returns:
            dict: Dictionary containing checkpoint data.
        """
        if self._data_dict:
            # If the checkpoint data is already a dict, return
            return self._data_dict
        elif self._obj_ref:
            # If the checkpoint data is an object reference, resolve
            return ray.get(self._obj_ref)
        elif self._local_path or self._uri:
            # Else, checkpoint is either on FS or external storage
            with self.as_directory() as local_path:
                checkpoint_data_path = os.path.join(
                    local_path, _DICT_CHECKPOINT_FILE_NAME
                )
                if os.path.exists(checkpoint_data_path):
                    # If we are restoring a dict checkpoint, load the dict
                    # from the checkpoint file.
                    with open(checkpoint_data_path, "rb") as f:
                        checkpoint_data = pickle.load(f)
                else:
                    data = _pack(local_path)

                    checkpoint_data = {
                        _FS_CHECKPOINT_KEY: data,
                    }

            return checkpoint_data
        else:
            raise RuntimeError(f"Empty data for checkpoint {self}")
Return checkpoint data as dictionary.

        Returns:
            dict: Dictionary containing checkpoint data.
        
Return checkpoint data as dictionary.
Return checkpoint data as dictionary .
def to_dict(self) -> dict:
        if self._data_dict:
            return self._data_dict
        elif self._obj_ref:
            return ray.get(self._obj_ref)
        elif self._local_path or self._uri:
            with self.as_directory() as local_path:
                checkpoint_data_path = os.path.join(
                    local_path, _DICT_CHECKPOINT_FILE_NAME
                )
                if os.path.exists(checkpoint_data_path):
                    with open(checkpoint_data_path, "rb") as f:
                        checkpoint_data = pickle.load(f)
                else:
                    data = _pack(local_path)
                    checkpoint_data = {
                        _FS_CHECKPOINT_KEY: data,
                    }
            return checkpoint_data
        else:
            raise RuntimeError(f"Empty data for checkpoint {self}")
def to_dict ( self ) -> dict : if self . _data_dict : return self . _data_dict elif self . _obj_ref : return ray . get ( self . _obj_ref ) elif self . _local_path or self . _uri : with self . as_directory ( ) as local_path : checkpoint_data_path = os . path . join ( local_path , _DICT_CHECKPOINT_FILE_NAME ) if os . path . exists ( checkpoint_data_path ) : with open ( checkpoint_data_path , "rb" ) as f : checkpoint_data = pickle . load ( f ) else : data = _pack ( local_path ) checkpoint_data = { _FS_CHECKPOINT_KEY : data , } return checkpoint_data else : raise RuntimeError ( f"Empty data for checkpoint {self}" )
Return checkpoint data as dictionary.
Return checkpoint data as dictionary .
"""Return checkpoint data as dictionary.

        Returns:
            dict: Dictionary containing checkpoint data.
        """ # If the checkpoint data is already a dict, return # If the checkpoint data is an object reference, resolve # Else, checkpoint is either on FS or external storage # If we are restoring a dict checkpoint, load the dict # from the checkpoint file.
Dictionary containing checkpoint data.
Dictionary containing checkpoint data .
dict
self