o
    wi
                     @   s   d dl Z d dlZd dlZd dlZd dlmZ d dlmZ zd dlZW n	 e	y+   Y nw ddl
mZmZ ddlmZ deeef ddfd	d
ZdddZdS )    N)Path)Union   )job_environmentutils)
get_loggerfolderreturnc                 C   s  t | tjd< t }|j}t }|d|  |d|j  d}t	|D ]}|j
 r1 ntd q(|j
 sGtd| d|j zDtj|j}t }||| | }|d ~t|j}td	|f| ~|d
 W d   W dS 1 sw   Y  W dS  ty }	 zGz"t|j}tdt f| W d   n1 sw   Y  W n ty }
 z|d|	 d|
  W Y d}
~
nd}
~
ww |d |	d}	~	ww )a#  Loads a pickled job, runs it and pickles the output

    Parameter
    ---------
    folder: Path/str
        path of the folder where the job pickle will be stored (with a name containing its uuid)

    Side-effect
    -----------
    Creates a picked output file next to the job file.
    SUBMITIT_FOLDERzStarting with zLoading pickle: <   r   zWaited for z4 seconds but could not find submitted jobs in path:
zJob completed successfullysuccessz#Exiting after successful completionNerrorzCould not dump error:
z

because of z$Submitted job triggered an exception)strosenvironr   JobEnvironmentpathsr   infosubmitted_picklerangeexiststimesleepRuntimeErrorr   DelayedSubmissionload_handle_signalsresulttemporary_save_pathresult_picklecloudpickle_dump	Exception	traceback
format_excr   )r   envr   logger	wait_time_delayedr   tmppathr   	dumperror r+   U/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/submitit/core/submission.pyprocess_job   sR   


&"
r-   c                  C   s2   t jdd} | jdtdd |  }t|j d S )Nz	Run a job)descriptionr   z/Folder where the jobs are stored (in subfolder))typehelp)argparseArgumentParseradd_argumentr   
parse_argsr-   r   )parserargsr+   r+   r,   submitit_mainH   s   r7   )r	   N)r1   r   r   r"   pathlibr   typingr   numpyImportError r   r   r%   r   r   r-   r7   r+   r+   r+   r,   <module>   s   0