
    Zi                         d Z ddlZddlZddlmZmZmZ ddlZddlm	Z	m
Z
mZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ  e ee                    Z ee          Z  ej!        dd	 e D             e"
          Z#eee"          ej$        dd%                    e           d ee                    f         Z& ed          Z'e'(                    dg d          ddddddej)        ddf	dedededeee#          ej$        d          f         dede&dededed dfd!            Z*e'(                    d"d#d$g          	 	 	 d)d%ee" ej+        d&          f         d'ede&ded df
d(            Z,dS )*a  Contains commands to interact with datasets on the Hugging Face Hub.

Usage:
    # list datasets on the Hub
    hf datasets ls

    # list datasets with a search query
    hf datasets ls --search "code"

    # get info about a dataset
    hf datasets info HuggingFaceFW/fineweb
    N)	AnnotatedOptionalget_args)CLIErrorRepositoryNotFoundErrorRevisionNotFoundError)DatasetSort_TExpandDatasetProperty_T   )	AuthorOpt	FilterOpt	FormatOptLimitOptOutputFormatQuietOptRevisionOpt	SearchOptTokenOptapi_object_to_dict
get_hf_apimake_expand_properties_parserprint_list_outputtyper_factoryDatasetSortEnumc                     i | ]}||S  r   ).0ss     W/root/projects/butler/venv/lib/python3.11/site-packages/huggingface_hub/cli/datasets.py
<dictcomp>r    8   s    /L/L/L1/L/L/L    )typezWComma-separated properties to expand. Example: '--expand=downloads,likes,tags'. Valid: z, .)helpcallbackz"Interact with datasets on the Hub.)r$   ls)zhf datasets lsz*hf datasets ls --sort downloads --limit 10zhf datasets ls --search "code")examples
   FsearchauthorfiltersortzSort results.limitexpandformatquiettokenreturnc	           	          t          |          }	|r|j        nd}
d |	                    ||| |
||          D             }t          |||           dS )zList datasets on the Hub.r1   Nc                 ,    g | ]}t          |          S r   )r   )r   dataset_infos     r   
<listcomp>zdatasets_ls.<locals>.<listcomp>`   s0        	<((  r!   )r+   r*   r)   r,   r-   r.   )r/   r0   )r   valuelist_datasetsr   )r)   r*   r+   r,   r-   r.   r/   r0   r1   apisort_keyresultss               r   datasets_lsr=   G   s    . 5
!
!
!C!+tzztH --&he\b . 
 
  G gfE::::::r!   infoz&hf datasets info HuggingFaceFW/finewebz9hf datasets info my-dataset --expand downloads,likes,tags
dataset_idz+The dataset ID (e.g. `username/repo-name`).revisionc                 N   t          |          }	 |                    | ||          }nJ# t          $ r}t          d|  d          |d}~wt          $ r}t          d| d|  d          |d}~ww xY wt          t          j        t          |          d	
                     dS )z$Get info about a dataset on the Hub.r4   )repo_idr@   r.   z	Dataset 'z' not found.Nz
Revision 'z' not found on 'z'.   )indent)	r   r6   r   r   r   printjsondumpsr   )r?   r@   r.   r1   r:   r>   es          r   datasets_inforI   i   s     5
!
!
!CU
XfUU" D D D;:;;;<<!C  U U ULHLLjLLLMMSTTU	$*'--a
8
8
899999s    + 
A2A		A2A--A2)NNN)-__doc__enumrF   typingr   r   r   typerhuggingface_hub.errorsr   r   r   huggingface_hub.hf_apir	   r
   
_cli_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   sorted_EXPAND_PROPERTIES_SORT_OPTIONSEnumstrr   Optionjoin	ExpandOptdatasets_clicommandtabler=   ArgumentrI   r   r!   r   <module>r]      s      0 0 0 0 0 0 0 0 0 0  [ [ [ [ [ [ [ [ [ [ I I I I I I I I                               $ VHH%<==>> ''$)-/L/Lm/L/L/LSVWWW SMEL Hgkgpgp  rD  hE  hE  H  H  H../ABB  	 }"FGGG        	$*; ;;; ; !/***	,	; ; ; ; ; ; 
; ; ; ;4 
0C    !	: :#~u~3`aaaab:: : 	:
 
: : : : : :r!   