§
    “©ºjß  ã                   óf   — d Z ddlZddlmZ ddlmZ ddlZddlm	Z	 ddl
mZ  G d„ de¦  «        ZdS )	zg
On exception checkpointing
==========================

Automatically save a checkpoints on exception.
é    N)ÚAny)Úoverride)Ú_PATH)Ú
Checkpointc            	       ó¢   ‡ — e Zd ZdZdZddededdfˆ fd„Zedefd	„¦   «         Z	e
d
ddededdfd„¦   «         Ze
d
ddededdfd„¦   «         Zˆ xZS )ÚOnExceptionCheckpointaÔ  Used to save a checkpoint on exception.

    Args:
        dirpath: directory to save the checkpoint file.
        filename: checkpoint filename. This must not include the extension.

    Raises:
        ValueError:
            If ``filename`` is empty.


    Example:
        >>> from pytorch_lightning import Trainer
        >>> from pytorch_lightning.callbacks import OnExceptionCheckpoint
        >>> trainer = Trainer(callbacks=[OnExceptionCheckpoint(".")])

    z.ckptÚon_exceptionÚdirpathÚfilenameÚreturnNc                 ó†   •— t          ¦   «                              ¦   «          |st          d¦  «        ‚|| _        || _        d S )NzThe filename cannot be empty)ÚsuperÚ__init__Ú
ValueErrorr
   r   )Úselfr
   r   Ú	__class__s      €úƒ/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/pytorch_lightning/callbacks/on_exception_checkpoint.pyr   zOnExceptionCheckpoint.__init__4   sB   ø€ Ý‰Œ×ÒÑÔÐØð 	=ÝÐ;Ñ<Ô<Ð<àˆŒØ ˆŒˆˆó    c                 óf   — t           j                             | j        | j        | j        z   ¦  «        S ©N)ÚosÚpathÚjoinr
   r   ÚFILE_EXTENSION)r   s    r   Ú	ckpt_pathzOnExceptionCheckpoint.ckpt_path<   s$   € åŒw�|Š|˜DœL¨$¬-¸$Ô:MÑ*MÑNÔNÐNr   Útrainerz
pl.TrainerÚ_Ú__c                 ó:   — |                      | j        ¦  «         d S r   )Úsave_checkpointr   ©r   r   r   r   s       r   r	   z"OnExceptionCheckpoint.on_exception@   s    € ð 	×Ò ¤Ñ/Ô/Ð/Ð/Ð/r   c                 óD   — |j                              | j        ¦  «         d S r   )ÚstrategyÚremove_checkpointr   r!   s       r   ÚteardownzOnExceptionCheckpoint.teardownE   s!   € àÔ×*Ò*¨4¬>Ñ:Ô:Ð:Ð:Ð:r   )r	   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústrr   Úpropertyr   r   r   r	   r%   Ú__classcell__)r   s   @r   r   r      s  ø€ € € € € ðð ð$ €Nð!ð ! ð !°ð !È$ð !ð !ð !ð !ð !ð !ð ðO˜3ð Oð Oð Oñ „XðOð ð0 Lð 0°cð 0Àð 0Èð 0ð 0ð 0ñ „Xð0ð ð; ð ;°#ð ;¸Sð ;ÀTð ;ð ;ð ;ñ „Xð;ð ;ð ;ð ;ð ;r   r   )r)   r   Útypingr   Útyping_extensionsr   Úpytorch_lightningÚplÚ lightning_fabric.utilities.typesr   Úpytorch_lightning.callbacksr   r   © r   r   ú<module>r4      s¢   ððð ð 
€	€	€	Ø Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &à Ð Ð Ð Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2ð(;ð (;ð (;ð (;ð (;˜Jñ (;ô (;ð (;ð (;ð (;r   