
    Vh                     :   d Z ddlmZ ddlmZmZ ddlmZ ddlmZ ddl	Z
ddlmZ ddlmZ d	e
j        d
efdZd	e
j        defdZe G d d                      Ze G d d                      Ze G d d                      Ze G d d                      ZdS )z'
Basic configuration for Dora is here.
    )	Namespace)	dataclassfield)fnmatch)PathN)
DictConfig)	OmegaConfdataargsc                     | j         D ]L}t          |t                    sJ t          ||          r#t	          ||          }|t          | ||           MdS )z>Update the given dataclass from the argument parser args.
    N)__dict__
isinstancestrhasattrgetattrsetattr)r
   r   keyvalues       O/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/dora/conf.pyupdate_from_argsr      so     } * *#s#####4 	*D#&&E c5)))* *    cfgc                 8   t          j        |d          }t          |t                    sJ |                                D ]W\  }}t          |t
                    sJ t          | |          rt          | ||           >t          d| j	         d|           dS )z6Update the given dataclass from the hydra config.
    T)resolvezObject of type z does not have an attribute N)
r	   to_containerr   dictitemsr   r   r   AttributeError	__class__)r
   r   dctr   r   s        r   update_from_hydrar!      s     
 d
3
3
3Cc4     iikk F F
U#s#####4 	FD#u%%%%  "E4> "E "E?B"E "E F F FF Fr   c                   ~   e Zd ZU dZdZeed<   dZeed<   dZ	eed<   dZ
eed	<   d
Zej        e         ed<   dZeed<   d
Zej        e         ed<    ee          Zej        e         ed<   dZeed<   dZeed<   dZeed<   dZeed<   d
Zej        e         ed<   d
Zej        e         ed<   d
Zej        e         ed<   d
S )SlurmConfiga+  
    Configuration when scheduling a job.
    This differs slightly from Slurm/Submitit params because this will
    automatically scale some values based on the number of GPUs.

    Args:
        gpus (int): number of total GPUs to schedule. Number of nodes
            and tasks per nodes will be automatically inferred.
        mem_per_gpu (float): amount of memory in GB to schedule
            per gpus.
        time (int): maximum duration for the job in minutes.
        cpus_per_gpu (int): number of cpus per gpu, this will set
            the `cpus_per_task` automatically, based on the
            number of gpus and `one_task_per_node`, unless `cpus_per_task`
            is explicitely provided.
        cpus_per_task (int or None): number of cpus per task.
        partition (str): partition name
        comment (str): comment for the job.
        setup (List[str]): list of shell commands to execute
            before the actual command. Use it for `module load`.
        max_num_timeout (int): maximum number of requeue.
        one_task_per_node (bool): if True, schedules a single task
            per node, otherwise, will schedule one task per gpu (default is False).
        array_parallelism (int): when using job arrays, how many tasks can run
            in parallel.
        qos: (str or None): qos param for slurm.
        account: (str or None): account param for slurm.

    ..warning:: this assumes one task per GPU.
        Set `one_task_per_node` if you do not want that.
        Tasks without any gpus are not really supported at the moment.
       gpus(   mem_per_gpui  time
   cpus_per_gpuNcpus_per_tasklearnlab	partitioncommentdefault_factorysetup   max_num_timeout 
constraintFone_task_per_node   array_parallelismexcludeqosaccount)__name__
__module____qualname____doc__r%   int__annotations__r'   floatr(   r*   r+   tpOptionalr-   r   r.   r   listr1   Listr3   r5   r6   boolr8   r9   r:   r;    r   r   r#   r#   .   sD         @ D#MMMKD#L#&*M2;s#***Is $GR[$$$%555E273<555OSJ#t### s    $GR[$$$ CS	    $GR[$$$$$r   r#   c                   L    e Zd ZU dZdZeed<   dZeed<   dZeed<   dZ	eed<   dS )SubmitRulesa:  
    Submit rules describe in which case Shepherd will schedule new jobs.

    Args:
        retry (bool): if true, all failed or canceled jobs will be rescheduled.
        update_pending (bool): if true, all pending jobs whose Slurm parameters
            have changed will be replaced.
        update (bool): if true, all pending or running jobs whose Slurm parameters
            have changed will be replaced.
        replace (bool): if true, all running jobs will be replaced by new jobs.
        replace_done (bool): if true, all done jobs will be relaunched.
    Fretryupdatereplacereplace_doneN)
