
    mi                         d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZ ddlmZ dd	lmZmZ dd
lmZ d Zd Zd Zd Zedk(  r e        yy)z
This is the central dispatch of the `dora` command. From there you can
check grid files, launch XPs, check their logs etc, as well
as doing local runs for debugging.
    N   )grid_action)info_action)launch_action)fatalsetup_logging
simple_log)
run_action)import_actionexport_action)get_mainc                     | j                  dddd       | j                  dddd       | j                  d	d
dd       | j                  dddd d       y )Nz-rz--retry
store_truezRetry failed jobsactionhelpz-Rz	--replacezReplace any running job.z-Dz--replace_donezAlso resubmit done jobs.z--no_git_savestore_falsegit_savez6Temporarily deactivate git_save for any scheduled job.r   destdefaultr   )add_argumentparsers    G/var/www/stems/demucs_env/lib/python3.12/site-packages/dora/__main__.pyadd_submit_rulesr      sw    
i0  2
k,7  9
.|7  9
JX\U  W    c                     | j                  ddt        d       | j                  ddd       | j                  d	d
ddd       | j                  ddd       | j                  dd       y )Nz-gz--gpuszNumber of gpus.typer   z-pz--partitionz
Partition.r   z--devstore_const	partitiondevlabzUse dev partition.)r   r   constr   z-cz	--commentzComment.z--constraintzConstraint.)r   intr   s    r   add_slurm_configr'   "   su    
hS7HI
m,?
Kx1  3
k
;
];r   c                     t        j                         } | j                  ddd d       | j                  dd d       | j                  ddd	d
       | j                  dddd      }|j	                  d      }t        |       t        |       |j                  ddd	d       |j                  dd	d       |j                  dddt        d       |j                  dddd       |j                  d d	d!       |j                  d"d#t        d$%       |j                  d&d'd	d(       |j                         }|j                  d)d*t        d+%       |j                  d,d-t        d.%       |j                  d/d0t        d.%       |j                  d1d	d2       |j                  dd3d45       |j                  d6d7d85       |j                  t        9       |j	                  d:d;<      }|j                  d)d=d><       |j                  d?d@d	dA       |j                  dBt        dC%       |j                  dDd	dEdFG       |j                  dd	dH       |j                  dId7J       |j                  t        9       |j	                  dK      }|j                  d)d=d><       |j                  dLdMd	dN       |j                  dOddPddQR       |j                  ddd	dS       |j                  dd	dH       t        |       t        |       |j                  dId7J       |j                  t        9       |j	                  dT      }|j                  d)d=d><       |j                  dUdVdW<       |j                  ddd	dX       |j                  d,d-d	dY       |j                  d/d0d	dZ       |j                  d[d\d	d]       |j                  dId7J       |j                  t        9       |j	                  d^      }|j                  t        9       |j	                  d_      }|j                  d`d7da5       |j                  t         9       | S )bNz	--packagez-PzTraining module. You can also set the DORA_PACKAGE env. In last resort, Dora will look for a package in the current folder with module defined at --runfile flag.)r   r   z--main_modulezTraining exec name. Dora will search for this module to run within the package provided by --package flag. You can also set DORA_MAIN_MODULE env. Defaults to 'train' module.z	--verbosez-vr   zShow debug info.r   commandzCommand to executeT)titler   requiredr   gridz-Cz--cancelzCancel all running jobs.z--clearz=Remove XP folder, reschedule all jobs, starting from scratch.z-iz
--interval   zIUpdate status and metrics every that number of minutes. Default is 5 min.)r   r    r   z--no_monitoringr   monitorz5No monitoring, just schedule and print current state.)r   r   r   z	--dry_runz9Only simulate actions but does not run any call to Slurm.z-Tz--trimz;Trim history to the length of the exp with the given index.r   z-Lz--trim_lastzTrim history to the slowest.z-fz--folderz0Show the folder for the job with the given indexz-lz--logz-Show the log for the job with the given indexz-tz--tailz--initz=Init the given XPs so that their signature can be referenced.?zKName of the grid to run. Name of the module will be `package`.grids.`name`.)nargsr   patterns*zXOnly handle experiments matching all the given pattern. If empty, handle all experiments)r   runzRun locally the given command.r!   z
--from_sigz$Signature of job to use as baseline.z-dz--ddpzDistributed training.z--ddp_workersz5Nb of workers for distributed, default to nb of GPUs.z
--git_saveFzRun from a clean git clone.)r   r   r   z8Remove XP folder, reschedule job, starting from scratch.argv)r0   launchz-az--attachzPAttach to the remote process. Interrupting the command will kill the remote job.z	--no_tailtailz*Does not tail the log once job is started.r   z#Cancel any existing job and return.infoz-jz--job_idzFind job by job id.z
Cancel jobzShow entire logzTail logz-mz	--metricszShow last metricsimportexportsigszAll the XP sigs to export.)argparseArgumentParserr   add_subparsers
add_parserr   r'   floatr&   add_mutually_exclusive_groupset_defaultsr   r
   r   r   r   r   )	r   
subparsersr,   groupr3   r5   r7   import_r9   s	            r   
get_parserrE   +   s   $$&F
T"  # Z  [ T,EWX&&2T	 ' SJ  (DTTdJ|5  7iZ  \dL!%/  0 	'IR  T 	k,V  XdH3X  ZdM,9  ; --/E	tZcN  P	tW3K  M	tXCK  M 	h|Z  \ 	cZ  \ 	j>  ? 	[)


,L

MCT<.TUT7<>UV_3Q  S\,7  9Y|T  VV3'J'""8,F
l1WX
j4  5 MPTI  K
jB  D
	,W  YVV
c*
}-  (DdL/UVdJ-BCdJ|,OdGL?PQdH\
KdKCVWfC([)##H-G.""8,F
c0LM
}-Mr   c                  >   t               } | j                         }t        |j                         |j                  t        d       t        |j                  |j                        }t        |dd       I	 |j                  |j                        }t        ddd|j                         ||j                  z   |_        t        |dd       |j                  |j                   _        |j	                  ||       y # t        $ r t        d|j                          Y w xY w)NzYou must give an action.from_sigz(Could not find an existing run with sig ParserzInjecting argvzfrom sigr   )rE   
parse_argsr   verboser   r   r   main_modulepackagegetattrget_argv_from_sigrG   RuntimeErrorr	   r4   r   dora)r   argsmainr4   s       r   rR   rR      s    \FD$,,{{()D$$dll3DtZ&2	N))$--8D 	8-tZO499$	tZ&2!]]		KKd  	N<T]]OLM	Ns   5C8 8!DD__main__)__doc__r;   r,   r   r7   r   r5   r   logr   r   r	   r3   r
   sharer   r   _utilsr   r   r'   rE   rR   __name__ r   r   <module>rZ      sR   
    ! 1 1  / W<gT0 zF r   