
    &`i                         d dl mZ d dlm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mZ d d	lmZ  G d
 de          Zd Zd Z e            efdefd            Z e            efde
fd            ZdS )    )defaultdict)	lru_cacheN)ResourceNotExistsError)ServiceResource)
BaseClient)Config)cf
cli_logger)BOTO_MAX_RETRIESc                       e Zd ZdZd ZdS )LazyDefaultDicta  
    LazyDefaultDict(default_factory[, ...]) --> dict with default factory

    The default factory is call with the key argument to produce
    a new value when a key is not present, in __getitem__ only.
    A LazyDefaultDict compares equal to a dict with the same items.
    All remaining arguments are treated the same as if they were
    passed to the dict constructor, including keyword arguments.
    c                 B    |                      |          | |<   | |         S )z
        __missing__(key) # Called by __getitem__ for missing key; pseudo-code:
          if self.default_factory is None: raise KeyError((key,))
          self[key] = value = self.default_factory(key)
          return value
        )default_factory)selfkeys     u/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/autoscaler/_private/aws/utils.py__missing__zLazyDefaultDict.__missing__   s%     ((--S	Cy    N)__name__
__module____qualname____doc__r    r   r   r   r      s-             r   r   c           	      f   d }d }t          | d          r| j                            dd           }||                    dd           }d |j        |i |t	          j        |          g}g d}||v rdt	          j        d          z   dz   t	          j        d	          z   d
z   t	          j        d          z   }dt	          j        d          z   dz   }	dt	          j        d          z   dz   }
dt	          j        d          z   dz   }d}t          j        |  t          j	        t          |                      t          j        d           t          j                     t          j        d           t          j        t	          j        |                     t          j        d           t          j        t	          j        |	                     t          j        t	          j        |
                     t          j        t	          j        |                     t          j                     t          j        d           t          j        t	          j        |                     t          j                     t          j        |  t          j                     t          j        d          5  t          j	        dt          t          |                                t          j        dt          |                      d d d            n# 1 swxY w Y   t          j                     d S )NresponseErrorCodez{}
Error code: {})ExpiredTokenExceptionExpiredTokenRequestExpiredz7aws sts get-session-token --serial-number arn:aws:iam::ROOT_ACCOUNT_IDz:mfa/AWS_USERNAMEz --token-code TWO_FACTOR_AUTH_CODEzexport AWS_SECRET_ACCESS_KEY = 
REPLACE_MEz' # found at Credentials.SecretAccessKeyzexport AWS_SESSION_TOKEN = z$ # found at Credentials.SessionTokenzexport AWS_ACCESS_KEY_ID = z# # found at Credentials.AccessKeyIdzBhttps://gist.github.com/maximsmol/a0284e1d97b25d417bd9ae02e5f450cfzYour AWS session has expired.zYou can request a new one usingz then expose it to Ray by settingz-You can find a script that automates this at:zBoto3 error:z{})hasattrr   getformatr	   bold
underlinedr
   verbose_errorverbosevarspanicnewlineabortverbatim_error_ctxstr)excmsgargskwargs
error_code
error_infogeneric_message_argscredentials_expiration_codestoken_commandsecret_key_varsession_token_varaccess_key_id_varaws_session_script_urls                r   handle_boto_errorr?   $   sk   JJsJ 5\%%gt44
^^FD11
 	
D#F##

$ $ $  111,m-../  mN++	,
  m2334 	 .mL))*78 	 *mL))*45 	 *mL))*34 	 Q 	 	 "677499%%%8999:;;;//000;<<<00111!233444!233444HIII'=>>??? 	 *++		&~	6	6 ) )4T#YY000s3xx((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) s   5ALLLc                 >      G  fdd          } |            S )Nc                   $    e Zd Zd Z fdZdS )>boto_exception_handler.<locals>.ExceptionHandlerContextManagerc                     d S )Nr   )r   s    r   	__enter__zHboto_exception_handler.<locals>.ExceptionHandlerContextManager.__enter__   s    Dr   c                 R    dd l }||j        j        u rt          |gR i  d S d S )Nr   )botocore
exceptionsClientErrorr?   )r   typevaluetbrF   r4   r5   r3   s        r   __exit__zGboto_exception_handler.<locals>.ExceptionHandlerContextManager.__exit__   sK    OOOx*666!%>t>>>v>>>>> 76r   N)r   r   r   rD   rL   )r4   r5   r3   s   r   ExceptionHandlerContextManagerrB      sG        	 	 		? 	? 	? 	? 	? 	? 	? 	? 	?r   rM   r   )r3   r4   r5   rM   s   ``` r   boto_exception_handlerrN      sR    ? ? ? ? ? ? ? ? ? ? ? ? *)+++r   returnc                     t          j        dt          j        |           t          j        |                     |                    dt          d|i                     t          j        | |fi |S )Nz"Creating AWS resource `{}` in `{}`configmax_attemptsretries)r
   r+   r	   r(   
setdefaultr   boto3resourcenameregionmax_retriesr5   s       r   resource_cacher\      s     ,bgdmmRWV__   4555   >    r   c                 <   	 t          | ||fi |j        j        S # t          $ rv t	          j        dt          j        |           t          j        |                     |                    dt          d|i                     t          j        | |fi |cY S w xY w)Nz Creating AWS client `{}` in `{}`rQ   rR   rS   )r\   metaclientr   r
   r+   r	   r(   rU   r   rV   rX   s       r   client_cacher`      s    
dFKBB6BBGNN! 
 
 
.rwv	
 	
 	
 	NK8999	
 	
 	
 |
 
 
 
 	
 	
 	

s    A=BB)collectionsr   	functoolsr   rV   boto3.exceptionsr   boto3.resources.baser   botocore.clientr   botocore.configr   "ray.autoscaler._private.cli_loggerr	   r
   !ray.autoscaler._private.constantsr   r   r?   rN   r\   r`   r   r   r   <module>ri      se   # # # # # #        3 3 3 3 3 3 0 0 0 0 0 0 & & & & & & " " " " " " = = = = = = = = > > > > > >    k   ,[ [ [|, , , .    " +; 
 
* 
 
 
 
 
 
r   