r<   r=   r>   r?   rK   rG   rA   rL   rM   rN   rH   r   r   rJ   rJ   a   s^           E4FDGTL$r   rJ   c                   h    e Zd ZU dZdZeed<   dZeed<   dZeed<   dZ	eed<   dZ
eed	<   d
Zeed
<   dS )
ShepConfigz
    Configuration for Shepherd. Mostly naming conventions for folders and files.
    There should be little reasons to change that.
    zjob.pkljob_fileby_idorphanssubmititsubmitit_folderlatestlatest_submititarraysN)r<   r=   r>   r?   rQ   r   rA   rR   rS   rU   rW   rX   rH   r   r   rP   rP   v   s~           HcE3GS%OS%%%#OS###FCr   rP   c                   X    e Zd ZU dZ ed          Zeed<    ee          Z	e
j        e         ed<   dZeed<   dZe
j        e         ed	<   dZe
j        e         ed
<   dZeed<   dZeed<    ee          Zeed<   dZeed<   dZeed<   dZeed<   dZeed<   dedefdZ fdZ xZS )
DoraConfiga<  
    Main Dora configuration. The main parameters to change are the following.

    Args:
        dir (Path or str): path where Dora will save all useful informations, logs.
            This is also where you should store your checkpoints (see `dora.xp.XP`).
        exclude (List[str]): list of patterns of argument names to ignore
            when computing the XP signature and doing deduplication.
            For instance 'num_workers', etc.
        git_save (bool): when True, experiments can only be scheduled from a clean repo.
            A shallow clone of the repo will be made and execution will happen from there.
            This does not impact `dora run` unless you pass the `--git_save` flag.
        shared (Path or None): if provided, the path to a central repository of XPs.
            For the moment, this only supports sharing hyper-params, logs etc. will stay
            in the per user folder.
        grid_package (str or None): if provided, package to look for grids. Default
            to the package with the `train.py` module followed by `.grids`.
    z	./outputsdirr/   r9   Fgit_saveNsharedgrid_packagezhistory.jsonhistoryxpsshepzrendezvous.txtrendezvous_fileuse_rendezvousgrids_gridscodes_codesarg_namereturnc                 @    | j         D ]}t          ||          r dS dS )zUReturn True if the given argument name should be excluded from
        the signature.TF)r9   r   )selfrh   patterns      r   is_excludedzDoraConfig.is_excluded   s8     | 	 	Gx)) ttur   c                     |dv r ddl m} |t           ||                    }t                                          ||           d S )N)r[   r]   r$   )to_absolute_path)r\   ro   r   super__setattr__)rk   namer   ro   r   s       r   rq   zDoraConfig.__setattr__   s`    $$$222222 --e4455D%(((((r   )r<   r=   r>   r?   r   r[   rA   r   rE   r9   rC   rF   r   r\   rG   r]   rD   r^   r_   r`   rP   ra   rb   rc   re   rg   rm   rq   __classcell__)r   s   @r   rZ   rZ      sb         $ [!!C!!!!E$777GRWS\777Hd $FBK$$$%)L"+c"))) "GS!!!CuZ888D*888+OS+++ ND   FCFCC D    ) ) ) ) ) ) ) ) )r   rZ   )r?   argparser   dataclassesr   r   r   pathlibr   typingrC   omegaconf.dictconfigr   	omegaconfr	   Anyr   r!   r#   rJ   rP   rZ   rH   r   r   <module>r{      s          ( ( ( ( ( ( ( (                 + + + + + +      *26 * * * * *FBF F F F F F /% /% /% /% /% /% /% /%d        ( 
 
 
 
 
 
 
 
 1) 1) 1) 1) 1) 1) 1) 1) 1) 1)r   