o
    ̳i-                     @   s`   d dl Z d dl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 G dd de	ZdS )	    N)Path)	OmegaConf)config)
Subcommand)ConfigErrorc                       sB   e Zd ZdZdejf fddZdddZd	ejfd
dZ	  Z
S )Validatez7Holds all the logic for the `tune validate` subcommand.
subparsersc              	      sH   t    |jdddddtdtjd| _|   | jj	| j
d d S )Nvalidateztune validatez4Validate a config and ensure that it is well-formed.ztune validate <config>z                examples:

                    $ tune validate recipes/configs/full_finetune_distributed.yaml
                    Config is well-formed!
                )proghelpdescriptionusageepilogformatter_class)func)super__init__
add_parsertextwrapdedentargparseRawTextHelpFormatter_parser_add_argumentsset_defaults_validate_cmd)selfr   	__class__ K/home/ubuntu/.local/lib/python3.10/site-packages/torchtune/_cli/validate.pyr      s   
zValidate.__init__returnNc                 C   s   | j jdtdd dS )zAdd arguments to the parser.r   zPath to a config to validate.)typer   N)r   add_argumentr   )r   r   r   r    r   *   s
   
zValidate._add_argumentsargsc              
   C   s\   t |j}zt| W n ty' } z| jt| W Y d}~nd}~ww td dS )zValidate a config file.NzConfig is well-formed!)	r   loadr   r	   r   r   errorstrprint)r   r$   cfger   r   r    r   2   s   zValidate._validate_cmd)r!   N)__name__
__module____qualname____doc__r   _SubParsersActionr   r   	Namespacer   __classcell__r   r   r   r    r      s
    
r   )r   r   pathlibr   	omegaconfr   	torchtuner   torchtune._cli.subcommandr   torchtune.config._errorsr   r   r   r   r   r    <module>   s   