o
    z“©iN  ã                   @   s@   d dl mZmZmZ d dlmZ d dlmZ G dd„ deƒZdS )é    )ÚAnyÚDictÚOptional)Úoverride)ÚCheckpointIOc                	       s¬   e Zd ZdZdded ddf‡ fdd„Zeded fdd	„ƒZejdd
d	„ƒZe	de
de
ddfdd„ƒZe	de
de
ddfdd„ƒZe	de
de
deee
f f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.

    NÚcheckpoint_ior   Úreturnc                    sB   t ƒ  ¡  || _d| _|d urt|tƒr|j| _d S d| _d S d S )NFT)ÚsuperÚ__init__Ú_checkpoint_ioÚ_base_checkpoint_io_configuredÚ
isinstancer   ©Úselfr   ©Ú	__class__© úX/home/ubuntu/.local/lib/python3.10/site-packages/pytorch_lightning/plugins/io/wrapper.pyr      s   


üz_WrappingCheckpointIO.__init__c                 C   s   | j S ©N)r   )r   r   r   r   r   )   s   z#_WrappingCheckpointIO.checkpoint_ioc                 C   sT   t |tƒrJ ‚| jd u rd| _|| _d S t | jtƒr&| js(d| _|| j_d S d S d S )NT)r   r   r   r   r   r   r   r   r   r   -   s   

þÚargsÚkwargsc                 O   ó$   | 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   8   ó   z%_WrappingCheckpointIO.save_checkpointc                 O   r   )z9Uses the base ``checkpoint_io`` to remove the checkpoint.N)r   Úremove_checkpointr   r   r   r   r   >   r   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   D   s   z%_WrappingCheckpointIO.load_checkpointr   )r   r   r	   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úpropertyr   Úsetterr   r   r   r   r   Ústrr   Ú__classcell__r   r   r   r   r      s    
(r   N)	Útypingr   r   r   Útyping_extensionsr   Úlightning_fabric.pluginsr   r   r   r   r   r   Ú<module>   s   