
    -`i	                         d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	m
Z
mZ  ee          Z	 	 dd	e	d
e
dej        dededefdZdS )z*Utilities for checking endpoint readiness.    N)tqdm)init_logger   )RequestFuncRequestFuncInputRequestFuncOutputX     request_func
test_inputsessiontimeout_secondsretry_intervalreturnc                   K   t          j                    |z   }t          d          }t          d| d           t	          |dd          5 }	 |t          j                    z
  }||z
  }	t          |	|j        z
  ||j        z
            }
|                    |
           |                                 |d	k    r|	                                 n	  | ||
           d{V }|j
        r"|	                                 |cddd           S t                              d|j                   n# t          j        $ r Y nw xY wt          ||          }|d	k    rt!          j        |           d{V  $	 ddd           n# 1 swxY w Y   |S )a  
    Wait for an endpoint to become available before starting benchmarks.

    Args:
        request_func: The async request function to call
        test_input: The RequestFuncInput to test with
        timeout_seconds: Maximum time to wait in seconds (default: 10 minutes)
        retry_interval: Time between retries in seconds (default: 5 seconds)

    Returns:
        RequestFuncOutput: The successful response

    Raises:
        ValueError: If the endpoint doesn't become available within the timeout
    F)successz%Waiting for endpoint to become up in z secondsz7{desc} |{bar}| {elapsed} elapsed, {remaining} remainings)total
bar_formatunitTr   )request_func_inputr   Nz!Endpoint is not ready. Error='%s')timeperf_counterr   printr   minnupdaterefreshcloser   loggerwarningerroraiohttpClientConnectorErrorasynciosleep)r   r   r   r   r   deadlineoutputpbar	remainingelapsedupdate_amountsleep_durations               u/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/benchmarks/lib/ready_checker.pywait_for_endpointr/      sA     ,  ""_4Hu---F	
K/
K
K
KLLL	L
 
 
  4 
	4 4#4#6#66I%	1G$& 0/DF2JKKMKK&&&LLNNNA~~


+|'17            > VJJLLL!/ 4  4  4  4  4  4  4  42 NN#FUUUU/    !;;N!!mN3333333337	4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4D Ms=   BF/D- D-,F-D?<F>D??5FFF)r	   r
   )__doc__r%   r   r#   tqdm.asyncior   vllm.loggerr   endpoint_request_funcr   r   r   __name__r    ClientSessionintr/        r.   <module>r9      s    1 0          # # # # # # S S S S S S S S S S	X		 < << < "< 	<
 < < < < < < <r8   