
    קg                     R   U d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	 d dl
mZ d dlmc mZ d dlmZ g Zee         ed<    ej        e          a ed          Z e	d          Zd	eeef         fd
Zd	eeef         fdZ	 ddeded	eeeef         geeef         f         fdZdS )    N)AnyCallableDictListTypeVar)	ParamSpec)uuid4)DCP_LOGGER_NAME__all___T_Preturnc                     i }|                     dd          }|                     dd          }|                     dd          }|                     dd          }|s|p|x}rt          |dd          }|t          |          n||d<   t          t                      j                  |d<   |r|j        j        |d<   |r|j        j        |d<   |r|j        j        |d<   |S )z0
    Extracts log data from dcp method args
    storage_writerNstorage_readerplannercheckpoint_iduuid)getgetattrstrr	   int	__class____name__)argskwargsmsg_dictr   r   r   r   
serializers           _/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/distributed/checkpoint/logger.py_msg_dict_from_dcp_method_argsr       s    H ZZ 0$77NZZ 0$77NjjD))GJJ55M CN,LnLj C
OTBB ,7M] _
 577;''HV G%3%=%F!" G%3%=%F!" 9%/8O    c                 h    t          |i |}|                    t          j        | fi |           |S )N)r    updatec10d_logger_get_msg_dict)	func_namer   r   r   s       r   r%   r%   7   s>    -t>v>>HOOK-iDD8DDEEEOr!   Flog_exceptionswrapper_kwargsc                 J     dt           t          t          f         f fd}|S )zKThis method decorator logs the start, end, and exception of wrapped events.funcc                      t          j                   dt          j        dt          j        dt
          f fd            }|S )Nr   r   r   c                     t          j        g| R i i 	|}d|d<   t          j                    }||d<   |d<   t                              |           	  | i |}nP# t          $ rC}r;d|d<   | |d<   t          j                    |d<   t                              |            d }~ww xY wd|d<   t          j                    }t          j                    |d<   ||z
  |d<   t                              |           |S )	Nstarteventtimer'   	exceptionerrorendtimes_spent)r%   r   r/   time_ns_dcp_loggerdebugBaseExceptionr1   )
r   r   r   t0resultr1   t1r*   r'   r(   s
          r   wrapperz6_dcp_method_logger.<locals>.decorator.<locals>.wrapperD   sH   $ $  (D>(DV(D H
 !(HWB!HV)7H%&h'''t.v..    ! 0(3HW%+0
HW%'+|~~HV$%%h/// !&HWB#|~~HV&(2gH]#h'''Ms   A! !
B.+>B))B.)	functoolswrapsr   r   r   r   )r*   r;   r'   r(   s   ` r   	decoratorz%_dcp_method_logger.<locals>.decoratorC   sb    				27 	bi 	B 	 	 	 	 	 	 	 
		@ r!   )r   r   r   )r'   r(   r>   s   `` r   _dcp_method_loggerr?   >   s@    
"R( " " " " " " "H r!   )F)r<   r/   typingr   r   r   r   r   typing_extensionsr   r   r	   torch.distributed.c10d_loggerdistributedr$   -torch.distributed.checkpoint.logging_handlersr
   r   r   __annotations___get_or_create_loggerr5   r   r   r    r%   boolr?    r!   r   <module>rI      s         5 5 5 5 5 5 5 5 5 5 5 5 5 5 ' ' ' ' ' '       3 3 3 3 3 3 3 3 3 I I I I I I c    0k/@@WT]]Yt__tCH~    Dc3h     !) ))47)xB (2r6"223) ) ) ) ) )r!   