o
    i                     @   s  d dl mZ d dlmZmZmZmZmZmZ zd dl	m
Z
mZmZmZmZ W n ey=   d dlm
Z
mZmZmZmZ Y nw d dlmZ dee
 deeef dee fdd	ZG d
d de
ZG dd de
ZG dd de
ZG dd de
ZG dd de
ZdS )    )defaultdict)AnyDictListOptionalTypeUnion)	BaseModelField	StrictStrValidationErrorroot_validator)msgschemaobjreturnc                 C   s   z
| di | g W S  t yJ } z4| }tt}|D ]}ddd |dg D }|| |d qdd | D W  Y d}~S d}~ww )	zValidate data against a given pydantic schema.

    obj (Dict[str, Any]): JSON-serializable data to validate.
    schema (pydantic.BaseModel): The schema to validate against.
    RETURNS (List[str]): A list of error messages, if available.
    z -> c                 S   s   g | ]}t |qS  )str).0pr   r   B/home/ubuntu/.local/lib/python3.10/site-packages/weasel/schemas.py
<listcomp>   s    zvalidate.<locals>.<listcomp>locr   c                 S   s&   g | ]\}}d | dd | qS )[z] z, )join)r   r   r   r   r   r   r      s   & Nr   )r   errorsr   listr   getappenditems)r   r   er   dataerrorerr_locr   r   r   validate   s   r$   c                   @   sJ   e Zd ZU edddZeed< edddZeed< edddZeed	< d
S )ProjectConfigAssetGitItem.z URL of Git repo to download fromtitlerepozAFile path or sub-directory to download (used for sparse checkout)pathmasterzBranch to clone frombranchN)	__name__
__module____qualname__r
   r(   r   __annotations__r)   r+   r   r   r   r   r%   "   s   
 r%   c                   @   sh   e Zd ZU edddZeed< edddZee ed< eddd	d
Z	ee
 ed< edddZeed< dS )ProjectConfigAssetURL.zDestination of downloaded assetr&   destNzURL of asseturlMD5 hash of file([a-fA-F\d]{32})r'   regexchecksum Description of assetdescription)r,   r-   r.   r
   r1   r   r/   r2   r   r7   r   r:   r   r   r   r   r0   *   s
   
 r0   c                   @   sT   e Zd ZU edddZeed< eddddZee	 ed	< edd
dZ
ee ed< dS )ProjectConfigAssetGit.zGit repo informationr&   gitNr3   r4   r5   r7   r9   r:   )r,   r-   r.   r
   r<   r%   r/   r7   r   r   r:   r   r   r   r   r   r;   3   s   
 r;   c                   @   s   e Zd ZU edddZeed< edddZee ed< eg ddZ	e
e ed	< eg d
dZe
e ed< eg ddZe
e ed< eg ddZe
e ed< edddZeed< G dd dZdS )ProjectConfigCommand.zName of commandr&   nameNzCommand descriptionhelpz%List of CLI commands to run, in orderscriptz*File dependencies required by this commanddepsz Outputs produced by this commandoutputsz%Outputs not tracked by DVC (DVC only)outputs_no_cacheFz0Never skip this command, even if nothing changedno_skipc                   @   s   e Zd ZdZdZdS )zProjectConfigCommand.Configz4A single named command specified in a project configforbidN)r,   r-   r.   r'   extrar   r   r   r   ConfigF   s    rG   )r,   r-   r.   r
   r>   r   r/   r?   r   r@   r   rA   rB   rC   rD   boolrG   r   r   r   r   r=   ;   s   
 r=   c                   @   s   e Zd ZU ei ddZeeef ed< ei ddZ	eeef ed< eg ddZ
eeeef  ed< ei ddZeeee f ed	< eg d
dZee ed< edddZee ed< G dd dZedddeeef deeef fddZdS )ProjectConfigSchemaz,Optional variables to substitute in commandsr&   varszWOptional variable names to substitute in commands, mapped to environment variable namesenvzData assetsassetszCNamed workflows, mapped to list of project commands to run in order	workflowszProject command shortuctscommandsNzProject titler'   c                   @   s   e Zd ZdZdS )zProjectConfigSchema.Configz%Schema for project configuration fileN)r,   r-   r.   r'   r   r   r   r   rG   U   s    rG   T)prer   r   c                 C   s(   d|v r	t d d|v rt d |S )Nspacy_versionzYour project configuration file includes a `spacy_version` key, which is now deprecated. Weasel will not validate your version of spaCy.check_requirementszYour project configuration file includes a `check_requirements` key, which is now deprecated. Weasel will not validate your requirements.)r   warn)clsr   r   r   r   check_legacy_keysX   s   z%ProjectConfigSchema.check_legacy_keys)r,   r-   r.   r
   rJ   r   r   r   r/   rK   rL   r   r   r0   r;   rM   rN   r=   r'   r   r   rG   r   rT   r   r   r   r   rI   K   s   
   (rI   N)collectionsr   typingr   r   r   r   r   r   pydantic.v1r	   r
   r   r   r   ImportErrorpydanticwasabir   r   r$   r%   r0   r;   r=   rI   r   r   r   r   <module>   s       &	