o
    1 ié  ã                   @   s|   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 d dlmZ d dlmZ d dlmZ dZeG d	d
„ d
eƒƒZdS )é    )ÚAnyÚDictÚListÚOptional)Ú
Checkpoint)Úget_session)ÚTrainRunContext)ÚUserCallback)Ú_in_tune_session)ÚDeveloperAPIZcheckpoint_pathc                   @   s>   e Zd ZdZdd„ Zdedeeee	f  de
e fdd„Zd	S )
ÚTuneReportCallbackzJPropagate metrics and checkpoint paths from Ray Train workers to Ray Tune.c                 C   s   t ƒ stdƒ‚tƒ  ¡ | _d S )Nz2TuneReportCallback must be used in a Tune session.)r
   ÚRuntimeErrorr   Z _get_or_create_inter_actor_queueÚ_training_actor_item_queue)Úself© r   új/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/ray/tune/integration/ray_train.pyÚ__init__   s   ÿzTuneReportCallback.__init__Úrun_contextÚmetricsÚ
checkpointc                 C   s*   |d   ¡ }|r|j|t< | j |¡ d S )Nr   )ÚcopyÚpathÚCHECKPOINT_PATH_KEYr   Úput)r   r   r   r   r   r   r   Úafter_report   s   
zTuneReportCallback.after_reportN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ústrr   r   ÚRayTrainCheckpointr   r   r   r   r   r      s    þýür   N)Útypingr   r   r   r   Z	ray.trainr   r    Zray.train._internal.sessionr   Z(ray.train.v2._internal.execution.contextr   Zray.train.v2.api.callbackr	   Z%ray.tune.trainable.trainable_fn_utilsr
   Zray.util.annotationsr   r   r   r   r   r   r   Ú<module>   s    