o
    ci"                     @   s~  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 deeZeG d	d
 d
eeZeG dd deeZeG dd deZeG dd deZeG dd deZeG dd deZG dd deZeG dd deZeG dd deZeG dd deZeG dd deZeG dd  d eZeG d!d" d"eZeG d#d$ d$eZd%S )&    )Enum)DictListOptional)	BaseModelField)
JobDetails)DeveloperAPIiP  c                   @   s0   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
S )	RunStatusz5Enumeration of the possible statuses for a Train run.INITIALIZING
SCHEDULINGRUNNING
RESTARTINGRESIZINGFINISHEDERROREDABORTEDN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r    r   r   W/home/ubuntu/.local/lib/python3.10/site-packages/ray/train/v2/_internal/state/schema.pyr
      s    r
   c                   @   s$   e Zd ZdZdZdZdZdZdZdS )RunAttemptStatusz=Enumeration of the possible statuses for a Train run attempt.PENDINGr   r   r   r   N)	r   r   r   r   r   r   r   r   r   r   r   r   r   r   $   s    r   c                   @   s   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   7   s    r   c                   @   s,   e Zd ZU dZed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   A   s
   
 r   c                   @   s   e Zd ZU dZeddZeed< eddZeed< eddZ	eed< ed	dZ
eed
< eddZeed< eddZeed< eddZeed< eddZee ed< eddZee ed< eddZeed< ed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   r&   intr$   r'   r(   r)   r"   r*   r+   r,   r-   r   r.   r   r   r!   r   r/   r   r   r   r   r%   K   s2   
 r%   c                   @   sb   e Zd ZU dZeddZeed< eddZeed< eddZ	e
e ed< ed	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   r2   r0   r$   r3   r4   r   r5   r   r   r   r   r1   h   s   
 r1   c                   @   sP   e Zd ZU dZeddZeed< eddZe	e
e  ed< ed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   r7   r#   r$   r8   r   r   r0   r9   r1   r   r   r   r   r6   r   s   
 r6   c                   @   s6   e Zd ZU dZeddZeed< ed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,   r0   r$   r;   r   r   r   r   r:   ~   s   
 r:   c                   @   s   e Zd ZU dZeddZeed< eddZe	ed< eddZ
eed< ed	dZee ed
< eddZeed< eddZeed< ed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   r=   r"   r$   r>   r0   r?   r@   r   r#   rA   rB   rC   r:   r   r   r   r   r<      s   
 r<   c                   @   sB   e Zd ZU dZedddZee ed< ee	d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   rE   r   r6   r$   listrG   r   r<   r   r   r   r   rD      s   
 rD   c                   @   s   e Zd ZU dZeddZeed< eddZeed< eddZ	e
ed< ed	dZee ed
< eddZeed< eddZee ed< eddZee ed< ed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   rJ   r"   r$   rK   r.   r   rL   r   rM   r0   rN   r!   r   r   rO   r%   r   r   r   r   rI      s0   
 rI   c                   @   (   e Zd ZU dZed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   rO   N)	r   r   r   r   r   rO   r   rD   r$   r   r   r   r   rQ      
   
 rQ   c                   @   s   e Zd ZU dZeddZeed< eddZeed< eddZ	eed< ed	dZ
eed
< eddZeed< eddZee ed< eddZeed< eddZee ed< ed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.r?   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.rL   z?The UNIX timestamp (in nanoseconds) when the Train run started.rM   zdThe UNIX timestamp (in nanoseconds) when the Train run ended. If null, the run is still in progress.rN   z6The path to the log file for the Train run controller.controller_log_file_pathN)r   r   r   r   r   rT   r"   r$   r?   rU   rV   r.   r
   rL   r   rM   r0   rN   rW   r   r   r   r   rS      s.   
 rS   c                   @   s@   e Zd ZU dZeddZee ed< ed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   rY   r   rQ   r$   rZ   r   r   r   r   r   r   rX      s   
 rX   c                   @   rP   )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   r\   r   rX   r$   r   r   r   r   r[      rR   r[   N)enumr   typingr   r   r   ray._common.pydantic_compatr   r   )ray.dashboard.modules.job.pydantic_modelsr   ray.util.annotationsr	   MAX_ERROR_STACK_TRACE_LENGTHr"   r
   r   r   r   r%   r1   r6   r:   r<   rD   rI   rQ   rS   rX   r[   r   r   r   r   <module>   sF    			 	