o
    `Û·i´  ã                   @   sf   d dl mZmZmZmZ d dlmZ d dlmZ d dl	m
Z
 e
G dd„ dƒƒZe
G dd„ deƒƒZd	S )
é    )ÚAnyÚDictÚListÚOptional)Ú
Checkpoint)ÚTrainRunContext)ÚDeveloperAPIc                   @   s   e Zd ZdZdS )ÚRayTrainCallbackz"Base Ray Train callback interface.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úO/home/ubuntu/vllm_env/lib/python3.10/site-packages/ray/train/v2/api/callback.pyr	      s    r	   c                   @   sP   e Zd ZdZdedeeeef  de	e
 fdd„Zdedeeef fdd	„Zd
S )ÚUserCallbackzÄCallback interface for custom user-defined callbacks to handling events
    during training.

    This callback is called on the Ray Train controller process, not on the
    worker processes.
    Úrun_contextÚmetricsÚ
checkpointc                 C   ó   dS )a*  Called after all workers have reported a metric + checkpoint
        via `ray.train.report`.

        Args:
            run_context: The `TrainRunContext` for the current training run.
            metrics: A list of metric dictionaries reported by workers,
                where metrics[i] is the metrics dict reported by worker i.
            checkpoint: A Checkpoint object that has been persisted to
                storage. This is None if no workers reported a checkpoint
                (e.g. `ray.train.report(metrics, checkpoint=None)`).
        Nr   )Úselfr   r   r   r   r   r   Úafter_report   s   zUserCallback.after_reportÚworker_exceptionsc                 C   r   )a  Called after one or more workers have raised an exception.

        Args:
            run_context: The `TrainRunContext` for the current training run.
            worker_exceptions: A dict from worker world rank to the exception
                raised by that worker.
        Nr   )r   r   r   r   r   r   Úafter_exception+   s   
zUserCallback.after_exceptionN)r
   r   r   r   r   r   r   Ústrr   r   r   r   ÚintÚ	Exceptionr   r   r   r   r   r      s    þý
üÿ
ÿr   N)Útypingr   r   r   r   Ú	ray.trainr   Ú(ray.train.v2._internal.execution.contextr   Úray.util.annotationsr   r	   r   r   r   r   r   Ú<module>   s    