o
    $i/                     @   s   U d dl Z d dlmZmZmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZ daed	 ed
< e  Zde ZeddG dd	 d	eZedddefddZdS )    N)AnyDictOptional)session)V2_MIGRATION_GUIDE_MESSAGE_v2_migration_warnings_enabled)TrainContext)	_copy_doc)PlacementGroupFactory)
Deprecated	PublicAPITuneContext_tune_contextz`{}` is deprecated for Ray Tune because there is no concept of worker ranks for Ray Tune, so these methods only make sense to use in the context of a Ray Train worker. beta)	stabilityc                   @   sf  e Zd ZdZeejdefddZeejdefddZeej	de
fddZ	eejdefd	d
Zedeeef fddZeede deejdefddZeede deejdefddZeede deejdefddZeede deejdefddZeede deejdefddZdS )r   z5Context to access metadata within Ray Tune functions.returnc                 C      t  S N)r   get_trial_nameself r   M/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/tune/context.pyr   "      zTuneContext.get_trial_namec                 C   r   r   )r   get_trial_idr   r   r   r   r   &   r   zTuneContext.get_trial_idc                 C   r   r   )r   get_trial_resourcesr   r   r   r   r   *   r   zTuneContext.get_trial_resourcesc                 C   r   r   )r   get_trial_dirr   r   r   r   r   .   r   zTuneContext.get_trial_dirc                 C   s   t d)NzG`get_metadata` is deprecated for Ray Tune, as it has never been usable.)DeprecationWarningr   r   r   r   get_metadata4   s   zTuneContext.get_metadataget_world_size)messagewarningc                 C   r   r   )r   r   r   r   r   r   r   :      zTuneContext.get_world_sizeget_world_rankc                 C   r   r   )r   r#   r   r   r   r   r#   B   r"   zTuneContext.get_world_rankget_local_rankc                 C   r   r   )r   r$   r   r   r   r   r$   J   r"   zTuneContext.get_local_rankget_local_world_sizec                 C   r   r   )r   r%   r   r   r   r   r%   R   s   z TuneContext.get_local_world_sizeget_node_rankc                 C   r   r   )r   r&   r   r   r   r   r&   \   r"   zTuneContext.get_node_rankN)__name__
__module____qualname____doc__r	   r   r   strr   r   r
   r   r   r   r   r   +_TRAIN_SPECIFIC_CONTEXT_DEPRECATION_MESSAGEformatr   TrainV1Contextr   intr#   r$   r%   r&   r   r   r   r   r      sX    r   c                   C   s:   t  tdu r
t atW  d   S 1 sw   Y  dS )zGet or create a singleton Ray Tune context.

    The context is only available in a tune function passed to the `ray.tune.Tuner`.

    See the :class:`~ray.tune.TuneContext` API reference to see available methods.
    N)_tune_context_lockr   r   r   r   r   r   get_contexte   s
   
$r1   )	threadingtypingr   r   r   ray.train._internalr   ray.train.constantsr   r   ray.train.contextr   r.   ray.train.utilsr	   #ray.tune.execution.placement_groupsr
   ray.util.annotationsr   r   r   __annotations__Lockr0   r,   r   r1   r   r   r   r   <module>   s$   
 J