
    ]i&
                         S SK Jr  S SKJr  S SKrS SKJr  S SKrS SKr	S SK
r
SSKJr  SSKJr  SSKJr  SS	KJrJrJr  SS
KJr  \" \S5      rSS\	R.                  \   S\S\4S jjrS\4S jrg)    )	ExitStack)partialN)rmtree   )git_save)start_ddp_workers)DecoratedMain)disable_logging
simple_logred)ShepherdzLaunch:argvmainclearc           	         [        U[        5      nUR                  U 5      nUR                  b  UR	                  5         UR                  5       (       d  UR                  n[        [        SUR                   SUR                   S35      5        U(       aM  [        S5        UR                  UR                  5        UR                  5         [        R                  " S5        O[        [        S5      5        U(       aV  UR                  R                  R                  5       (       a,  [        S5         [!        UR                  R                  5        ggg! ["         a    [        S	5         gf = f)
zsThis will check if an existing job is running and warn,
unless --clear is passed, in which case we must cancel it.
NzFound existing slurm job z with status .zCancelling the existing job.   z4PLEASE ABORT NOW UNLESS YOU ARE SURE OF WHAT YOU DO.zRemoving existing XP folder.z>Failed to properly remove folder, but things should be okay...)r   logget_sheep_from_argvjobupdateis_doner   job_idstatecancel_lazycommittimesleepxpfolderexistsr   OSError)r   r   r   shepherdsheepr   s         E/mnt/rpi/tmp/demucs-venv-sys/lib/python3.13/site-packages/dora/run.pycheck_job_and_clearr&      s
    c"H((.Eyy}}))C/

|=STUVW23$$UYY/!

1CNOP''))*+	R588??# *u  	RPQ	Rs   3E E-,E-c                 $   UR                  U R                  5      n[        5        nU R                  (       a  S[        R
                  ;  a  S[        R
                  S'   [        R                  " U5      n[        R                  " X$5        UR                  [        R                  " U5      5        [        R                  " [        R                  [        R                  SS/[        R                  SS  -   5        U R                  (       ae  [        R
                  R                  S5      (       dA  [        U R                  XR                   5        [#        XR                  U R$                  5        OS[        R
                  ;  aF  [        U R                  XR                   5        S[        R
                  S'   S[        R
                  S'   U R                  [        R                  SS & ['        5         U" 5         S S S 5        g ! , (       d  f       g = f)	N_DORA_GIT_SAVE_DONE1z-mdorar   RANK
WORLD_SIZE0)get_xpr   r   r   osenvironget_new_cloneassign_cloneenter_contextenter_cloneexecvsys
executableddpgetr&   r   r   ddp_workersr
   )argsr   r   stackclones        r%   
run_actionr>   2   sA   	TYY	B	==2"**D03BJJ,-**40E!!", 4 4U ;<HHS^^cnndF%Cchhqrl%RS88BJJNN622		4<dIIt/?/?@2::-#DIItZZ@%(

6"+.

<(99CHHQRLF# 
s   GH
H)F)
contextlibr   	functoolsr   r/   shutilr   r6   typingtpr    r   executorr   r   r	   r   r
   r   r   shepr   Liststrboolr&   r>        r%   <module>rL      sl    !  	  
    '  1 1 j)$Rbggcl R- R R4= rK   