o
    ٷi                     @   sD  d dl Z d dlZd dlZd dlZdi iZe Ze	d e
dZe ) ejdddZejdd	dZejd
gd
dddZedd de W d   n1 sSw   Y  e . e  ejddZejddZejddZW d   n1 s~w   Y  W d   n1 sw   Y  ejdddddddddddddZejejejejejejgeeegeeeegd d!d" ZW d   n1 sw   Y  ed#kr i ed< ee  d$d%D ]8Z!e  d d&Z"e e" e #e"d'krg d(nd)d*ge #g d+e  d d,e$e  d d-d.ed e  d/d0< qe%  dS dS )1    Ndataz# Monitoring Dashboard   z	now - 24hz
Start Time)labelnowzEnd TimeAllEndpointzASelect the function to see analytics for, or 'All' for aggregate.)valuer   infoc                   C   s(   t jdgtdd td  D  dS )Nr   c                 S   s   h | ]}|d  qS )function ).0rowr   r   O/home/ubuntu/.local/lib/python3.10/site-packages/gradio/monitoring_dashboard.py	<setcomp>   s    z<lambda>.<locals>.<setcomp>r   )choices)grDropdownlistr   valuesr   r   r   r   <lambda>   s
    r   zUnique UserszTotal RequestszAvg Process Timetimer
   statuszRequests over TimeRequests1mcountz#22c55ez#ef4444z#eab308z#3b82f6)successfailurependingqueued)xycolortitley_titlex_biny_aggregate	color_map)inputsoutputsc           	      C   s  t td dkrtt iS tttd  }|dkr%||d |k }||d | k|d |k@  }tj	|d dd|d< t |d 
 }t |}t|d	  d
}||  }|dkr]dn|dkrcdnd}|jdgd}t|tjstJ tj||| |gd|||fS )Nr   r   r   r
   r   s)unitsession_hashprocess_time   iQ 1hi0*  15mr   )columns)r   r$   x_lim)lenr   plotr   skippd	DataFramer   r   to_datetimeuniqueroundmeandrop
isinstanceBarPlot)	startendselected_fndfunique_userstotal_requestsr,   durationr$   r   r   r   gen_plot5   s0   rE   __main__i,  i  i i  )r   r   r   r   r   )predictchatrH   
      )r   r   r
   r,   r+      i )&randomr   pandasr5   gradior   r   BlocksdemoMarkdownTimertimerRowDateTimer>   r?   r   r@   loadGroupLabelrB   rC   r,   r=   r3   ontickchangerE   __name__rangerandint_	timedeltachoicestrlaunchr   r   r   r   <module>   s    







O

