o
    "jo                  	   @   s  d dl Z d dlmZmZ d dlmZ i ddefddefdd	efd
defddefddefddefddefddefddefddefddefddefddefd d!efd"d#efd$d%efd&efd'efd(efd)efd*efd+efd,efd-Zd.d/ Z	d0d1 Z
dS )2    N)	REMAINDERArgumentParser)	strtoboolZPOD_IPhostZPADDLE_MASTERZmasterZPADDLE_DEVICESZdevicesZPADDLE_NNODESZnnodesZPADDLE_RUN_MODEZrun_modeZPADDLE_LOG_LEVELZ	log_levelZPADDLE_LOG_OVERWRITEZlog_overwriteZPADDLE_SORT_IPZsort_ipZPADDLE_NPROC_PER_NODEZnproc_per_nodeZPADDLE_JOB_IDZjob_idZPADDLE_RANKrankZPADDLE_LOG_DIRZlog_dirZPADDLE_MAX_RESTARTZmax_restartZPADDLE_ELASTIC_LEVELZelastic_levelZPADDLE_ELASTIC_TIMEOUTZelastic_timeoutZPADDLE_SERVER_NUMZ
server_numZPADDLE_TRAINER_NUMZtrainer_numZserversZtrainersZ	gloo_portZ	with_glooZ
start_portipsZauto_parallel_config)ZPADDLE_SERVERS_ENDPOINTSZPADDLE_TRAINERS_ENDPOINTSZPADDLE_GLOO_PORTZPADDLE_WITH_GLOOZPADDLE_START_PORTZ
PADDLE_IPSZPADDLE_AUTO_PARALLEL_CONFIGc                   C   s&   t jdd  t jdd  t j S )NZ
http_proxyZhttps_proxy)osenvironpopcopy r   r   l/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddle/distributed/launch/context/args_envs.py
fetch_envs/   s   
r   c               	   C   sr  t  } | d}|jdtd dd |jdtddd |jdtd	d
d |jdtddd |jdtddd |jdtddd |jdtddd |jdtddd |jdtd dd |jdtddd |jdtd dd |jdtd d!d |jd"d#d$d%td d&d |jd'td d(d |jd)td d*d |jd+td,d-d |jd.td d/d |jd0td1d2 |jd3td d4d |jd5td6 | d7}|jd8td9d:d |jd;td9d<d |jd=td d>d |jd?td d@d |jdAtdBdCd |jdDtddEd | dF}|jdGtdHdId |jdJtd	dKd |jdLtdMdNd |  }tt	dOd	}|dPkr7t
|dP dQs2J ||dP _|S )RNzBase Parametersz--masterz%the master/rendezvous server, ip:port)typedefaulthelpz--legacyFzuse legacy launchz--rankzthe node rankz--log_levelINFOzlog level. Default INFOz--log_overwritez'overwrite exits logfiles. Default Falsez	--sort_ipzrank node by ip. Default Falsez--enable_gpu_logTz2enable capture gpu log while running. Default Truez--nnodes1z)the number of nodes, i.e. pod/node numberz--nproc_per_nodez the number of processes in a podz	--log_dirlogz.the path for each process's log. Default ./logz
--run_modez+run mode of the job, collective/ps/ps-heterz--job_idr   z%unique id of the job. Default defaultz	--devicesz--gpusz--npusz--xpusz'accelerate devices. as --gpus,npus,xpusz--hostzhost ipz--ipsz#nodes ips, e.g. 10.10.1.1,10.10.1.2z--start_porti  zfix port start withz--auto_parallel_configzGauto parallel config file absolute path, the file should be json formatZtraining_scriptzHthe full path of py script,followed by arguments for the training script)r   r   z--auto_tuner_jsonzauto tuner json file pathZtraining_script_args)nargszParameter-Server Parametersz	--servers zservers endpoints full listz
--trainersztrainers endpoints full listz--trainer_numznumber of trainersz--server_numznumber of serversz--gloo_portio  zgloo http portz--with_gloozuse gloo or notzElastic Parametersz--max_restart   z the times can restart. Default 3z--elastic_levelzHelastic level: -1 disable, 0 failed exit, peers hold, 1 internal restartz--elastic_timeout   z1seconds to wait before elastic job begin to trainZPADDLE_TRAINER_IDr   r   )r   add_argument_groupadd_argumentstrr   intr   parse_known_argsr   getenvhasattrr   )parserZ
base_groupZps_groupZelastic_groupargsZenv_rankr   r   r   
parse_args6   s$  





r#   )r   argparser   r   Zdistutils.utilr   r   r   Zenv_args_mappingr   r#   r   r   r   r   <module>   s`   	
