
    &`i$                        d dl mZ d dlmZmZmZ d dlmZmZ d dl	m
Z
 d dlmZ dZe G d dee                      Ze G d	 d
ee                      Ze G d dee                      Ze G d de                      Ze G d de                      Ze G d de                      Ze G d de                      Z G d de          Ze G d de                      Ze G d de                      Ze G d de                      Ze G d de                      Ze G d d e                      Ze G d! d"e                      Ze G d# d$e                      Zd%S )&    )Enum)DictListOptional)	BaseModelField)
JobDetails)DeveloperAPIiP  c                   >    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
efdZdS )	RunStatusz5Enumeration of the possible statuses for a Train run.INITIALIZING
SCHEDULINGRUNNING
RESTARTINGRESIZINGFINISHEDERROREDABORTEDreturnc                 L    | t           j        t           j        t           j        fv S N)r   r   r   r   selfs    w/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/train/v2/_internal/state/schema.pyis_terminalzRunStatus.is_terminal#   s    	*I,=y?PQQQ    N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   boolr    r   r   r   r      sh        ?? "LJGJH HGGRT R R R R R Rr   r   c                   2    e Zd ZdZdZdZdZdZdZde	fdZ
d	S )
RunAttemptStatusz=Enumeration of the possible statuses for a Train run attempt.PENDINGr   r   r   r   r   c                 L    | t           j        t           j        t           j        fv S r   )r$   r   r   r   r   s    r   r   zRunAttemptStatus.is_terminal9   s&    %$$
 
 	
r   N)r   r   r   r    r%   r   r   r   r   r!   r   r"   r   r   r$   r$   '   sR        GG GG HGG
T 
 
 
 
 
 
r   r$   c                       e Zd ZdZdZdZdS )ActorStatusz5Enumeration of the statuses for a Train worker actor.ALIVEDEADN)r   r   r   r    r)   r*   r"   r   r   r(   r(   A   s         ?? EDDDr   r(   c                   F    e Zd ZU dZ ed          Zeeef         e	d<   dS )TrainResourcesz.Resources allocated for a Train worker or run.zVA dictionary specifying the types and amounts of resources allocated (e.g., CPU, GPU).description	resourcesN)
r   r   r   r    r   r/   r   strfloat__annotations__r"   r   r   r,   r,   K   sQ         88"'%&# # #ItCJ     r   r,   c                      e Zd ZU dZ ed          Zeed<    ed          Zeed<    ed          Z	eed<    ed	          Z
eed
<    ed          Zeed<    ed          Zeed<    ed          Zeed<    ed          Zee         ed<    ed          Zee         ed<    ed          Zeed<    ed          Zee         ed<   dS )TrainWorkerz"Metadata about a Ray Train worker.z6The global rank of the worker in the training cluster.r-   
world_rankz)The local rank of the worker on its node.
local_rankz-The rank of the worker's node in the cluster.	node_rankz$The unique ID of the worker's actor.actor_idz6The unique ID of the node where the worker is running.node_idz7The IP address of the node where the worker is running.node_ipzThe process ID of the worker.pidz*A list of GPU IDs allocated to the worker.gpu_idsz'The current status of the worker actor.statusz-The resources allocated to this Train worker.r/   z.The path to the log file for the Train worker.log_file_pathN)r   r   r   r    r   r5   intr2   r6   r7   r8   r0   r9   r:   r;   r<   r   r=   r   r(   r/   r,   r>   r"   r   r   r4   r4   U   s        ,,eL  J    e(STTTJTTTU'VWWWIsWWWE&LMMMHcMMM5L  GS    5M  GS    u!@AAACAAA+WXXXGT#YXXX$)E=% % %FH[!    !&C! ! !I~    $)5D$ $ $M8C=     r   r4   c                       e Zd ZU dZ ed          Zeed<    ed          Zeed<    ed          Z	e
e         ed<    ed	          Ze
e         ed
<   dS )
MemoryInfoz'Memory usage information for a process.z2The resident set size (RSS) memory usage in bytes.r-   rssz-The virtual memory size (VMS) usage in bytes.vmszThe number of page faults.pfaultszThe number of page-ins.pageinsN)r   r   r   r    r   rB   r?   r2   rC   rD   r   rE   r"   r   r   rA   rA   r   s         11u!UVVVCVVVu!PQQQCQQQ"U/KLLLGXc]LLL"U/HIIIGXc]IIIIIr   rA   c                       e Zd ZU dZ ed          Zeed<    ed          Ze	e
e                  ed<    ed          Zeed<   d	S )
ProcessStatsz(CPU and memory statistics for a process.zThe percentage of CPU usage.r-   
cpuPercentzOMemory statistics, including total memory, free memory, and memory usage ratio.memz"Detailed memory usage information.
memoryInfoN)r   r   r   r    r   rH   r1   r2   rI   r   r   r?   rJ   rA   r"   r   r   rG   rG   |   s         22*HIIIJIII$u"     C$s)	    #U/STTTJ
TTTTTr   rG   c                   X    e Zd ZU dZ ed          Zeed<    ed          Zeed<   dS )ProcessGPUUsagez#GPU usage statistics for a process.zThe process ID.r-   r;   zThe GPU memory usage in bytes.gpuMemoryUsageN)	r   r   r   r    r   r;   r?   r2   rM   r"   r   r   rL   rL      sT         --u!2333C333%,LMMMNCMMMMMr   rL   c                      e Zd ZU dZ ed          Zeed<    ed          Ze	ed<    ed          Z
eed<    ed	          Zee         ed
<    ed          Zeed<    ed          Zeed<    ed          Zeed<   dS )GPUStatszStatistics for a GPU.z!The unique identifier of the GPU.r-   uuidzThe index of the GPU.indexzThe name of the GPU.namez&The percentage utilization of the GPU.utilizationGpuz'The amount of GPU memory used in bytes.
memoryUsedz(The total amount of GPU memory in bytes.memoryTotalz0GPU usage statistics for the associated process.processInfoN)r   r   r   r    r   rP   r0   r2   rQ   r?   rR   rS   r   r1   rT   rU   rV   rL   r"   r   r   rO   rO      s        "EFFFD#FFF#:;;;E3;;;"8999D#999&+e<' ' 'NHUO    *STTTJTTT+UVVVKVVV#(5F$ $ $K     r   rO   c                   t    e Zd ZU dZ edd          Zee         ed<    ee	d          Z
ee         ed<   dS )	DecoratedTrainWorkerzJDetailed metadata for a Ray Train worker, including process and GPU stats.Nz1CPU and memory statistics for the worker process.r-   processStatszDA list of GPUs used by the worker process, with detailed statistics.)default_factoryr.   gpus)r   r   r   r    r   rY   r   rG   r2   listr[   r   rO   r"   r   r   rX   rX      s         TT+05M, , ,L(<(    !5%  D$x.     r   rX   c                   T   e Zd ZU dZ ed          Zeed<    ed          Zeed<    ed          Z	e
ed<    ed	          Zee         ed
<    ed          Zeed<    ed          Zee         ed<    ed          Zee         ed<    ed          Zee         ed<   dS )TrainRunAttemptz:Metadata for an individual attempt to execute a Train run.z+Unique identifier for the parent Train run.r-   run_idz6Unique identifier for this specific Train run attempt.
attempt_idz6The current execution status of the Train run attempt.r=   zLAdditional details about the status, including error messages if applicable.status_detailzGThe UNIX timestamp (in nanoseconds) when the Train run attempt started.start_time_nszlThe UNIX timestamp (in nanoseconds) when the Train run attempt ended. If null, the attempt is still ongoing.end_time_nszBThe resources (e.g., CPU, GPU) allocated to the Train run attempt.r/   zLList of Train workers participating in this attempt, sorted by global ranks.workersN)r   r   r   r    r   r_   r0   r2   r`   r=   r$   ra   r   rb   r?   rc   r/   r   r,   rd   r4   r"   r   r   r^   r^      s        DD%$QRRRFCRRReL  J     %uL     F    $)53$ $ $M8C=    /  M3    "'1" " "K#   
 ',eX' ' 'ItN#    "'"" " "GT+     r   r^   c                   B    e Zd ZU dZ ed          Zee         ed<   dS )DecoratedTrainRunAttemptzKDetailed metadata for a Train run attempt, including decorated worker data.zIA list of Train workers with detailed statistics, sorted by global ranks.r-   rd   N)	r   r   r   r    r   rd   r   rX   r2   r"   r   r   rf   rf      sN         UU*/%"+ + +GT&'     r   rf   c                   j   e Zd ZU dZ ed          Zeed<    ed          Zeed<    ed          Z	eed<    ed	          Z
