
    &`iq                        d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZ d dlZd dlZd dl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 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 dl.Z.d dl/m0Z0 d dl1m2Z2 d dl3m4Z4 d dl5m6Z6 d dl7m8Z8 d dl9m:Z: n# e;$ r dxZ.xZ8xZ:xZ6Z0Y nw xY wdZ<dZ=dZ>dZ?dZ@dZAdZB e+d          	 	 	 	 d<d!ee         d"eeC         d#eeC         d$eDd%ee:e6f         f
d&            ZE	 	 	 	 d=d'eCd(eCd!ee         d"eeC         d#eeC         d)ee         d%ee:e6f         fd*ZFd+ ZGddd,d-e
d.eeeCe
f                  d/eeeCe
f                  fd0ZHd>d1eeC         d%eeC         fd2ZId?d#eeC         d"eeC         fd3ZJd4e
d%dfd5ZK G d6 d7e jL                  ZM G d8 d9          ZN e+d           G d: d;e'                      ZOdS )@    N)Number)
ModuleType)AnyDictListOptionalSequenceTupleUnion)logger)
load_class)usage)TRAINING_ITERATION)_force_on_current_node)get_session)DEFAULT_SYNC_TIMEOUT)Trial)LoggerCallback)flatten_dict)	PublicAPI)Queue)WBValueImageVideo)RunDisabled)json_dumps_safer)RunWANDB_API_KEYWANDB_PROJECT_NAMEWANDB_GROUP_NAME
WANDB_MODEWANDB_SETUP_API_KEY_HOOK WANDB_POPULATE_RUN_LOCATION_HOOKWANDB_PROCESS_RUN_INFO_HOOKalpha)	stabilityTconfigapi_keyapi_key_filerank_zero_onlyreturnc                    t           st          d          d}d}d}t                      }|r"|r |j        |j        dk    rt	                      S |r|j        }|j        }|j        }|                    d          p||                    d          p||                    d          p|d}	|		                    |           t          d	| ||d|	S )
a  Set up a Weights & Biases session.

    This function can be used to initialize a Weights & Biases session in a
    (distributed) training or tuning run.

    By default, the run ID is the trial ID, the run name is the trial name, and
    the run group is the experiment name. These settings can be overwritten by
    passing the respective arguments as ``kwargs``, which will be passed to
    ``wandb.init()``.

    In distributed training with Ray Train, only the zero-rank worker will initialize
    wandb. All other workers will return a disabled run object, so that logging is not
    duplicated in a distributed run. This can be disabled by passing
    ``rank_zero_only=False``, which will then initialize wandb in every training
    worker.

    The ``config`` argument will be passed to Weights and Biases and will be logged
    as the run configuration.

    If no API key or key file are passed, wandb will try to authenticate
    using locally stored credentials, created for instance by running ``wandb login``.

    Keyword arguments passed to ``setup_wandb()`` will be passed to
    ``wandb.init()`` and take precedence over any potential default settings.

    Args:
        config: Configuration dict to be logged to Weights and Biases. Can contain
            arguments for ``wandb.init()`` as well as authentication information.
        api_key: API key to use for authentication with Weights and Biases.
        api_key_file: File pointing to API key for with Weights and Biases.
        rank_zero_only: If True, will return an initialized session only for the
            rank 0 worker in distributed training. If False, will initialize a
            session for all workers.
        kwargs: Passed to ``wandb.init()``.

    Example:

        .. code-block:: python

            from ray.air.integrations.wandb import setup_wandb

            def training_loop(config):
                wandb = setup_wandb(config)
                # ...
                wandb.log({"loss": 0.123})

    =Wandb was not found - please install with `pip install wandb`Nr   trial_id
trial_namegroup)r0   r1   r2   )r)   r*   r+    )wandbRuntimeErrorr   
world_rankr   r0   r1   experiment_namegetupdate_setup_wandb)
r)   r*   r+   r,   kwargsdefault_trial_iddefault_trial_namedefault_experiment_namesessionwandb_init_kwargss
             n/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/air/integrations/wandb.pysetup_wandbrB   >   s#   n  
K
 
 	
 " mmG ! 	!w)5':LPQ:Q:Q==  :"+$/")"9 JJz**>.>jj..D2DG$$?(?  V$$$ w\ EV      r0   r1   _wandbc           
         |r|                                 ni }|rt          j                            |          }t	          ||           t          |                    dd                     }|                    dt          j                            t                              }	t          |          }t          | |ddd|||	          }
 |
j        d	i | t          j        dk    rdt          j        d<   ndt          j        d<   |pt          } |j        d	i |
}t!          |           t#          j                     |S )
Nprojectr2   T)idnameresumereinitallow_val_changer)   rF   r2   ntthreadWANDB_START_METHODforkr3   )copyospath
expanduser_set_api_key_get_wandb_projectpopenvironr8   WANDB_GROUP_ENV_VAR
_clean_logdictr9   rH   r4   init _run_wandb_process_run_info_hook	air_usagetag_setup_wandb)r0   r1   r)   r*   r+   rD   r;   _configrF   r2   r@   runs               rA   r:   r:      sM     &-fkkmmm2G  8w)),77w''' It!<!<==GJJw
/B C CDDE !!G	 	 	 &&v&&& 
w$+3
'((+1
'(_uF
&+
*
*)
*
*C$S))) JrC   c                 r   t          | t          j                  r2| j        dk    r't          |                                 t
                    S t          | t                    r;t          |           dk    r(t          | d         t          t          t          f          S t          | t
          t          f          S )z3Return True if type is allowed for logging to wandb   r   )
isinstancenpndarraysizeitemr   r	   lenr   r   r   )objs    rA   _is_allowed_typerj      s    #rz"" .sx1}}#((**f---#x   ;SXX\\#a&5%"9:::cFG,---rC   video_kwargsimage_kwargsri   rl   rm   c                z   i i t          | t                    r!fd|                                 D             S t          | t          t          f          rfd| D             S t          | t
                    rt          fd| D                       S t          | t          j                  r| j        dk    rt          | fi S t          | t          j                  rM| j        dk    rB| j
        d         dk    rt          fd| D             	          nt          | d         fi S t          | t          j                  rM| j        d
k    rB| j
        d         dk    rt          fd| D             	          nt          | d         fi S t          |           r| S 	 t          |            t          j        |            | S # t"          $ r\ t%          |           }	 t'          |          }|cY S # t(          $ r Y nw xY w	 t+          |          }|cY S # t(          $ r Y nw xY w|cY S w xY w)Nc                 <    i | ]\  }}|t          |           S rk   rY   ).0kvrm   rl   s      rA   
<dictcomp>z_clean_log.<locals>.<dictcomp>   s>     
 
 
1 z!,\RRR
 
 
rC   c                 4    g | ]}t          |           S rp   rq   rr   rt   rm   rl   s     rA   
<listcomp>z_clean_log.<locals>.<listcomp>   s8     
 
 
 q|,OOO
 
 
rC   c              3   <   K   | ]}t          |           V  dS )rk   Nrq   rw   s     rA   	<genexpr>z_clean_log.<locals>.<genexpr>   sF       
 
 q|,OOO
 
 
 
 
 
rC         r   rb   c                 *    g | ]}t          |fi S r3   r   )rr   rt   rm   s     rA   rx   z_clean_log.<locals>.<listcomp>   )    777aq))L))777rC   rk      c                 *    g | ]}t          |fi S r3   r   )rr   rt   rl   s     rA   rx   z_clean_log.<locals>.<listcomp>  r~   rC   )rc   rZ   itemslistsettuplerd   re   ndimr   shaperY   r   rj   r   pickledumps	Exceptionstrint
ValueErrorfloat)ri   rl   rm   fallbacks    `` rA   rY   rY      s'    #t )
 
 
 
 
		
 
 
 	
 
C$	%	% $
 
 
 
 

 
 
 	
 
C		  
 
 
 
 

 
 
 
 
 	
 
C	$	$ QS))L)))	C	$	$ Q y|a 77773777))    s1v....	
 
C	$	$ Q y|a 77773777))    s1v....	
 
#		 
 	 	S
   s88	8}}HOOO 	 	 	D		XHOOO 	 	 	D	 'sZ   /$G H:.H>H:
HH:HH:H%"H:%
H2/H:1H22H:9H:rF   c                    | st           j                            t                    st           j                            t                    rv	  t          t           j        t                                          nH# t          $ r;}t          j        dt           dt           dt           d| |           Y d}~nd}~ww xY w| sHt           j                            t                    r$t           j                            t                    } | S )z]Get W&B project from environment variable or external hook if not passed
    as and argument.Error executing z to populate z and : exc_infoN)
rQ   rW   r8   WANDB_PROJECT_ENV_VARr%   r   r   r   	exceptionrX   )rF   es     rA   rU   rU   .  s4    
455 JNN;<<	DJrz"BCDDFFFF 	 	 	S#C S S1S S8KS SOPS S        	  8rz~~&;<< 8 *..!677Ns   ,A9 9
B>1B99B>c                    t           j                            t                    dv rdS | r_|rt	          d          t          | d          5 }|                                                                }ddd           n# 1 swxY w Y   |st           j                            t                    s	 t          j
                     t          j        j        rt          j        d           dS n# t          $ r Y nw xY wt           t           j        v rf	  t#          t           j        t                                          }n8# t$          $ r+}t          j        dt            d| |           Y d}~nd}~ww xY w|r|t           j        t          <   dS t           j                            t                    s't	          d	                    t                              dS )
a  Set WandB API key from `wandb_config`. Will pop the
    `api_key_file` and `api_key` keys from `wandb_config` parameter.

    The order of fetching the API key is:
      1) From `api_key` or `api_key_file` arguments
      2) From WANDB_API_KEY environment variables
      3) User already logged in to W&B (wandb.api.api_key set)
      4) From external hook WANDB_SETUP_API_KEY_HOOK
    >   offlinedisabledNz,Both WandB `api_key_file` and `api_key` set.rtzAlready logged into W&B.r   z to setup API key: r   zNo WandB API key found. Either set the {} environment variable, pass `api_key` or `api_key_file` to the`WandbLoggerCallback` class as arguments, or run `wandb login` from the command line)rQ   rW   r8   WANDB_MODE_ENV_VARr   openreadlinestripWANDB_ENV_VARr4   ensure_configuredapir*   r   infoAttributeErrorr$   r   r   r   format)r+   r*   fpr   s       rA   rT   rT   G  s<    
z~~())-DDD , 	MKLLL,%% 	,kkmm))++G	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,  2:>>-88 	#%%%y  6777  	 	 	D	 $rz11J*RZ0H%IJJLL    W'?WWTUWW        
  
$+
=!!!Z^^M** 
9 :@9N9N	
 
 	

 
s<   'A??BB18C, ,
C98C9,D= =
E2!E--E2r`   c                     t           t          j        v ri	  t          t          j        t                              |            dS # t          $ r,}t          j        dt            d| |           Y d}~dS d}~ww xY wdS )z8Run external hook to process information about wandb runzError calling r   r   N)r&   rQ   rW   r   r   r   r   )r`   r   s     rA   r\   r\   w  s    "bj00	?Jrz"=>??DDDDD 	 	 	C!<CCCCa         	 10s   -A 
A:!A55A:c                   h    e Zd Z ej                    Z ej                    Z ej                    ZdS )
_QueueItemN)__name__
__module____qualname__enumautoENDRESULT
CHECKPOINTr3   rC   rA   r   r     s5        
$)++CTY[[FJJJrC   r   c            	       t    e Zd ZdZdededee         dee         fdZd Zdefd	Z	d
e
dee
e
f         fdZdS )_WandbLoggingActora  
    Wandb assumes that each trial's information should be logged from a
    separate process. We use Ray actors as forking multiprocessing
    processes is not supported by Ray and spawn processes run into pickling
    problems.

    We use a queue for the driver to communicate with the logging process.
    The queue accepts the following items:

    - If it's a dict, it is assumed to be a result and will be logged using
      ``wandb.log()``
    - If it's a checkpoint object, it will be saved using ``wandb.log_artifact()``.
    logdirqueueexclude	to_configc                    dd l }|| _        t          j        |           || _        t          |          | _        t          |          | _        || _        || _	        | j	        
                    dd          | _        || _        d S )Nr   rH   unknown)r4   rD   rQ   chdirr   r   _exclude
