
    &`i#                        d dl Z d dlZd dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZ d dlmZmZ er 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mZ h d
Zh dZh dZddhZh dZ G d de          Zde de
e          fdZ!d+dZ"d Z#ded	         fdZ$d,dZ%d Z&d Z'd e	ed!                  d"ee e(f         fd#Z)d e	ed!                  d"e*fd$Z+d-d'Z,d"e*fd(Z-d)ed"dfd*Z.dS ).    N)Enum)TYPE_CHECKINGDictListOptionalSetUnion)TagKeyrecord_extra_usage_tag)StorageContextBaseTrainerCallbackTrialSchedulerBasicVariantGeneratorSearcher>   TorchTrainerHorovodTrainerXGBoostTrainerLightGBMTrainerTensorflowTrainer>   
JaxTrainerr   r   r   r   DataParallelTrainer>   AxSearchTuneBOHB
HEBOSearchZOOptSearchOptunaSearchBayesOptSearchHyperOptSearchNevergradSearchConcurrencyLimiterRepeater>	   PB2FIFOSchedulerHyperBandForBOHBHyperBandSchedulerMedianStoppingRuleAsyncHyperBandSchedulerPopulationBasedTrainingResourceChangingSchedulerPopulationBasedTrainingReplayc                       e Zd ZdZdZdZdZdS )AirEntrypointz	Tuner.fitzTrainer.fitztune.runztune.run_experimentsN)__name__
__module____qualname__TUNERTRAINERTUNE_RUNTUNE_RUN_EXPERIMENTS     k/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/air/_internal/usage.pyr1   r1   C   s%        EGH1r:   r1   allowed_module_path_prefix	whitelistc                 b    | j         }| j        j        }|                    |          r||v r|S dS )a  Find the class name of the object. If the object is not
    under `allowed_module_path_prefix` or if its class is not in the whitelist,
    return "Custom".

    Args:
        obj: The object under inspection.
        allowed_module_path_prefix: If the `obj`'s class is not under
            the `allowed_module_path_prefix`, its class name will be anonymized.
        whitelist: If the `obj`'s class is not in the `whitelist`,
            it will be anonymized.
    Returns:
        The class name to be tagged with telemetry.
    Custom)r3   	__class__r2   
startswith)objr<   r=   module_pathcls_names        r;   _find_class_namerE   J   s@     .K}%H899 h)>S>Sxr:   trainerr   c                     ddl m} t          | |          sJ t          | dt                    }t          t          j        |           d S )Nr   r   	ray.train)ray.train.trainerr   
isinstancerE   AIR_TRAINERSr   r
   AIR_TRAINER)rF   r   trainer_names      r;   tag_air_trainerrN   `   sT    ------g{+++++#G[,GGL6-|<<<<<r:   c                     ddl m} t          | |          sJ t          | dt                    }t          t          j        |           d S )Nr   )r   rH   )&ray.train.v2.api.data_parallel_trainerr   rJ   rE   TRAIN_V2_TRAINERSr   r
   TRAIN_TRAINER)rF   r   rM   s      r;   tag_train_v2_trainerrS   h   sV    JJJJJJg233333#G[:KLLL6/>>>>>r:   searcherc                 H   ddl m}m} t          | |          rt	          t
          j        d           d S t          | |          rUt          | dt          	                    t                              }|t          v rd S t	          t
          j        |           d S J d            )Nr   r   r   zray.tune.searchFzZNot expecting a non-BasicVariantGenerator, non-Searcher type passed in for `tag_searcher`.)ray.tune.searchr   r   rJ   r   r
   TUNE_SEARCHERrE   TUNE_SEARCHERSunionTUNE_SEARCHER_WRAPPERS)rT   r   r   searcher_names       r;   tag_searcherr\   p   s    ????????(122 
 	v35LMMMMM	Hh	'	' 
(')=)=>T)U)U
 
 222Fv3]CCCCC	
>	
 	
ur:   	schedulerr   c                     ddl m} t          | |          sJ t          | dt                    }t          t          j        |           d S )Nr   r   zray.tune.schedulers)ray.tune.schedulersr   rJ   rE   TUNE_SCHEDULERSr   r
   TUNE_SCHEDULER)r]   r   scheduler_names      r;   tag_schedulerrc      sU    222222i00000%i1FXXN60.AAAAAr:   c                  :    t          t          j        d           d S N1)r   r
    AIR_SETUP_WANDB_INTEGRATION_USEDr9   r:   r;   tag_setup_wandbrh      s    6BCHHHHHr:   c                  :    t          t          j        d           d S re   )r   r
   !AIR_SETUP_MLFLOW_INTEGRATION_USEDr9   r:   r;   tag_setup_mlflowrk      s    6CSIIIIIr:   	callbacksr   returnc                    ddl m} ddlm} ddlm} ddlm} ddlm	} ddl
