Ë
    (täi,  ã                   ó
  — d Z ddlZddlmZmZ ddlZddlmZmZ ddl	m
Z
mZmZmZmZmZ ddlmZmZ  ee«      Z ej(                  deD � ci c]  } | | “Œ c} e¬	«      Z ee«      Z ej(                  d
eD �ci c]  }||“Œ c}e¬	«      Z ed¬«      Zej5                  dg d¢¬«      ddddej6                  dfdeedz   ej8                  d¬«      f   deedz   ej8                  d¬«      f   deedz   ej8                  d¬«      f   dede
deddfd„«       Zej5                  ddg¬«      ej6                  dfdee ej<                  d¬«      f   de
deddfd „«       Zej5                  d!g d"¢¬«      ddd#d#ej6                  dfd$ee ej<                  d%¬«      f   d&eedz   ej8                  d'¬«      f   d(eedz   ej8                  d)¬«      f   d*ee  ej8                  d+¬«      f   d,ee  ej8                  d-¬«      f   de
deddfd.„«       Z!ej5                  d/g d0¢¬«      dddddej6                  dfdee ej<                  d¬«      f   d$eedz   ej8                  d1¬«      f   d(eedz   ej8                  d2¬«      f   d3ee"dz   ej8                  d4¬«      f   d*ee dz   ej8                  d5¬«      f   d6eedz   ej8                  d7¬«      f   de
deddfd8„«       Z#ej5                  d9d:d;g¬«      d#ej6                  dfdee ej<                  d¬«      f   d<ee  ej8                  d=¬«      f   de
deddf
d>„«       Z$ej5                  d?g d@¢¬«      dd#ej6                  dfdee ej<                  d¬«      f   dAee ej<                  dB¬«      f   dCee ej<                  dD¬«      f   dEeedz   ej8                  dF¬«      f   d,ee  ej8                  dG¬«      f   de
deddfdH„«       Z%ej5                  dIdJdKg¬«      ddej6                  dfdee ej<                  d¬«      f   dLee ej<                  dM¬«      f   dEeedz   ej8                  dN¬«      f   d3ee"dz   ej8                  dO¬«      f   de
deddfdP„«       Z&ej5                  dQ«      d#ej6                  dfdee ej<                  d¬«      f   dLee ej<                  dR¬«      f   d<ee  ej8                  dS¬«      f   de
deddfdT„«       Z'yc c} w c c}w )Ua_  Contains commands to interact with collections on the Hugging Face Hub.

Usage:
    # list collections on the Hub
    hf collections ls

    # list collections for a specific user
    hf collections ls --owner username

    # get info about a collection
    hf collections info username/collection-slug

    # create a new collection
    hf collections create "My Collection" --description "A collection of models"

    # add an item to a collection
    hf collections add-item username/collection-slug username/model-name model

    # delete a collection
    hf collections delete username/collection-slug
é    N)Ú	AnnotatedÚget_args)ÚCollectionItemType_TÚCollectionSort_Té   )ÚFormatWithAutoOptÚLimitOptÚTokenOptÚapi_object_to_dictÚ
get_hf_apiÚtyper_factory)ÚOutputFormatWithAutoÚoutÚCollectionItemType)ÚtypeÚCollectionSortz%Interact with collections on the Hub.)Úhelpz	list | ls)zhf collections lsz hf collections ls --owner nvidiazLhf collections ls --item models/teknium/OpenHermes-2.5-Mistral-7B --limit 10)Úexamplesé
   Úownerz)Filter by owner username or organization.ÚitemzkFilter collections containing a specific item (e.g., "models/gpt2", "datasets/squad", "papers/2311.12983").Úsortz4Sort results by last modified, trending, or upvotes.ÚlimitÚformatÚtokenÚreturnc                 óÆ   — t        |¬«      }|r|j                  nd}|j                  | |||¬«      D �cg c]  }t        |«      ‘Œ }	}t	        j
                  |	«       yc c}w )zList collections on the Hub.©r   N)r   r   r   r   )r   ÚvalueÚlist_collectionsr   r   Útable)
r   r   r   r   r   r   ÚapiÚsort_keyÚ
collectionÚresultss
             ún/Volumes/fast/ai/experiments/MLX_z-image/.venv/lib/python3.12/site-packages/huggingface_hub/cli/collections.pyÚcollections_lsr'   :   su   € ô8 ˜5Ô