_to_configargsr;   r8   _trial_name_logdir)selfr   r   r   r   r   r;   r4   s           rA   __init__z_WandbLoggingActor.__init__  sv     	

Gi..	;??69==rC   c                 v   dt           j        d<    | j        j        | j        i | j        }| j        |j        _        t          |           	 | j
                                        \  }}|t          j        k    rn%|t          j        k    r|                     |           U|t          j        k    sJ |                     |          \  }}	 | j        j                            |d           | j                            ||                    t(                               n|# t*          j        j        $ r>}t1          j        d                    t7          |                               Y d }~n/d }~wt8          $ r}t1          j        d|           Y d }~nd }~ww xY wS| j                                         d S )NrM   rN   T)rK   )stepzFailed to log result to w&b: {}zFileNotFoundError: Did not log result to Weights & Biases. Possible cause: relative file path used instead of absolute path. Error: %s)rQ   rW   rD   r[   r   r;   r   r)   trial_log_pathr\   r   r8   r   r   r   _handle_checkpointr   _handle_resultr9   logr   urlliberror	HTTPErrorr   warningr   r   FileNotFoundErrorfinish)r   r`   	item_typeitem_contentr   config_updater   s          rA   r`   z_WandbLoggingActor.run  s   +3
'(dk	9T[99$(L
!(---	&*jnn&6&6#I|JN**J111''555
 11111!%!4!4\!B!BC"))-$)OOO#''2D*E*EFFFF<) Q Q Q @GGAOOPPPPPPPP$     	       %	2 	s%   AD" "F64E//F<FFcheckpoint_pathc                     | j                             d| j         d          }|                    |           | j                             |           d S )Ncheckpoint_model)rH   type)rD   Artifactr   add_dirlog_artifact)r   r   artifacts      rA   r   z%_WandbLoggingActor._handle_checkpoint  s`    ;''1t/11 ( 
 
 	)))  *****rC   resultr-   c                    |                     di                                           }i }t          |d          }|                                D ]a\  }t	          fd| j        D                       r&t	          fd| j        D                       r||<   Lt          |          s\||<   b|                    dd            ||fS )Nr)   /)	delimiterc              3   T   K   | ]"}                     |d z             p|k    V  #dS r   N
