a
    þdû
  ã                   @   s4   d dl mZmZmZ d dlmZ G dd„ deƒZdS )é    )ÚAnyÚDictÚOptional)ÚCheckpointIOc                       s˜   e Zd ZdZded ddœ‡ fdd„Zeed dœdd	„ƒZejdddœd
d	„ƒZe	e	ddœdd„Z
e	e	ddœdd„Ze	e	eee	f dœdd„Z‡  ZS )Ú_WrappingCheckpointIOzÅ``_WrappingCheckpointIO`` is a wrapper checkpoint_io that uses a base checkpoint_io to handle checkpointing.

    Args:
        checkpoint_io: A checkpoint IO plugin that is used as the basis.
    Nr   )Úcheckpoint_ioÚreturnc                    s<   t ƒ  ¡  || _d| _|d ur8t|tƒr2|j| _nd| _d S )NFT)ÚsuperÚ__init__Ú_checkpoint_ioÚ_base_checkpoint_io_configuredÚ
isinstancer   ©Úselfr   ©Ú	__class__© úm/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/pytorch_lightning/plugins/io/wrapper.pyr
      s    


z_WrappingCheckpointIO.__init__)r   c                 C   s   | j S )N)r   )r   r   r   r   r   &   s    z#_WrappingCheckpointIO.checkpoint_ioc                 C   sJ   t |tƒrJ ‚| jd u r&d| _|| _n t | jtƒrF| jsFd| _|| j_d S )NT)r   r   r   r   r   r   r   r   r   r   *   s    
)ÚargsÚkwargsr   c                 O   s$   | j dusJ ‚| j j|i |¤Ž dS )z7Uses the base ``checkpoint_io`` to save the checkpoint.N)r   Úsave_checkpoint©r   r   r   r   r   r   r   5   s    z%_WrappingCheckpointIO.save_checkpointc                 O   s$   | j dusJ ‚| j j|i |¤Ž dS )z9Uses the base ``checkpoint_io`` to remove the checkpoint.N)r   Úremove_checkpointr   r   r   r   r   :   s    z'_WrappingCheckpointIO.remove_checkpointc                 O   s    | j dusJ ‚| j j|i |¤ŽS )z7Uses the base ``checkpoint_io`` to load the checkpoint.N)r   Úload_checkpointr   r   r   r   r   ?   s    z%_WrappingCheckpointIO.load_checkpoint)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   Úpropertyr   Úsetterr   r   r   r   Ústrr   Ú__classcell__r   r   r   r   r      s   
r   N)Útypingr   r   r   Zlightning_fabric.pluginsr   r   r   r   r   r   Ú<module>   s   