o
    b²“iñ	  ã                   @   s\   d dl mZm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 G dd„ deƒZdS )é    )ÚListÚTuple)Úformat_readonly_node_type)ÚNodeProvider)ÚNODE_KIND_HEADÚSTATUS_UP_TO_DATEÚTAG_RAY_NODE_KINDÚTAG_RAY_NODE_NAMEÚTAG_RAY_NODE_STATUSÚTAG_RAY_USER_NODE_TYPEc                   @   sŽ   e Zd ZdZdd„ Zdd„ Zdeeeef  fdd„Z	d	d
„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zedd„ ƒZdS )ÚReadOnlyNodeProviderzÂA node provider that merely reports the current cluster state.

    This is used for laptop mode / manual cluster setup modes, in order to
    provide status reporting in the same way for users.c                 C   s   t  | ||¡ i | _d S ©N)r   Ú__init__Únodes)ÚselfÚprovider_configÚcluster_name© r   úb/home/ubuntu/.local/lib/python3.10/site-packages/ray/autoscaler/_private/readonly/node_provider.pyr      s   
zReadOnlyNodeProvider.__init__c                 C   s   dS )NTr   )r   r   r   r   Úis_readonly   ó   z ReadOnlyNodeProvider.is_readonlyr   c                 C   s.   i }|D ]\}}t |ƒ|dœ||< q|| _dS )z‚Update the set of nodes in the cluster.

        Args:
            nodes: List of (node_id, node_manager_address) tuples.
        )Ú	node_typeÚipN)r   r   )r   r   Ú	new_nodesÚnode_idÚnode_manager_addressr   r   r   Ú
_set_nodes   s   ý
zReadOnlyNodeProvider._set_nodesc                 C   s   t | j ¡ ƒS r   )Úlistr   Úkeys)r   Útag_filtersr   r   r   Únon_terminated_nodes-   s   z)ReadOnlyNodeProvider.non_terminated_nodesc                 C   s
   || j v S r   ©r   ©r   r   r   r   r   Ú
is_running0   ó   
zReadOnlyNodeProvider.is_runningc                 C   s
   || j vS r   r!   r"   r   r   r   Úis_terminated3   r$   z"ReadOnlyNodeProvider.is_terminatedc                 C   s"   t tt| j| d t|tti}|S )Nr   )r   r   r   r   r	   r
   r   ©r   r   Útagsr   r   r   Ú	node_tags6   s   üzReadOnlyNodeProvider.node_tagsc                 C   ó   |S r   r   r"   r   r   r   Úexternal_ip?   r   z ReadOnlyNodeProvider.external_ipc                 C   r)   r   r   r"   r   r   r   Úinternal_ipB   r   z ReadOnlyNodeProvider.internal_ipc                 C   ó   t dƒ‚©Nz(Readonly node provider cannot be updated©ÚAssertionErrorr&   r   r   r   Úset_node_tagsE   ó   z"ReadOnlyNodeProvider.set_node_tagsc                 C   r,   r-   r.   )r   Únode_configr'   Úcountr   r   r   Úcreate_nodeH   r1   z ReadOnlyNodeProvider.create_nodec                 C   r,   r-   r.   r"   r   r   r   Úterminate_nodeK   r1   z#ReadOnlyNodeProvider.terminate_nodec                 C   s   | S r   r   )Úcluster_configr   r   r   Úbootstrap_configN   s   z%ReadOnlyNodeProvider.bootstrap_configN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ústrr   r    r#   r%   r(   r*   r+   r0   r4   r5   Ústaticmethodr7   r   r   r   r   r      s     	r   N)Útypingr   r   Úray.autoscaler._private.utilr   Úray.autoscaler.node_providerr   Úray.autoscaler.tagsr   r   r   r	   r
   r   r   r   r   r   r   Ú<module>   s
     
