o
    ni	                     @  sl   d dl mZ d dlZd dlZd dlmZ dZdZddd	ZdddZ	dddZ
ejddG dd dZdS )    )annotationsN)env2tcpreturnServiceToken | Nonec               
   C  s   t jtj} | sdS | d}t|dkrtd|  |\}}}}}|tkr6tdt d| d|  d|t	vrEtd	| d|  dzt
|t|||t|d
W S  tyg } ztd|  |d}~ww )zReads the token from environment variables.

    Returns:
        The token if the correct environment variable is set, or None.

    Raises:
        ValueError: If the environment variable is set but cannot be
            parsed.
    N-   zInvalid token: zExpected version z
, but got z (token=)Unsupported transport: )versionpid	transporthostport)osenvirongetr   SERVICEsplitlen
ValueError_CURRENT_VERSION_SUPPORTED_TRANSPORTSServiceTokenint)tokenpartsr   pid_strr   r   port_stre r!   Y/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/wandb/sdk/lib/service_token.pyget_service_token   s>   

r#   
parent_pidr   r   strr   r   Nonec                 C  s>   |t vrtd| dtt| ||t|ftjtj< dS )a  Stores a service token in an environment variable.

    Args:
        parent_pid: The process ID of the process that started the service.
        transport: The transport used to communicate with the service.
        host: The host part of the internet address on which the service
            is listening (e.g. localhost).
        port: The port the service is listening on.

    Raises:
        ValueError: If given an unsupported transport.
    r   r   N)	r   r   joinr   r%   r   r   r   r   )r$   r   r   r   r!   r!   r"   set_service_token6   s   r(   c                   C  s   t jtjd dS )z:Clears the environment variable storing the service token.N)r   r   popr   r   r!   r!   r!   r"   clear_service_tokenQ   s   r*   T)frozenc                   @  s:   e Zd ZU dZded< ded< ded< ded< ded< d	S )
r   z,An identifier for a running service process.r%   r   r   r   r   r   r   N)__name__
__module____qualname____doc____annotations__r!   r!   r!   r"   r   V   s   
 r   )r   r   )
r$   r   r   r%   r   r%   r   r   r   r&   )r   r&   )
__future__r   dataclassesr   wandbr   r   r   r#   r(   r*   	dataclassr   r!   r!   r!   r"   <module>   s    

*

