o
    c²“iC  ã                   @   sJ   d Z ddlZddlZe e¡ZejG dd„ dƒƒZejG dd„ dƒƒZdS )z#Some utility class for Collectives.é    Nc                   @   ó(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚNCCLUniqueIDStorezéNCCLUniqueID Store as a named actor class.

    Args:
        name: the unique name for this named actor.

    Attributes:
        name: the unique name for this named actor.
        nccl_id: the NCCLUniqueID held in this store.
    c                 C   s   || _ d | _d S )N)ÚnameÚnccl_id)Úselfr   © r   úL/home/ubuntu/.local/lib/python3.10/site-packages/ray/util/collective/util.pyÚ__init__   s   
zNCCLUniqueIDStore.__init__c                 C   s   || _ | j S )zÅ
        Initialize the NCCL unique ID for this store.

        Args:
            uid: the unique ID generated via the NCCL generate_communicator_id API.

        Returns:
            None
        )r   )r   Úuidr   r   r   Úset_id   s   
zNCCLUniqueIDStore.set_idc                 C   s   | j st d | j¡¡ | j S )z*Get the NCCL unique ID held in this store.z.The NCCL ID has not been set yet for store {}.)r   ÚloggerÚwarningÚformatr   ©r   r   r   r   Úget_id%   s
   
ÿzNCCLUniqueIDStore.get_idN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   r   r      s
    
r   c                   @   r   )	ÚInfozrStore the group information created via `create_collective_group`.

    Note: Should be used as a NamedActor.
    c                 C   s"   d | _ d| _d| _d | _d| _d S )Néÿÿÿÿi0u  ©ÚidsÚ
world_sizeÚrankÚbackendÚgloo_timeoutr   r   r   r   r	   5   s
   
zInfo.__init__c                 C   s"   || _ || _|| _|| _|| _dS )zStore collective information.Nr   )r   r   r   r   r   r   r   r   r   Úset_info<   s
   
zInfo.set_infoc                 C   s   | j | j| j| j| jfS )z-Get previously stored collective information.r   r   r   r   r   Úget_infoD   s   ûzInfo.get_infoN)r   r   r   r   r	   r   r   r   r   r   r   r   .   s
    r   )	r   ÚrayÚloggingÚ	getLoggerr   r   Úremoter   r   r   r   r   r   Ú<module>   s    
%