o
    پi                     @   s   d Z dd ZdS )a  (\(\w+ pid=(?P<pid>\d+)(?:,\s*ip=(?P<ip>[\d\.]+))?\))?\s*\[(?P<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})(?:\s+DP(?P<dp_rank>\d+))?(?:\s+TP(?P<tp_rank>\d+))?(?:\s+EP(?P<ep_rank>\d+))?(?:\s+PP(?P<pp_rank>\d+))?\]\s+Decode batch( \[\d+\])?,\s+#running-req:\s*(?P<num_running_req>\d+),\s+#token:\s*(?P<num_token>\d+),\s+token usage:\s*(?P<token_usage>[0-9.]+),\s+.*?gen throughput \(token/s\):\s*(?P<gen_throughput>[0-9.]+),\s+#queue-req:\s*(?P<queue_req>\d+),c                    s   dd l t|  d  jdjtd  	d  
d   jdjjdg fd	d
djfdjfdjfdjfdjfdjfdjfdjfdjfdjff
D R    S )N    )liner   )infor   gen_throughputtimez%Y-%m-%d %H:%M:%Sc                    s*   g | ]\}}| j v r||qS  )columnscolcast).0r   dtypedfplr   U/home/ubuntu/.local/lib/python3.10/site-packages/sglang/srt/debug_utils/log_parser.py
<listcomp>   s
    
zparse.<locals>.<listcomp>piddp_ranktp_rankep_rankpp_ranknum_running_req	num_tokentoken_usage	queue_req)polars	DataFramedict
splitlineswith_columnsr   strextract_groups_PATTERN_DECODEunnestfilteris_not_nullstrptimeDatetimeInt64Float64)linesr   r   r   parse   s.   
r*   N)r!   r*   r   r   r   r   <module>   s   