eed
<    ed          Zeed<    ed          Zee         ed<    ed          Zeed<    ed          Zee         ed<    ed          Zee         ed<   dS )TrainRunz?Metadata for a Ray Train run, including its details and status.z$Unique identifier for the Train run.r-   idz.Human-readable name assigned to the Train run.rR   z.The Ray Job ID associated with this Train run.job_idz.Unique ID of the actor managing the Train run.controller_actor_idz.The current execution status of the Train run.r=   zTAdditional details about the current status, including error messages if applicable.ra   z?The UNIX timestamp (in nanoseconds) when the Train run started.rb   zdThe UNIX timestamp (in nanoseconds) when the Train run ended. If null, the run is still in progress.rc   z6The path to the log file for the Train run controller.controller_log_file_pathN)r   r   r   r    r   ri   r0   r2   rR   rj   rk   r=   r   ra   r   rb   r?   rc   rl   r"   r   r   rh   rh      s        IIe FGGGBGGG"RSSSD#SSS%$TUUUFCUUU$uD         D  FI    $)52$ $ $M8C=    U  M3    "'1" " "K#    /4eL/ / /hsm     r   rh   c                   r    e Zd ZU dZ ed          Zee         ed<    edd          Z	e
e         ed<   dS )DecoratedTrainRunzJDetailed metadata for a Ray Train run, including attempts and job details.z1A list of attempts made to execute the Train run.r-   attemptsNzADetailed information about the job that initiated this Train run.job_details)r   r   r   r    r   ro   r   rf   r2   rp   r   r	   r"   r   r   rn   rn      s         TT/4uG0 0 0Hd+,    ).W) ) )K*%     r   rn   c                   B    e Zd ZU dZ ed          Zee         ed<   dS )TrainRunsResponsez3Response containing a list of decorated Train runs.z,A list of Train runs with detailed metadata.r-   
train_runsN)	r   r   r   r    r   rs   r   rn   r2   r"   r   r   rr   rr     sL         ==*/%B+ + +J&'     r   rr   N)enumr   typingr   r   r   ray._common.pydantic_compatr   r   )ray.dashboard.modules.job.pydantic_modelsr	   ray.util.annotationsr
   MAX_ERROR_STACK_TRACE_LENGTHr0   r   r$   r(   r,   r4   rA   rG   rL   rO   rX   r^   rf   rh   rn   rr   r"   r   r   <module>rz      s         ' ' ' ' ' ' ' ' ' ' 8 8 8 8 8 8 8 8 @ @ @ @ @ @ - - - - - -$  R R R R RT R R R6 
 
 
 
 
sD 
 
 
2     #t        Y        )   8 J J J J J J J J U U U U U9 U U UN N N N Ni N N N     y     
 
 
 
 
; 
 
 
     i   @             y   8 	 	 	 	 	 	 	 	     	     r   