
    &`i                     2   U d dl Z 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mZ d dlmZmZ d dlmZmZmZ erd dlmZ dad	ed
<    e j                    Zde Zde Z ed           G d d                      Z ed          defd            ZdS )    N)TYPE_CHECKINGAnyDictOptional)session)StorageContext)V2_MIGRATION_GUIDE_MESSAGE_v2_migration_warnings_enabled)	_copy_doc_log_deprecation_warning)
DeprecatedDeveloperAPI	PublicAPI)PlacementGroupFactoryzOptional[TrainContext]_default_contextz`get_metadata` was an experimental API that accessed the metadata passed to `<Framework>Trainer(metadata=...)`. This API can be replaced by passing the metadata directly to the training function (e.g., via `train_loop_config`). z`{}` is deprecated because the concept of a `Trial` will soon be removed in Ray Train.Ray Train will no longer assume that it's running within a Ray Tune `Trial` in the future. stable)	stabilityc                   t   e Zd ZdZ eej                  defd            Z eej                  de	fd            Z eej
                  de	fd            Z
 eej                  de	fd            Z eej                  de	fd            Z eej                  de	fd            Ze eej                  defd	                        Z ee e            
           eej                  deeef         fd                        Z ee                    d           e            
           eej                  defd                        Z ee                    d           e            
           eej                  defd                        Z ee                    d           e            
           eej                  dd                        Z ee                    d           e            
           eej                  defd                        ZdS )TrainContextzJContext containing metadata that can be accessed within Ray Train workers.returnc                 (    t          j                    S N)r   get_experiment_nameselfs    e/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/train/context.pyr   z TrainContext.get_experiment_name*   s    *,,,    c                 (    t          j                    S r   )r   get_world_sizer   s    r   r   zTrainContext.get_world_size.       %'''r   c                 (    t          j                    S r   )r   get_world_rankr   s    r   r"   zTrainContext.get_world_rank2   r    r   c                 (    t          j                    S r   )r   get_local_rankr   s    r   r$   zTrainContext.get_local_rank6   r    r   c                 (    t          j                    S r   )r   get_local_world_sizer   s    r   r&   z!TrainContext.get_local_world_size:   s    +---r   c                 (    t          j                    S r   )r   get_node_rankr   s    r   r(   zTrainContext.get_node_rank>   s    $&&&r   c                 (    t          j                    S r   )r   get_storager   s    r   r*   zTrainContext.get_storageB   s     "$$$r   )messagewarningc                 (    t          j                    S r   )r   get_metadatar   s    r   r.   zTrainContext.get_metadataI        #%%%r   get_trial_namec                 (    t          j                    S r   )r   r0   r   s    r   r0   zTrainContext.get_trial_nameQ   s     %'''r   get_trial_idc                 (    t          j                    S r   )r   r2   r   s    r   r2   zTrainContext.get_trial_idY   r/   r   get_trial_resourcesr   c                 (    t          j                    S r   )r   r4   r   s    r   r4   z TrainContext.get_trial_resourcesa   s     *,,,r   get_trial_dirc                 (    t          j                    S r   )r   r6   r   s    r   r6   zTrainContext.get_trial_dirk   s     $&&&r   N)r   r   )__name__
__module____qualname____doc__r   r   r   strr   intr"   r$   r&   r(   r   r*   r   r   !_GET_METADATA_DEPRECATION_MESSAGEr
   r.   r   r   *_TUNE_SPECIFIC_CONTEXT_DEPRECATION_MESSAGEformatr0   r2   r4   r6    r   r   r   r   &   s       TTYw*++-S - - - ,+- Yw%&&( ( ( ( '&( Yw%&&( ( ( ( '&( Yw%&&( ( ( ( '&( Yw+,,.c . . . -,. Yw$%%'s ' ' ' &%' Yw"##%^ % % % $# \%
 Z1..00   Yw#$$&d38n & & & %$	 
& Z:AABRSS..00   Yw%&&( ( ( ( '&	 
( Z:AA.QQ..00   Yw#$$&c & & & %$	 
& Z:AA!
 
 /.00	   Yw*++- - - ,+ - Z:AA/RR..00   Yw$%%'s ' ' ' &%	 
' ' 'r   r   r   c                     ddl m}   |             r5ddlm} t	                      rt          dt                       |            S t          5  t          t                      at          cddd           S # 1 swxY w Y   dS )zGet or create a singleton training context.

    The context is only available within a function passed to Ray Train.

    See the :class:`~ray.train.TrainContext` API reference to see available methods.
    r   )_in_tune_session)get_contextz`ray.train.get_context()` should be switched to `ray.tune.get_context()` when running in a function passed to Ray Tune. This will be an error in the future. N)
%ray.tune.trainable.trainable_fn_utilsrC   ray.tunerD   r
   r   r	   _context_lockr   r   )rC   get_tune_contexts     r   rD   rD   t   s     GFFFFF  
"<<<<<<)++ 	$0 .0 0    !!! 
    #+~~                                   s   A66A:=A:)	threadingtypingr   r   r   r   ray.train._internalr   ray.train._internal.storager   ray.train.constantsr	   r
   ray.train.utilsr   r   ray.util.annotationsr   r   r   #ray.tune.execution.placement_groupsr   r   __annotations__LockrG   r>   r?   r   rD   rA   r   r   <module>rS      s        5 5 5 5 5 5 5 5 5 5 5 5 ' ' ' ' ' ' 6 6 6 6 6 6        @ ? ? ? ? ? ? ? D D D D D D D D D D JIIIIII .2 * 1 1 1	  $ "$ $ "$ "	$ $ + XJ' J' J' J' J' J' J' J'Z X \            r   