o
    $ik                     @   sP   d dl mZ d dlmZ d dlZd dlmZ eG dd dZG dd dZdS )	    )	dataclass)ListN)Backendc                   @   s*   e Zd ZU dZeed< eed< eed< dS )Communicatorz=
    A handle to a communicator that we are a member of.
    namerankbackendN)__name__
__module____qualname____doc__str__annotations__int r   r   e/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/experimental/collective/communicator.pyr      s
   
 r   c                   @   s~   e Zd ZdZdeejj dedefddZ	dejjfdd	Z
ed
eejj fddZed
efddZed
efddZdS )CommunicatorHandlezj
    A communicator handle used by the driver to store handles to the
    actors in the communicator.
    actorsr   r   c                 C   s   || _ || _t|| _dS )a  
        Initializes the CommunicatorHandle with the given actor handles.
        Assumes that the communicator has already been initialized on all actors.

        Args:
            actors: A list of actor handles to be stored.
            name: Name of the communicator.
            backend: Communicator backend. See
                ray.util.collective.types for valid values.
        N)_actors_namer   _backend)selfr   r   r   r   r   r   __init__   s   zCommunicatorHandle.__init__actorc                 C   s(   t | jD ]\}}||kr|  S qdS )N)	enumerater   )r   r   iar   r   r   get_rank,   s
   zCommunicatorHandle.get_rankreturnc                 C   s   | j dd S )z@
        Return all actor handles in this communicator.
        N)r   r   r   r   r   r   2   s   zCommunicatorHandle.actorsc                 C      | j S N)r   r    r   r   r   r   9      zCommunicatorHandle.namec                 C   r!   r"   )r   r    r   r   r   r   =   r#   zCommunicatorHandle.backendN)r	   r
   r   r   r   rayr   ActorHandler   r   r   propertyr   r   r   r   r   r   r   r      s    r   )	dataclassesr   typingr   r$   ray.util.collective.typesr   r   r   r   r   r   r   <module>   s    