
    }Yh                     |   U d dl Z d dlZd dlZd dl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  ej                    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efdZ dS )    N)AnyCallable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           u/var/www/tools.fuzzalab.pt/emblema-extractor/venv/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                 n    t          |i |}|                    t          j        | g|R i |           |S )N)r   updatec10d_logger_get_msg_dict)	func_namer   r   r   s       r   r#   r#   ;   sF    -t>v>>HOOK-iI$III&IIJJJ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BaseExceptionr/   )
r   r   r   t0resultr/   t1r(   r%   r&   s
          r   wrapperz6_dcp_method_logger.<locals>.decorator.<locals>.wrapperH   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(   r9   r%   r&   s   ` r   	decoratorz%_dcp_method_logger.<locals>.decoratorG   sb    				27 	bi 	B 	 	 	 	 	 	 	 
		@ r   )r   r   r
   )r%   r&   r<   s   `` r   _dcp_method_loggerr=   B   s@    
"R( " " " " " " "H r   rankc                 @   t                               t          j                   t          j                    }|                    t          j                   t          j        d|  d          }|                    |           t                               |           d S )N[z6] %(asctime)s - %(name)s - %(levelname)s - %(message)s)loggersetLevelloggingINFOStreamHandler	FormattersetFormatter
addHandler)r>   ch	formatters      r   _init_loggerrK   n   s    
OOGL!!!			 	 BKK!HDHHH I OOI
br   )F)!r:   rC   r-   typingr   r   r   typing_extensionsr   r   r   torch.distributed.c10d_loggerdistributedr"   -torch.distributed.checkpoint.logging_handlersr   	getLoggerrA   r	   listr   __annotations___get_or_create_loggerr3   r
   r   dictr   r#   boolr=   r   rK    r   r   <module>rX      s          ) ) ) ) ) ) ) ) ) ) ' ' ' ' ' '       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) ) ) )Xs      r   