o
    
۾i                     @   s   d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ eeZe Zdede	fdd	Zed
defddZeddefddZdefddZdS )    )	APIRouterFastAPIRequest)Response)ProfilerConfig)EngineClient)init_loggerrequestreturnc                 C   s
   | j jjS )N)appstateengine_client)r	    r   ]/home/ubuntu/.local/lib/python3.10/site-packages/vllm/entrypoints/serve/profile/api_router.pyr      s   
r   z/start_profileraw_requestc                    2   t d t|  I d H  t d tddS )NzStarting profiler...zProfiler started.   status_code)loggerinfor   start_profiler   r   r   r   r   r      
   


r   z/stop_profilec                    r   )NzStopping profiler...zProfiler stopped.r   r   )r   r   r   stop_profiler   r   r   r   r   r      r   r   r   c                 C   s\   t | jjdd }|d u st|tsJ |d ur*|jd ur,td|j | t	 d S d S d S )Nprofiler_configzeProfiler with mode '%s' is enabled in the API server. This should ONLY be used for local development!)
getattrr   args
isinstancer   profilerr   warning_onceinclude_routerrouter)r   r   r   r   r   attach_router%   s   r#   N)fastapir   r   r   fastapi.responsesr   vllm.configr   vllm.engine.protocolr   vllm.loggerr   __name__r   r"   r   postr   r   r#   r   r   r   r   <module>   s   