startswithrr   rg   rs   s     rA   rz   z4_WandbLoggingActor._handle_result.<locals>.<genexpr>  s<      SST1<<s
++8qDySSSSSSrC   c              3   T   K   | ]"}                     |d z             p|k    V  #dS r   r   r   s     rA   rz   z4_WandbLoggingActor._handle_result.<locals>.<genexpr>  s<      WWtQ\\$*--:dWWWWWWrC   	callbacks)	r8   rP   r   r   anyr   r   rj   rV   )r   r   r   r   flat_resultrt   rs   s         @rA   r   z!_WandbLoggingActor._handle_result  s    

8R005577"6S999%%'' 	 	DAqSSSST]SSSSS WWWWtWWWWW #$a  %a(( A+t,,,M!!rC   N)r   r   r   __doc__r   r   r   r   r`   r   r   r
   r   r3   rC   rA   r   r     s           c	
 9   .! ! !F+# + + + +"T "eD$J.? " " " " " "rC   r   c                   l   e Zd ZdZddgZg dZ	 eZddddddddeddfde	e
         de	e
         d	e	e
         d
e	e
         de	ee
                  dedededede	e         de	e         fdZd Zd(dZdddee
         fdZd(dZdedddefdZd(dZd)dddefdZd(d Zd*d"ed#efd$Zd%ed         fd&Zd' ZdS )+WandbLoggerCallbackao  WandbLoggerCallback

    Weights and biases (https://www.wandb.ai/) is a tool for experiment
    tracking, model optimization, and dataset versioning. This Ray Tune
    ``LoggerCallback`` sends metrics to Wandb for automatic tracking and
    visualization.

    Example:

        .. testcode::

            import random

            from ray import tune
            from ray.air.integrations.wandb import WandbLoggerCallback


            def train_func(config):
                offset = random.random() / 5
                for epoch in range(2, config["epochs"]):
                    acc = 1 - (2 + config["lr"]) ** -epoch - random.random() / epoch - offset
                    loss = (2 + config["lr"]) ** -epoch + random.random() / epoch + offset
                    train.report({"acc": acc, "loss": loss})


            tuner = tune.Tuner(
                train_func,
                param_space={
                    "lr": tune.grid_search([0.001, 0.01, 0.1, 1.0]),
                    "epochs": 10,
                },
                run_config=tune.RunConfig(
                    callbacks=[WandbLoggerCallback(project="Optimization_Project")]
                ),
            )
            results = tuner.fit()

        .. testoutput::
            :hide:

            ...

    Args:
        project: Name of the Wandb project. Mandatory.
        group: Name of the Wandb group. Defaults to the trainable
            name.
        api_key_file: Path to file containing the Wandb API KEY. This
            file only needs to be present on the node running the Tune script
            if using the WandbLogger.
        api_key: Wandb API Key. Alternative to setting ``api_key_file``.
        excludes: List of metrics and config that should be excluded from
            the log.
        log_config: Boolean indicating if the ``config`` parameter of
            the ``results`` dict should be logged. This makes sense if
            parameters will change during training, e.g. with
            PopulationBasedTraining. Defaults to False.
        upload_checkpoints: If ``True``, model checkpoints will be uploaded to
            Wandb as artifacts. Defaults to ``False``.
        video_kwargs: Dictionary of keyword arguments passed to wandb.Video()
            when logging videos. Videos have to be logged as 5D numpy arrays
            to be affected by this parameter. For valid keyword arguments, see
            https://docs.wandb.ai/ref/python/data-types/video/. Defaults to ``None``.
        image_kwargs: Dictionary of keyword arguments passed to wandb.Image()
            when logging images. Images have to be logged as 3D or 4D numpy arrays
            to be affected by this parameter. For valid keyword arguments, see
            https://docs.wandb.ai/ref/python/data-types/image/. Defaults to ``None``.
        **kwargs: The keyword arguments will be passed to ``wandb.init()``.

    Wandb's ``group``, ``run_id`` and ``run_name`` are automatically selected
    by Tune, but can be overwritten by filling out the respective configuration
    values.

    Please see here for all other valid configuration settings:
    https://docs.wandb.ai/ref/python/init/
    doneshould_checkpoint)r0   experiment_tagnode_ipexperiment_idhostnamepiddateNFrF   r2   r+   r*   excludes
log_configupload_checkpointssave_checkpointsupload_timeoutrl   rm   c                 Z   t           st          d          |rt          j        dt                     |}|| _        || _        || _        || _        |pg | _	        || _
        || _        |	| _        |
pi | _        |pi | _        || _        d | _        i | _        i | _        i | _        i | _        d S )Nr/   zC`save_checkpoints` is deprecated. Use `upload_checkpoints` instead.)r4   r5   warningswarnDeprecationWarningrF   r2   api_key_pathr*   r   r   r   _upload_timeoutrl   rm   r;   _remote_logger_class_trial_logging_actors_trial_logging_futures_logging_future_to_trial_trial_queues)r   rF   r2   r+   r*   r   r   r   r   r   rl   rm   r;   s                rA   r   zWandbLoggerCallback.__init__I  s      	O    	2MU"   "2
( B$"4-(.B(.B$(!  	" EG#FH%35rC   c                    | j         r$t          j                            | j                   nd | _        t          | j        | j                   t          | j                  | _        | j        st          dt           d          | j        sOt          j                            t                    r-t          j                            t                    | _        d S d S d S )Nz8Please pass the project name as argument or through the z environment variable.)r   rQ   rR   rS   r+   rT   r*   rU   rF   r   r   r2   rW   r8   rX   )r   r   r;   s      rA   setupzWandbLoggerCallback.setupy  s    595FPBGt0111D 	 	T&555)$,77| 	E,E E E   z 	=bjnn-@AA 	=(;<<DJJJ	= 	= 	= 	=rC   trialr   c           
          |j                                         }|                    dd             j                                        }| j        z  } j        s|dgz  }|r|j        nd }|rt          |          nd } j        }|r j	        p|j
        nd }t          |          } fd|                                D             }t          ||ddd|||          }|                     j                     j        ||fi | d S )Nr   r)   c                 .    i | ]\  }}|j         v||S r3   )r   )rr   keyvaluer   s      rA   ru   z7WandbLoggerCallback.log_trial_start.<locals>.<dictcomp>  s2     
 
 