!€CÙ!ˆt�zŠz t€Hð ×.Ñ.ØØØØð	 /ô 
óñ
ˆJô 	˜:Õ&ð
ð ð ô ‡I�IˆgÕùòs   ´AÚinfoz/hf collections info username/my-collection-slugÚcollection_slugz7The collection slug (e.g., 'username/collection-slug').c                 óh   — t        |¬«      }|j                  | «      }t        j                  |«       y)z'Get info about a collection on the Hub.r   N)r   Úget_collectionr   Údict)r)   r   r   r"   r$   s        r&   Úcollections_infor-   d   s*   € ô ˜5Ô
!€CØ×#Ñ# OÓ4€JÜ‡H�HˆZÕó    Úcreate)z!hf collections create "My Models"z^hf collections create "My Models" --description "A collection of my favorite models" --privatez9hf collections create "Org Collection" --namespace my-orgFÚtitlezThe title of the collection.Ú	namespacezMThe namespace (username or organization). Defaults to the authenticated user.Údescriptionz!A description for the collection.ÚprivatezCreate a private collection.Ú	exists_okz7Do not raise an error if the collection already exists.c                 ó    — t        |¬«      }|j                  | ||||¬«      }t        j                  d|j                  |j
                  ¬«       y)z#Create a new collection on the Hub.r   )r0   r1   r2   r3   r4   zCollection created©ÚslugÚurlN)r   Úcreate_collectionr   Úresultr7   r8   )	r0   r1   r2   r3   r4   r   r   r"   r$   s	            r&   Úcollections_creater;   u   sM   € ô< ˜5Ô
!€CØ×&Ñ&ØØØØØð 'ó €Jô ‡J�JÐ#¨*¯/©/¸z¿~¹~ÖNr.   Úupdate)z@hf collections update username/my-collection --title "New Title"zPhf collections update username/my-collection --description "Updated description"zDhf collections update username/my-collection --private --theme greenz!The new title for the collection.z'The new description for the collection.Úpositionz7The new position of the collection in the owner's list.z)Whether the collection should be private.Úthemez;The theme color for the collection (e.g., 'green', 'blue').c                 ó¢   — t        |¬«      }|j                  | |||||¬«      }	t        j                  d|	j                  |	j
                  ¬«       y)z*Update a collection's metadata on the Hub.r   )r)   r0   r2   r=   r3   r>   zCollection updatedr6   N)r   Úupdate_collection_metadatar   r:   r7   r8   )
r)   r0   r2   r=   r3   r>   r   r   r"   r$   s
             r&   Úcollections_updaterA   ž   sQ   € ôD ˜5Ô
!€CØ×/Ñ/Ø'ØØØØØð 0ó €Jô ‡J�JÐ#¨*¯/©/¸z¿~¹~ÖNr.   Údeletez,hf collections delete username/my-collectionz9hf collections delete username/my-collection --missing-okÚ
missing_okz6Do not raise an error if the collection doesn't exist.c                 óp   — t        |¬«      }|j                  | |¬«       t        j                  d| ¬«       y)z!Delete a collection from the Hub.r   )rC   zCollection deleted©r7   N)r   Údelete_collectionr   r:   )r)   rC   r   r   r"   s        r&   Úcollections_deleterG   Ì   s0   € ô" ˜5Ô
!€CØ×Ñ˜/°jÐÔAÜ‡J�JÐ#¨/Ö:r.   zadd-item)zGhf collections add-item username/my-collection moonshotai/kimi-k2 modelz`hf collections add-item username/my-collection Qwen/DeepPlanning dataset --note "Useful dataset"zGhf collections add-item username/my-collection Tongyi-MAI/Z-Image spaceÚitem_idzCThe ID of the item to add (repo_id for repos, paper ID for papers).Ú	item_typezGThe type of item (model, dataset, space, paper, collection, or bucket).Únotez2A note to attach to the item (max 500 characters).z?Do not raise an error if the item is already in the collection.c                 ó    — t        |¬«      }|j                  | ||j                  ||¬«      }t        j                  d| |j
                  ¬«       y)zAdd an item to a collection.r   )r)   rH   rI   rJ   r4   zItem added to collectionr6   N)r   Úadd_collection_itemr   r   r:   r8   )	r)   rH   rI   rJ   r4   r   r   r"   r$   s	            r&   Úcollections_add_itemrM   â   sM   € ô: ˜5Ô
