o
    rôjÛ  ã                   @   sœ   d dl Z d dlZd dlmZ ddlmZ ddlmZmZm	Z	m
Z
 ddlmZmZmZ ddlmZ dZd	d
„ Zddd„Zdd„ Zdd„ ZedkrLeƒ  dS dS )é    N)ÚComputeEnvironmenté   )Úget_cluster_input)Ú	cache_dirÚdefault_config_fileÚdefault_yaml_config_fileÚload_config_from_file)Ú
_ask_fieldÚ_ask_optionsÚ_convert_compute_environment)Úget_sagemaker_inputzŸLaunches a series of prompts to create and save a `default_config.yaml` configuration file for your training system. Should always be ran first on your machinec                  C   s.   t dddgtƒ} | tjkrtƒ }|S tƒ }|S )Nz-In which compute environment are you running?zThis machinezAWS (Amazon SageMaker))r
   r   r   ÚAMAZON_SAGEMAKERr   r   )Zcompute_environmentÚconfig© r   úr/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/accelerate/commands/config/config.pyÚget_user_input   s   ý
ÿr   c                 C   sN   | d ur| j dtd�}ntjdtd�}|jdd dd� | d ur%|jtd� |S )Nr   )ÚdescriptionzAccelerate config commandz--config_fileaT  The path to use to store the config file. Will default to a file named default_config.yaml in the cache location, which is the content of the environment `HF_HOME` suffixed with 'accelerate', or if you don't have such an environment variable, your cache directory ('~/.cache' or the content of `XDG_CACHE_HOME`) suffixed with 'huggingface'.)ÚdefaultÚhelp)Úfunc)Ú
add_parserr   ÚargparseÚArgumentParserÚadd_argumentÚset_defaultsÚconfig_command)Ú
subparsersÚparserr   r   r   Úconfig_command_parser,   s   ür   c                 C   sd   t ƒ }| jd ur| j}ntj t¡st t¡ t}| d¡r$| 	|¡ n| 
|¡ td|› �ƒ d S )Nz.jsonz"accelerate configuration saved at )r   Úconfig_fileÚosÚpathÚisdirr   Úmakedirsr   ÚendswithÚto_json_fileZto_yaml_fileÚprint)Úargsr   r   r   r   r   r   B   s   



r   c                  C   s   t ƒ } |  ¡ }t|ƒ d S ©N)r   Ú
parse_argsr   )r   r'   r   r   r   ÚmainR   s   r*   Ú__main__r(   )r   r    Úaccelerate.utilsr   Úclusterr   Úconfig_argsr   r   r   r   Zconfig_utilsr	   r
   r   Ú	sagemakerr   r   r   r   r   r*   Ú__name__r   r   r   r   Ú<module>   s   

ÿ