a
    þd¿	  ã                   @   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eeef ee	e ddœdd„ƒZ
edee	e eeef dœdd„ƒZeedd	œd
d„ƒZddœdd„ZdS )ÚCheckpointIOa$  Interface to save/load checkpoints as they are saved through the ``Strategy``.

    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   s   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   úr/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/lightning_fabric/plugins/io/checkpoint_io.pyÚsave_checkpoint#   s    zCheckpointIO.save_checkpoint)r
   Úmap_locationr   c                 C   s   dS )aJ  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_checkpoint-   s    zCheckpointIO.load_checkpoint)r
   r   c                 C   s   dS )zhRemove checkpoint file from the filesystem.

        Args:
            path: Path to checkpoint
        Nr   )r   r
   r   r   r   Úremove_checkpoint9   s    zCheckpointIO.remove_checkpoint)r   c                 C   s   dS )z.This method is called to teardown the process.Nr   )r   r   r   r   ÚteardownA   s    zCheckpointIO.teardown)N)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   Z lightning_fabric.utilities.typesr   r   r   r   r   r   Ú<module>   s   