
    Vh&
                         d dl mZ d dlmZ d dlZd dlmZ d dlZd dl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  eed          Zdde	j        e         dedefdZdefdZdS )    )	ExitStack)partialN)rmtree   )git_save)start_ddp_workers)DecoratedMain)disable_logging
simple_logred)ShepherdzLaunch:Fargvmainclearc           	         t          |t                    }|                    |           }|j        |                                 |                                s|j        }t          t          d|j         d|j         d                     |rRt          d           |	                    |j                   |
                                 t          j        d           nt          t          d                     |ri|j        j                                        rMt          d           	 t!          |j        j                   dS # t"          $ r t          d	           Y dS w xY wdS dS )
z{This 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         N/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/dora/run.pycheck_job_and_clearr&      s    c""H((..Ey}} 		Q)CU
UUUUUVVWWW Q2333$$UY///!!!
1CNOOPPP R'')) R*+++	R58?##### 	R 	R 	RPQQQQQQ	R	R R R Rs   .E	 	E&%E&c                    |                     | j                  }t                      5 }| j        rdt          j        vrdt          j        d<   t          j        |          }t          j        ||           |                    t          j	        |                     t	          j
        t          j        t          j        ddgt          j        dd          z              | j        rVt          j                            d          s7t          | j        || j                   t#          || j        | j                   nudt          j        vr9t          | j        || j                   dt          j        d<   dt          j        d<   | j        t          j        dd <   t'                        |             d d d            d S # 1 swxY w Y   d S )	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   s   	TY		B	 = 	T2"*DD03BJ,-*400E!"e,,, 4U ; ;<<<HS^cndF%Cchqrrl%RSSS8 
	BJNN622 
		4<<<dDIt/?@@@@2:--#DItTZ@@@%(
6"+.
<(9CHQRRLDFFF#                 s   FF>>GG)F)
contextlibr   	functoolsr   r/   shutilr   r6   typingtpr    r   executorr   r   r	   r   r
   r   r   shepr   Liststrboolr&   r>        r%   <module>rL      s<   !                 				       



            ' ' ' ' ' '       1 1 1 1 1 1 1 1 1 1      gj)$$R Rbgcl R- R R R R R4=      rK   