U
    ºO.eß  ã                   @   sž   d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ e  e¡ZG d
d„ deƒZdS )é    N)ÚCallableÚListÚOptionalÚSequenceÚUnion)ÚLiteral)ÚRepresentationMixin)ÚParslExecutor)ÚThreadPoolExecutor)ÚConfigurationError)Ú
TaskRecord)ÚMonitoringHubc                   @   s¼   e Zd ZdZejdeee  e	ee
e  eded
 ed ed ed f ee e	eeeeeegef  eee eee e	e	ddœdd„ƒZee
e dœdd„ƒZeje
e dœdd„ƒZdS )ÚConfigaA  
    Specification of Parsl configuration options.

    Parameters
    ----------
    executors : list of ParslExecutor, optional
        List of `ParslExecutor` instances to use for executing tasks.
        Default is [:class:`~parsl.executors.threads.ThreadPoolExecutor()`].
    app_cache : bool, optional
        Enable app caching. Default is True.
    checkpoint_files : sequence of str, optional
        List of paths to checkpoint files. See :func:`parsl.utils.get_all_checkpoints` and
        :func:`parsl.utils.get_last_checkpoint` for helpers. Default is None.
    checkpoint_mode : str, optional
        Checkpoint mode to use, can be ``'dfk_exit'``, ``'task_exit'``, ``'periodic'`` or ``'manual'``.
        If set to `None`, checkpointing will be disabled. Default is None.
    checkpoint_period : str, optional
        Time interval (in "HH:MM:SS") at which to checkpoint completed tasks. Only has an effect if
        ``checkpoint_mode='periodic'``.
    garbage_collect : bool. optional.
        Delete task records from DFK when tasks have completed. Default: True
    internal_tasks_max_threads : int, optional
        Maximum number of threads to allocate for submit side internal tasks such as some data transfers
        or @joinapps
        Default is 10.
    monitoring : MonitoringHub, optional
        The config to use for database monitoring. Default is None which does not log to a database.
    retries : int, optional
        Set the number of retries (or available retry budget when using retry_handler) in case of failure. Default is 0.
    retry_handler : function, optional
        A user pluggable handler to decide if/how a task retry should happen.
        If no handler is specified, then each task failure incurs a retry cost
        of 1.
    run_dir : str, optional
        Path to run directory. Default is 'runinfo'.
    strategy : str, optional
        Strategy to use for scaling blocks according to workflow needs. Can be 'simple', 'htex_auto_scale', 'none'
        or `None`.
        If 'none' or `None`, dynamic scaling will be disabled. Default is 'simple'. The literal value `None` is
        deprecated.
    max_idletime : float, optional
        The maximum idle time allowed for an executor before strategy could shut down unused blocks. Default is 120.0 seconds.
    usage_tracking : bool, optional
        Set this field to True to opt-in to Parsl's usage tracking system. Parsl only collects minimal, non personally-identifiable,
        information used for reporting to our funding agencies. Default is False.
    initialize_logging : bool, optional
        Make DFK optionally not initialize any logging. Log messages
        will still be passed into the python logging system under the
        ``parsl`` logger name, but the logging system will not by default
        perform any further log system configuration. Most noticeably,
        it will not create a parsl.log logfile.  The use case for this
        is when parsl is used as a library in a bigger system which
        wants to configure logging in a way that makes sense for that
        bigger system as a whole.
    NTé
   r   ÚruninfoÚsimpleç      ^@FÚ	task_exitÚperiodicÚdfk_exitÚmanual)Ú	executorsÚ	app_cacheÚcheckpoint_filesÚcheckpoint_modeÚcheckpoint_periodÚgarbage_collectÚinternal_tasks_max_threadsÚretriesÚretry_handlerÚrun_dirÚstrategyÚmax_idletimeÚ
monitoringÚusage_trackingÚinitialize_loggingÚreturnc                 C   s¼   |d krt ƒ g}|| _|| _|| _|| _|d k	rb|d krJt d |¡¡ n|dkrbt d |¡¡ |dkrv|d krvd}|| _|| _	|| _
|| _|	| _|
| _|| _|| _|| _|| _|| _d S )NzWThe requested `checkpoint_period={}` will have no effect because `checkpoint_mode=None`r   zTRequested checkpoint period of {} only has an effect with checkpoint_mode='periodic'z00:30:00)r
   r   r   r   r   ÚloggerÚdebugÚformatr   r   r   r   r   r    r!   r"   r$   r%   r#   )Úselfr   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   © r+   új/mounts/lovelace/software/anaconda3/envs/qiime2-shotgun-2023.9/lib/python3.8/site-packages/parsl/config.pyÚ__init__J   s8    ÿÿzConfig.__init__)r&   c                 C   s   | j S ©N)Ú
_executors)r*   r+   r+   r,   r   |   s    zConfig.executors)r   c                    sX   dd„ |D ƒ‰ ‡ fdd„t ˆ ƒD ƒ}t|ƒdkrNtd d dd„ |D ƒ¡¡ƒ‚|| _d S )Nc                 S   s   g | ]
}|j ‘qS r+   )Úlabel)Ú.0Úer+   r+   r,   Ú
<listcomp>‚   s     z$Config.executors.<locals>.<listcomp>c                    s$   g | ]\}}|ˆ d |… kr|‘qS r.   r+   )r1   Únr2   ©Úlabelsr+   r,   r3   ƒ   s      r   z&Executors must have unique labels ({})z, c                 S   s   g | ]}d   t|ƒ¡‘qS )zlabel={})r)   Úrepr)r1   Údr+   r+   r,   r3   †   s     )Ú	enumerateÚlenr   r)   Újoinr/   )r*   r   Ú
duplicatesr+   r5   r,   r   €   s    ÿ)NTNNNTr   r   Nr   r   r   NFT)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	typeguardÚtypecheckedr   r   r	   Úboolr   Ústrr   r   Úintr   Ú	Exceptionr   Úfloatr   r-   Úpropertyr   Úsetterr+   r+   r+   r,   r      sX   8               í

ü í1r   )ÚloggingrA   Útypingr   r   r   r   r   Útyping_extensionsr   Úparsl.utilsr   Úparsl.executors.baser	   Úparsl.executors.threadsr
   Úparsl.errorsr   Úparsl.dataflow.taskrecordr   Úparsl.monitoringr   Ú	getLoggerr=   r'   r   r+   r+   r+   r,   Ú<module>   s   