%33dm;S;SC;S;S;SrC   FT)rG   rH   rI   rJ   rK   r2   rF   r)   )r)   rP   rV   _exclude_resultsr   r   r0   r   rF   r2   experiment_dir_namerY   r   rZ   r9   r;   _start_logging_actor)	r   r  r)   exclude_resultsr0   r1   wandb_projectwandb_groupr@   s	   `        rA   log_trial_startz#WandbLoggerCallback.log_trial_start  sX   ""$$

;%%%/4466 	4=(  	*z)O &+45>>#(2SZZZd
  BGPdj=E$=D F##
 
 
 
)/
 
 
 !!!	
 	
 	
 	  ---!!%NN<MNNNNNrC   r  c           	      8   || j         v rd S | j        sni }t          t          j        v rt          j        t                   |t          <    t          j        d	ddit                      d|iddd| j                  | _        t          ddit                      ddd          | j
        |<    | j        j        d	|j        | j
        |         || j        d|| j        |<   | j        |         j                                        }|| j         |<   || j        |<   d S )
Nnum_cpusr   env_vars)runtime_envmax_restartsmax_task_retries)r  r  )actor_options)r   r   r   r   r3   )r   r   r   rQ   rW   rayremoter   _logger_actor_clsr   r   
local_pathAUTO_CONFIG_KEYSr   r`   r   )r   r  r  r@   r  logging_futures         rA   r
  z(WandbLoggerCallback._start_logging_actor  s   
 D///F( 	&H
***,*]*C')
 ) ))(**) (2!#) ) ) ) $)& )&D% %*A(** !#$&	  %
 %
 %
5! -MD,E,L -
#$U+#+	-
 -

  -
 -
"5) 3E:>EEGG-;#E*8=%n555rC   c                 ^    | j         |                             t          j        d f           d S N)r   putr   r   r   r  s     rA   _signal_logging_actor_stopz.WandbLoggerCallback._signal_logging_actor_stop  s+    5!%%z~t&<=====rC   	iterationr   c                     || j         vr|                     |           t          || j        | j                  }| j        |                             t          j        |f           d S )Nrk   )	r   r  rY   rl   rm   r   r  r   r   )r   r"  r  r   s       rA   log_trial_resultz$WandbLoggerCallback.log_trial_result  sq    222  '''!2AR
 
 
 	5!%%z'8&&ABBBBBrC   c                     | j         rn|j        rid }t          |j        j        t          j        j                  r|j        j        }|r2| j        |         	                    t          j        |f           d S d S d S d S r  )r   
checkpointrc   
filesystempyarrowfsLocalFileSystemrR   r   r  r   r   )r   r  checkpoint_roots      rA   log_trial_savez"WandbLoggerCallback.log_trial_save  s    " 	Xu'7 	X"O%*5wz7QRR 8"'"2"7 X"5)--z/Do.VWWWWW	X 	X 	X 	X
X XrC   failedc                 Z    |                      |           |                                  d S )Nr  )r!  _cleanup_logging_actors)r   r  r-  s      rA   log_trial_endz!WandbLoggerCallback.log_trial_end  s1    ''e'444$$&&&&&rC   c                 t    | j         |= | j        |= t          j        | j        |                    | j        |= d S r  )r   r   r  killr   r   s     rA   _cleanup_logging_actorz*WandbLoggerCallback._cleanup_logging_actor  sA    u%'.+E2333&u---rC   r   timeoutkill_on_timeoutc                 x   t          | j                                                  }t          j        |t          |          |          \  }}|D ]1}| j                            |          }|                     |           2|r4|D ]3}| j                            |          }	|                     |	           2dS dS )a'  Clean up logging actors that have finished uploading to wandb.
        Waits for `timeout` seconds to collect finished logging actors.

        Args:
            timeout: The number of seconds to wait. Defaults to 0 to clean up
                any immediate logging actors during the run.
                This is set to a timeout threshold to wait for pending uploads
                on experiment end.
            kill_on_timeout: Whether or not to kill and cleanup the logging actor if
                it hasn't finished within the timeout.
        )num_returnsr5  N)	r   r   valuesr  waitrh   r   rV   r4  )
r   r5  r6  futuresr   	remainingready_futurefinished_trialremaining_futurer  s
             rA   r0  z+WandbLoggerCallback._cleanup_logging_actors  s     t299;;<<(7GgVVVi  	8 	8L!:>>|LLN''7777 	3$- 3 3 599:JKK++E2222	3 	33 3rC   trialsc                 >    |                      | j        d           dS )zzWait for the actors to finish their call to `wandb.finish`.
        This includes uploading all logs + artifacts to wandb.Tr5  r6  N)r0  r   )r   r@  r   s      rA   on_experiment_endz%WandbLoggerCallback.on_experiment_end  s'     	$$T-ASW$XXXXXrC   c                     t          j                    rDt          | j                  D ]}|                     |           |                     dd           i | _        i | _        i | _        i | _        d S )Nr/     TrB  )	r  is_initializedr   r   r!  r0  r   r   r   r   s     rA   __del__zWandbLoggerCallback.__del__  s     	Jd899 = =//e/<<<<((D(III%'"&(#(*%rC   )r  r   )F)r   F)r   r   r   r   r  r  r   r  r   r   r   r   boolr   rZ   r   r  r  r
  r!  r   r$  r,  r1  r4  r0  rC  rG  r3   rC   rA   r   r     sY       J JZ  34   M* "&#&*!%(, #(!&2'+'+.6 .6#.6 }.6 sm	.6
 #.6 49%.6 .6 !.6 .6 .6 tn.6 tn.6 .6 .6 .6`= = =*O *O *O *OX&>&>/3Cy&> &> &> &>P> > > >C# Cg Ct C C C CX X X X' '7 'D ' ' ' '. . . .3 3s 3 3 3 3 30YW Y Y Y Y

  
  
  
  
 rC   r   )NNNT)NNNNr  )NN)Pr   rQ   r   r   r   numbersr   typesr   typingr   r   r   r   r	   r
   r   numpyrd   
pyarrow.fsr(  r  r   ray._common.utilsr   ray.air._internalr   r]   ray.air.constantsr   ray.air.util.noder   ray.train._internal.sessionr   ray.train._internal.syncerr   ray.tune.experimentr   ray.tune.loggerr   ray.tune.utilsr   ray.utilr   ray.util.queuer   r4   (wandb.sdk.data_types.base_types.wb_valuer   wandb.sdk.data_types.imager   wandb.sdk.data_types.videor   wandb.sdk.lib.disabledr   
wandb.utilr   wandb.wandb_runr   ImportErrorr   r   rX   r   r$   r%   r&   r   rH  rB   r:   rj   rY   rU   rT   r\   Enumr   r   r   r3   rC   rA   <module>ra     s0    				                D D D D D D D D D D D D D D D D D D         



       ( ( ( ( ( ( 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 4 4 4 3 3 3 3 3 3 ; ; ; ; ; ; % % % % % % * * * * * * ' ' ' ' ' '                  	BLLL@@@@@@000000000000222222++++++####### B B B=AAEAAsA[777B  , ( ! 
 6  $F  
 <  W!!"&	W WTNWc]W 3-W 	W 3W W W Wz "!"&#'2 222 TN2 c]	2
 3-2 Z 2 32 2 2 2j. . . .2-1	T T T	T 4S>*T 4S>*	T T T Tn  #    2-
 -
x} -
hsm -
 -
 -
 -
`# $           `" `" `" `" `" `" `" `"F Wv  v  v  v  v . v  v  v  v  v s   (B1 1CC