L i RUddlZddlZddlZddlmZmZmZddlmZddl m Z ddl m cm Z ddlmZej ZgZeeed<e j,eaedZedZd eeeffd Zd eeeffd Z dd ed ed eeeefgeeefffdZdefdZ y)N)AnyCallableTypeVar) ParamSpec)uuid4)DCP_LOGGER_NAME__all___T_Preturnci}|jdd}|jdd}|jdd}|jdd}|s|xs|x}r t|dd}| t|n||d<ttj|d<|r|j j |d<|r|j j |d<|r|j j |d<|S)z0 Extracts log data from dcp method args storage_writerNstorage_readerplanner checkpoint_iduuid)getgetattrstrrint __class____name__)argskwargsmsg_dictrrrr serializers i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/distributed/checkpoint/logger.py_msg_dict_from_dcp_method_argsrsHZZ 0$7NZZ 0$7NjjD)GJJ5M N,LnLjL OTB ,7M] _ 57;;'HV%3%=%=%F%F!"%3%=%=%F%F!"%//88 Oclt|i|}|jtj|g|i||S)N)rupdate c10d_logger _get_msg_dict) func_namerrrs rr#r#;s7-t>v>H OOK--iI$I&IJ Orlog_exceptionswrapper_kwargsc >dtttfffd }|S)zKThis method decorator logs the start, end, and exception of wrapped events.funcctjdtjdtjdt ffd }|S)Nrrr ctjg|ii |}d|d<tj}||d<|d<tj | |i|}d|d<tj}tj|d<||z |d<tj ||S#t $r?}r7d|d<||d<tj|d<tj|d}~wwxYw) Nstarteventtimer% exceptionerrorend times_spent)r#rr-time_ns _dcp_loggerdebug BaseExceptionr/) rrrt0resultr/t1r(r%r&s rwrapperz6_dcp_method_logger..decorator..wrapperHs$  $(D>(DV(DH !(HW B!HV )7H% &   h ' t.v.!&HW B#||~HV &(2gH] #   h 'M! !(3HW%+0'HW%'+||~HV$%%h/  sB// C78:C22C7) functoolswrapsr rrr )r(r9r%r&s` r decoratorz%_dcp_method_logger..decoratorGsC   277 bii B   @r)rr r )r%r&r<s`` r_dcp_method_loggerr=Bs! "R("H rrankc.tjtjtj}|jtjtj d|d}|j |tj|y)N[z6] %(asctime)s - %(name)s - %(levelname)s - %(message)s)loggersetLevelloggingINFO StreamHandler Formatter setFormatter addHandler)r>ch formatters r _init_loggerrKnsi OOGLL!    BKK !! D6GHIOOI br)F)!r:rCr-typingrrrtyping_extensionsrrrtorch.distributed.c10d_logger distributedr"-torch.distributed.checkpoint.logging_handlersr getLoggerrAr listr__annotations___get_or_create_loggerr3r r dictrr#boolr=rrKrrrXs ))'33I    c0k//@  T]t_tCH~Dc3h!))47) xB (2r6"223)Xsr