!€CØ×(Ñ(Ø'ØØ—/‘/ØØð )ó €Jô ‡J�JÐ)°ÀZÇ^Á^ÖTr.   zupdate-itemzVhf collections update-item username/my-collection ITEM_OBJECT_ID --note "Updated note"zMhf collections update-item username/my-collection ITEM_OBJECT_ID --position 0Úitem_object_idzTThe ID of the item in the collection (from 'item_object_id' field, not the repo_id).z-A new note for the item (max 500 characters).z/The new position of the item in the collection.c                 ót   — t        |¬«      }|j                  | |||¬«       t        j                  d| ¬«       y)zUpdate an item in a collection.r   )r)   rN   rJ   r=   zItem updated in collectionrE   N)r   Úupdate_collection_itemr   r:   )r)   rN   rJ   r=   r   r   r"   s          r&   Úcollections_update_itemrQ   
  s>   € ô2 ˜5Ô
!€CØ×ÑØ'Ø%ØØð	 ô ô ‡J�JÐ+°/ÖBr.   zdelete-itemznThe ID of the item in the collection (retrieved from `item_object_id` field returned by 'hf collections info'.z0Do not raise an error if the item doesn't exist.c                 ór   — t        |¬«      }|j                  | ||¬«       t        j                  d| ¬«       y)z!Delete an item from a collection.r   )r)   rN   rC   zItem deleted from collectionrE   N)r   Údelete_collection_itemr   r:   )r)   rN   rC   r   r   r"   s         r&   Úcollections_delete_itemrT   -  s;   € ô" ˜5Ô
!€CØ×ÑØ'Ø%Øð ô ô
 ‡J�JÐ-°OÖDr.   )(Ú__doc__ÚenumÚtypingr   r   ÚtyperÚhuggingface_hub.hf_apir   r   Ú
_cli_utilsr   r	   r
   r   r   r   Ú_outputr   r   Ú_COLLECTION_ITEM_TYPESÚEnumÚstrr   Ú_COLLECTION_SORT_OPTIONSr   Úcollections_cliÚcommandÚautoÚOptionr'   ÚArgumentr-   Úboolr;   ÚintrA   rG   rM   rQ   rT   )ÚtÚss   00r&   Ú<module>ri      sN  ðñó, ß &ã ç Iç l× lß .ñ "Ð"6Ó7Ð Ø�T—Y‘YÐ3ÑDZÓ5[ÑDZ¸q°a¸±dÐDZÑ5[ÐbeÔfÐ á#Ð$4Ó5Ð Ø�—‘Ð+Ñ<TÓ-UÑ<T°q¨a°©dÐ<TÑ-UÐ\_Ô`€ñ  Ð%LÔM€ð ×ÑØòð ó ð 	ð 	ð 	ØØ 4× 9Ñ 9Øñ#ØØˆd‰
Øˆ�‰ÐEÔFð	Hñðð
 Øˆd‰
Øˆ�‰Ø~ô	
ð	ñðð Ø˜ÑØˆ�‰ÐPÔQð	Sñðð ðð  ð!ð" ð#ð$ 
ò%óððD ×ÑØ
à9ðð ó ð !5× 9Ñ 9ØñØ˜s N E§N¡NÐ8qÔ$rÐrÑsðàðð ðð 
ò	óðð ×ÑØòð ó ð 	ð 	ð 	ð 	Ø 4× 9Ñ 9Øñ'OØ�S˜.˜%Ÿ.™.Ð.LÔMÐMÑNðOàØˆd‰
Øˆ�‰ÐiÔjð	lñðOð Øˆd‰
Øˆ�‰Ð=Ô>ð	@ñðOð ØØˆ�‰Ð8Ô9ð	;ñðOð ØØˆ�‰ÐSÔTð	VñðOð$ ð%Oð& ð'Oð( 
ò)OóðOðB ×ÑØòð ó ð 	ð 	ð 	ð 	ð 	Ø 4× 9Ñ 9Øñ/#OØ˜s N E§N¡NÐ8qÔ$rÐrÑsð#OàØˆd‰
Øˆ�‰Ð=Ô>ð	@ñð#Oð Øˆd‰
Øˆ�‰ÐCÔDð	Fñð#Oð Øˆd‰
Øˆ�‰ÐSÔTð	Vñð#Oð Øˆt‰Øˆ�‰ÐEÔFð	Hñð#Oð$ Øˆd‰
Øˆ�‰ÐWÔXð	Zñð%#Oð, ð-#Oð. ð/#Oð0 
ò1#Oóð#OðL ×ÑØà6ØCðð ó ð 	Ø 4× 9Ñ 9Øñ;Ø˜s N E§N¡NÐ8qÔ$rÐrÑsð;àØØˆ�‰ÐRÔSð	Uñð;ð ð;ð ð;ð 
ò;óð;ð ×ÑØòð ó ð( 	ð 	Ø 4× 9Ñ 9Øñ%UØ˜s N E§N¡NÐ8qÔ$rÐrÑsðUàØˆ^ˆU�^‰^Ð!fÔgÐgñðUð
 ØØˆ�‰ÐeÔfð	hñðUð Øˆd‰
Øˆ�‰ÐNÔOð	QñðUð ØØˆ�‰Ð[Ô\ð	^ñðUð" ð#Uð$ ð%Uð& 
ò'UóðUð@ ×ÑØà`ØWðð ó ð  	ð 	Ø 4× 9Ñ 9ØñCØ˜s N E§N¡NÐ8qÔ$rÐrÑsðCàØØˆ�‰ÐrÔsð	uñðCð Øˆd‰
Øˆ�‰ÐIÔJð	LñðCð Øˆd‰
Øˆ�‰ÐKÔLð	NñðCð ðCð ðCð  
ò!CóðCð8 ×Ñ˜Ó'ð 	Ø 4× 9Ñ 9ØñEØ˜s N E§N¡NÐ8qÔ$rÐrÑsðEàØØˆ�‰ð Bô	
ð	ñðEð ØØˆ�‰ÐLÔMð	OñðEð ðEð ðEð 
òEó (ñEùò{ 6\ùò .Vs   Á
S<
Á8
T
