U
    ne                     @   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Iterable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ddddZdS )ConfigaZ  
    Specification of Parsl configuration options.

    Parameters
    ----------
    executors : sequence of ParslExecutor, optional
        List (or other iterable) 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   t |pg }|st f}|| _|   || _|| _|| _|d k	rr|d krZtd	| n|dkrrtd	| |dkr|d krd}|| _
|| _|| _|| _|	| _|
| _|| _|| _|| _|| _|| _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)tupler
   
_executors_validate_executorsr   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-2024.2/lib/python3.8/site-packages/parsl/config.py__init__J   s<    zConfig.__init__)r&   c                 C   s   | j S N)r(   )r-   r.   r.   r/   r      s    zConfig.executorsc                    sj   t | jdkrtddd | jD   fddt D }t |dkrftdddd |D d S )	Nr   z'At least one executor must be specifiedc                 S   s   g | ]
}|j qS r.   )label).0er.   r.   r/   
<listcomp>   s     z.Config._validate_executors.<locals>.<listcomp>c                    s$   g | ]\}}| d | kr|qS r1   r.   )r3   nr4   labelsr.   r/   r5      s      z&Executors must have unique labels ({})z, c                 S   s   g | ]}d  t|qS )zlabel={})r,   repr)r3   dr.   r.   r/   r5      s     )lenr   r   	enumerater,   join)r-   
duplicatesr.   r7   r/   r)      s    zConfig._validate_executors)NTNNNTr   r   Nr   r   r   NFT)__name__
__module____qualname____doc__	typeguardtypecheckedr   r   r	   boolr   strr   r   intr   	Exceptionr   floatr   r0   propertyr   r)   r.   r.   r.   r/   r      sV   8               

 6r   )loggingrC   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   
