o
    „o™i
  ã                   @   sD   d dl mZmZ d dlmZmZmZ d dlmZ G dd„ deƒZ	dS )é    )ÚABCÚabstractmethod)ÚAnyÚDictÚOptional)Ú_PATHc                
   @   s„   e Zd ZdZeddeeef dede	e ddfdd„ƒZ
edded	e	e deeef fd
d„ƒZededdfdd„ƒZddd„ZdS )ÚCheckpointIOa~  Interface to save/load checkpoints as they are saved through the ``Strategy``.

    .. warning::  This is an :ref:`experimental <versioning:Experimental API>` feature.

    Typically most plugins either use the Torch based IO Plugin; ``TorchCheckpointIO`` but may
    require particular handling depending on the plugin.

    In addition, you can pass a custom ``CheckpointIO`` by extending this class and passing it
    to the Trainer, i.e ``Trainer(plugins=[MyCustomCheckpointIO()])``.

    .. note::

        For some plugins, it is not possible to use a custom checkpoint plugin as checkpointing logic is not
        modifiable.

    NÚ
checkpointÚpathÚstorage_optionsÚreturnc                 C   ó   dS )a'  Save model/training states as a checkpoint file through state-dump and file-write.

        Args:
            checkpoint: dict containing model and trainer state
            path: write-target path
            storage_options: Optional parameters when saving the model/training states.

        N© )Úselfr	   r
   r   r   r   ú]/home/ubuntu/.local/lib/python3.10/site-packages/lightning/fabric/plugins/io/checkpoint_io.pyÚsave_checkpoint&   ó    zCheckpointIO.save_checkpointÚmap_locationc                 C   r   )aK  Load checkpoint from a path when resuming or loading ckpt for test/validate/predict stages.

        Args:
            path: Path to checkpoint
            map_location: a function, :class:`torch.device`, string or a dict specifying how to remap storage
                locations.

        Returns: The loaded checkpoint.

        Nr   )r   r
   r   r   r   r   Úload_checkpoint1   r   zCheckpointIO.load_checkpointc                 C   r   )ziRemove checkpoint file from the filesystem.

        Args:
            path: Path to checkpoint

        Nr   )r   r
   r   r   r   Úremove_checkpoint>   r   zCheckpointIO.remove_checkpointc                 C   r   )z.This method is called to teardown the process.Nr   )r   r   r   r   ÚteardownG   r   zCheckpointIO.teardown)N)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústrr   r   r   r   r   r   r   r   r   r   r   r      s    *
&r   N)
Úabcr   r   Útypingr   r   r   Ú lightning.fabric.utilities.typesr   r   r   r   r   r   Ú<module>   s   