m} ddlm} ||||f|z   }d	 |D             }	t          j        t                     }
| pg } | D ]e}t#          ||          s|j        j        }||	v r|
|xx         d
z  cc<   4t#          ||          r|
dxx         d
z  cc<   U|
dxx         d
z  cc<   f|
S )zHCreates a map of callback class name -> count given a list of callbacks.r   )CometLoggerCallback)MLflowLoggerCallback)WandbLoggerCallbackr   )LoggerCallback)AimLoggerCallback)DEFAULT_CALLBACK_CLASSESc                     g | ]	}|j         
S r9   )r2   ).0callback_clss     r;   
<listcomp>z$_count_callbacks.<locals>.<listcomp>   s    SSSl+SSSr:      CustomLoggerCallbackCustomCallback)ray.air.integrations.cometro   ray.air.integrations.mlflowrp   ray.air.integrations.wandbrq   ray.tuner   ray.tune.loggerrr   ray.tune.logger.aimrs   ray.tune.utils.callbackrt   collectionsdefaultdictintrJ   r@   r2   )rl   ro   rp   rq   r   rr   rs   rt   built_in_callbackscallback_namescallback_countscallbackcallback_names                r;   _count_callbacksr      s   >>>>>>@@@@@@>>>>>>!!!!!!......555555@@@@@@ 		
 	!! TS@RSSSN!-c22ORI 3 3(H-- 	 *3N**M***a/****.11 	32333q83333,---2----r:   c                     | sdS t          |           }|r0t          j        |          }t          t          j        |           dS dS )a  Records built-in callback usage via a JSON str representing a
    dictionary mapping callback class name -> counts.

    User-defined callbacks will increment the count under the `CustomLoggerCallback`
    or `CustomCallback` key depending on which of the provided interfaces they subclass.
    NOTE: This will NOT track the name of the user-defined callback,
    nor its implementation.

    This will NOT report telemetry if no callbacks are provided by the user.

    Returns:
        bool: True if usage was recorded, False otherwise.
    FN)r   jsondumpsr   r
   AIR_CALLBACKS)rl   r   callback_counts_strs      r;   tag_callbacksr      s]      u&y11O J"j99v35HIIIIIJ Jr:   storager   c                     h d}| j         rd}n| j        j        |v r| j        j        }nd}t          t          j        |           dS )a  Records the storage configuration of an experiment.

    The storage configuration is set by `RunConfig(storage_path, storage_filesystem)`.

    The possible storage types (defined by `pyarrow.fs.FileSystem.type_name`) are:
    - 'local' = pyarrow.fs.LocalFileSystem. This includes NFS usage.
    - 'mock' = pyarrow.fs._MockFileSystem. This is used for testing.
    - ('s3', 'gcs', 'abfs', 'hdfs'): Various remote storage schemes
        with default implementations in pyarrow.
    - 'custom' = All other storage schemes, which includes ALL cases where a
        custom `storage_filesystem` is provided.
    - 'other' = catches any other cases not explicitly handled above.
    >   s3gcsabfshdfsmocklocalcustomotherN)custom_fs_providedstorage_filesystem	type_namer   r
   AIR_STORAGE_CONFIGURATION)r   r=   storage_config_tags      r;   tag_storage_typer      sc     ?>>I! %%		#	-	:	:$7A$6;=OPPPPPr:   c                  B   ddl m}  ddlm} ddlm} t          t                                          | ||                    }g }|D ]%}|t          j
        v r|                    |           &|r0t          j        |          }t          t          j        |           dS dS )ac  Records usage of environment variables exposed by the Ray AIR libraries.

    NOTE: This does not track the values of the environment variables, nor
    does this track environment variables not explicitly included in the
    `all_ray_air_env_vars` allow-list.

    Returns:
        bool: True if at least one environment var is supplied by the user.
    r   )AIR_ENV_VARS)TRAIN_ENV_VARS)TUNE_ENV_VARSTF)ray.air.constantsr   ray.train.constantsr   ray.tune.constantsr   sortedsetrY   osenvironappendr   r   r   r
   )r   r   r   all_ray_air_env_varsuser_supplied_env_varsenv_varenv_vars_strs          r;   tag_ray_air_env_varsr      s     /.....222222000000!L-@@   ' 3 3bj  "))'222 z"899v2LAAAt5r:   
entrypointc                 Z    | t           v sJ t          t          j        | j                   dS )z.Records the entrypoint to an AIR training run.N)r1   r   r
   AIR_ENTRYPOINTvalue)r   s    r;   tag_air_entrypointr     s/    &&&&60*2BCCCCCr:   )rF   r   )r]   r   )r   r   )/r   r   r   enumr   typingr   r   r   r   r   r	   ray._common.usage.usage_libr
   r   ray.train._internal.storager   rI   r   r   r   r_   r   rV   r   r   rK   rQ   rX   rZ   r`   r1   strrE   rN   rS   r\   rc   rh   rk   r   r   boolr   r   r   r   r9   r:   r;   <module>r      s        				       B B B B B B B B B B B B B B B B F F F F F F F F @::::::------!!!!!!222222????????     	 	 	  

 
 
2 2 2 2 2D 2 2 2c c#h    ,= = = =? ? ?
5!DE 
 
 
 
,B B B BI I IJ J J#j)9 : #tCH~ # # # #LJXd:&67 JD J J J J2Q Q Q Q4d    @D= DT D D D D D Dr:   