
    ujj8                     X   d dl Z d dlmZ d dlmZmZmZmZmZ d dl	m
Z
 deeeeef                           ded         fdZe G d	 d
                      Ze G d d                      Ze G d d                      Ze G d d                      Ze G d d                      ZdS )    N)	dataclass)AnyDictListLiteralOptional)convert_timestampsiblings_datareturnRepoSiblingc                 "    | sg S d | D             S )a"  
    Parse siblings data into RepoSibling objects.

    Args:
        siblings_data: Raw siblings data from API response, supporting both
                      uppercase (Path, Size, etc.) and lowercase (path, size, etc.) field names.

    Returns:
        List of RepoSibling objects.
    c                    g | ]u}t          |                    d           p|                    d          |                    d          p|                    d          |                    d          p|                    d          |                    d          p|                    d          |                    d          p|                    d	          t          |                    d
          p|                    d                    t          |                    d          p|                    d          |                    d          p|                    d                              wS )PathpathSizesizeSha256sha256TypetypeRevisionrevisionCommittedDatecommittedDate)r   r   )	rfilenamer   blob_idr   shalast_modifiedlfs)r   getr	   BlobLfsInfo).0siblings     c/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/modelscope/hub/info.py
<listcomp>z#_parse_siblings.<locals>.<listcomp>   sT        	kk&))@W[[-@-@V$$;F(;(;KK))BW[[-B-BV$$;F(;(;J''B7;;z+B+B+GKK,H,H,hGKKXgLhLhii[[((?GKK,?,?{{8,,EH0E0E  	
 	
 	
       )r
   s    r$   _parse_siblingsr(      s4      	  '   r&   c                   
   e Zd ZU dZee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed	<   eej                 ed
<   eej                 ed<   d Z	dS )OrganizationInfoz*Organization information for a repository.idname	full_namedescriptionavatargithub_addressr   emailcreated_timemodified_timec                    |                     dd           | _        |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     d|                     d	d                     | _        |                     d
|                     dd                    | _        |                     d|                     dd                     }|rt          |          nd | _
        |                     d|                     dd                     }|rt          |          nd | _        d S )NIdName FullNameDescriptionAvatarGithubAddressr   r   Emailr1   
GmtCreatedr2   GmtModifiedr3   )popr+   r,   r-   r.   r/   r0   r   r1   r	   r2   r3   )selfkwargsr2   r3   s       r$   __init__zOrganizationInfo.__init__8   sH   **T4((JJvr**	J33!::mR88jj2..$jj"==JJvvzz&$'?'?@@	ZZGR)@)@AA
zz,

>40P0PQQ?KU-l;;;QU

=&**_d2S2STTANX.}===TXr&   N)
__name__
__module____qualname____doc__r   int__annotations__strdatetimerB   r'   r&   r$   r*   r*   *   s         44
3-}#SMSM!!!
3-C=8,----H-....Y Y Y Y Yr&   r*   c                   D    e Zd ZU dZee         ed<   dZee         ed<   dS )r!   Nr   r   )	rC   rD   rE   r   r   rG   rH   r   rI   r'   r&   r$   r!   r!   G   s:         D(3- FHSM     r&   r!   c                       e Zd ZU dZeed<   dZee         ed<   dZ	ee         ed<   dZ
ee         ed<   dZee         ed<   dZeej                 ed<   dZee         ed	<   dS )
r   a  
    Contains basic information about a repo file inside a repo on the Hub.

    Attributes:
        rfilename (str): file name, relative to the repo root.
        size (`int`, *optional*): The file's size, in bytes.
        blob_id (`str`, *optional*): The file's git OID.
        lfs (`BlobLfsInfo`, *optional*): The file's LFS metadata.
        type (`str`, *optional*): The file's type.
        sha (`str`, *optional*): The file's latest commit SHA.
        last_modified (`datetime`, *optional*): The file's last modified time.
    r   Nr   r   r   r   r   r   )rC   rD   rE   rF   rI   rH   r   r   rG   r   r   r   r   rJ   r   r!   r'   r&   r$   r   r   M   s           NNND(3-!GXc]!!!D(3-C#15M8H-.555!%C+	%%%%%r&   c                      e Zd ZU dZee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed	<   ee         ed
<   ee         ed<   ee         ed<   ee         ed<   ee	j	                 ed<   ee	j	                 ed<   ee
e                  ed<   ee
e                  ed<   ee
eeef                           ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   eeeef                  ed<   ee
e                  ed<   ee
e                  ed<   ee         ed<   ee         ed<   ee
e                  ed<   ee
e                  ed <   eeeef                  ed!<   ee         ed"<   ee	j	                 ed#<   d$ Zd%S )&	ModelInfoae	  
    Contains detailed information about a model on ModelScope Hub. This object is returned by [`model_info`].

    Attributes:
        id (`int`, *optional*): Model ID.
        name (`str`, *optional*): Model name.
        author (`str`, *optional*): Model author.
        chinese_name (`str`, *optional*): Chinese display name.
        visibility (`int`, *optional*): Visibility level (1=private, 5=public).
        is_published (`int`, *optional*): Whether the model is published.
        is_online (`int`, *optional*): Whether the model is online.
        already_star (`bool`, *optional*): Whether current user has starred this model.
        description (`str`, *optional*): Model description.
        license (`str`, *optional*): Model license.
        downloads (`int`, *optional*): Number of downloads.
        likes (`int`, *optional*): Number of likes.
        created_at (`datetime`, *optional*): Date of creation of the repo on the Hub.
        last_updated_time (`datetime`, *optional*): Last update timestamp.
        architectures (`List[str]`, *optional*): Model architectures.
        model_type (`List[str]`, *optional*): Model types.
        tasks (`List[Dict[str, Any]]`, *optional*): Supported tasks.
        readme_content (`str`, *optional*): README content.
        organization (`OrganizationInfo`, *optional*): Organization information.
        created_by (`str`, *optional*): Creator username.
        is_certification (`int`, *optional*): Certification status.
        approval_mode (`int`, *optional*): Approval mode.
        card_ready (`int`, *optional*): Whether model card is ready.
        backend_support (`str`, *optional*): Backend support information.
        model_infos (`Dict[str, Any]`, *optional*): Detailed model configuration information.
        tags (`List[str]`, *optional*): Model Tags.
        is_accessible (`int`, *optional*): Whether accessible.
        revision (`str`, *optional*): Revision/branch.
        related_arxiv_id (`List[str]`, *optional*): Related arXiv paper IDs.
        related_paper (`List[int]`, *optional*): Related papers.
        sha (`str`, *optional*): Latest commit SHA.
        last_modified (`datetime`, *optional*): Latest commit date.
        last_commit (`Dict[str, Any]`, *optional*): Latest commit information.
        siblings (List[RepoSibling], optional): Basic information about files that constitute the model.
    r+   r,   authorchinese_name
visibilityis_published	is_onlinealready_starr.   license	downloadslikes
created_atlast_updated_timearchitectures
model_typetasksreadme_contentorganization
created_byis_certificationapproval_mode
card_readybackend_supportmodel_infossiblingstagsis_accessibler   related_arxiv_idrelated_paperlast_commitr   r   c                 	   |                     dd           | _        |                     dd          | _        |                     dd          | _        |                     dd           | _        |                     dd           | _        |                     dd           | _        |                     dd           | _        |                     d	d          | _        |                     d
d          | _	        |                     dd           | _
        |                     dd           p|                     dd           | _        |                     dd           }|rt          |          nd | _        |                     dd           }|rt          |          nd | _        |                     dg           | _        |                     dg           | _        |                     dg           | _        |                     dd          | _        |                     dd           }|rt'          d*i |nd | _        |                     dd           | _        |                     dd           | _        |                     dd           | _        |                     dd           | _        |                     dd          | _        |                     di           | _        |                     dg           | _        |                     dd           | _        |                     dd          | _        |                     dg           | _        |                     d g           | _        |                     d!d           p|                     d"d           }|rtA          |d!          r|j!        r|j!        d#         }tA          |d$          r|"                                nd | _#        | j#        r| j#        $                    d%          nd | _%        | j#        r't          | j#        $                    d&                    nd | _&        nd | _#        d | _%        d | _&        |                     d'd          | _'        |                     d(d           p|                     d)d           }tQ          |          | _)        | j*        +                    |           d S )+Nr5   r6   r7   ChineseName
VisibilityIsPublishedIsOnlineAlreadyStarr9   License	DownloadsStarsLikesCreatedTimeLastUpdatedTimeArchitectures	ModelTypeTasksReadMeContentOrganization	CreatedByIsCertificationApprovalMode	CardReadyBackendSupportz{}
ModelInfosTagsIsAccessibler   RelatedArxivIdRelatedPapercommitsCommitsr   to_dictr+   committed_daterO   re   Siblingsr'   ),r?   r+   r,   rP   rQ   rR   rS   rT   r.   rU   rV   rW   r	   rX   rY   rZ   r[   r\   r]   r*   r^   r_   r`   ra   rb   rc   rd   rf   rg   r   rh   ri   hasattrr   r   rj   r    r   r   rO   r(   re   __dict__updater@   rA   r2   rY   org_datar   rj   re   s           r$   rB   zModelInfo.__init__   s/   **T4((JJvr**	"JJ}b99 **\488"JJ}d;;J55"JJ}d;;!::mR88zz)R00K66ZZ..K&**Wd2K2K
zz-66=IS+L999t"JJ'8$??IZ!d!23D!E!E!E`d#ZZ<< **["55ZZ,,
$jj"==::nd33<DN,88x888$ **[$77 &

+<d C C#ZZ== **[$77%zz*:DAA!::lB77JJvr**	#ZZ==

:r22 &

+;R @ @#ZZ;;**Y--LIt1L1L 	&ww	22 	&w 	&!/!,K8?Y8W8Wa{22444]aD595EOt'++D1114DH^b^n!x!243C3G3GHX3Y3Y!Z!Z!ZtxD#DDH!%Djj2..::j$//O6::j$3O3O'11 	V$$$$$r&   N)rC   rD   rE   rF   r   rG   rH   rI   boolrJ   r   r   r   r*   r   rB   r'   r&   r$   rN   rN   e   s        & &P 	
3-SM3-3-}4.   #c]}C=*++++ 12222DI&&&&c####Dc3h())))SM!!!+,,,, sm###C=    c]"""$sCx.))))tK()))) 49
 C=    sm tCy))))DI&&&& $sCx.))))	#H-....2% 2% 2% 2% 2%r&   rN   c                   4   e Zd ZU dZee         ed<   ee         ed<   ee         ed<   ee         ed<   eed                  ed<   ee	         ed<   ee         ed	<   ee         ed
<   ee         ed<   ee         ed<   ee
j
                 ed<   ee
j
                 ed<   ee         ed<   ee         ed<   ee         ed<   eeeeef                           ed<   eeeef                  ed<   ee         ed<   ee
j
                 ed<   eee                  ed<   d ZdS )DatasetInfoa  
    Contains detailed information about a dataset on ModelScope Hub. This object is returned by [`dataset_info`].

    Attributes:
        id (`int`, *optional*)): Dataset ID.
        name (`str`, *optional*)): Dataset name.
        author (`str`, *optional*): Dataset owner (user or organization).
        chinese_name (`str`, *optional*): Chinese display name.
        visibility (`int`, *optional*)): Visibility level (1=private, 3=interal, 5=public).
        'internal' means visible to logged-in users only.
        already_star (`bool`, *optional*)): Whether current user has starred this dataset.
        description (`str`, *optional*): Dataset description.
        license (`str`, *optional*)): Dataset license.
        downloads (`int`, *optional*)): Number of downloads.
        likes (`int`, *optional*)): Number of likes.
        created_at (`int`, *optional*): Creation timestamp.
        last_updated_time (`int`, *optional*): Last update timestamp.
        readme_content (`str`, *optional*): README content.
        organization (`OrganizationInfo`, *optional*): Organization information.
        created_by (`str`, *optional*): Creator username.
        tags (`List[Dict[str, Any]]`): Dataset tags.
        last_commit (`Dict[str, Any]`, *optional*): Latest commit information.
        sha (`str`, *optional*): Latest commit SHA.
        last_modified (`datetime`, *optional*): Latest commit date.
        siblings (`List[RepoSibling]`, *optional*): Basic information about files in the dataset.
    r+   r,   rO   rP   )         rQ   rT   r.   rU   rV   rW   rX   rY   r]   r^   r_   rf   rj   r   r   re   c                    |                     dd           | _        |                     dd          | _        |                     d|                     dd           p|                     dd                     | _        |                     dd          | _        |                     dd           | _        |                     d	d           | _        |                     d
d          | _        |                     dd           p|                     dd           | _        |                     dd          | _	        |                     dd           | _
        |                     dd           }|rt          |          nd | _        |                     dd           }|rt          |          nd | _        |                     dd          | _        |                     dd           }|rt          di |nd | _        |                     dd           | _        |                     dg           | _        |                     dd           p|                     dd           }|rt'          |d          r|j        r|j        d         }t'          |d          r|                                nd | _        | j        r| j                            d          nd | _        | j        r't          | j                            d                    nd | _        nd | _        d | _        d | _        |                     dd           p|                     dd           }t5          |          | _        | j                            |           d S )Nr5   r6   r7   rO   Owner	Namespacerl   rm   rp   r9   rt   rs   rq   rr   	GmtCreaterv   rz   r{   r|   r   r   r   r   r   r+   r   re   r   r'   )r?   r+   r,   rO   rP   rQ   rT   r.   rW   rU   rV   r	   rX   rY   r]   r*   r^   r_   rf   r   r   r   rj   r    r   r   r(   re   r   r   r   s           r$   rB   zDatasetInfo.__init__'  s    **T4((JJvr**	jj6::gt+D+D+e

S^`dHeHeff"JJ}b99 **\488"JJ}d;;!::mR88ZZ..K&**Wd2K2K
zz)R00K66zz+t44=IS+L999t"JJ'8$??IZ!d!23D!E!E!E`d$jj"==::nd33<DN,88x888$ **[$77JJvr**	**Y--LIt1L1L 	&ww	22 	&w 	&!/!,K8?Y8W8Wa{22444]aD595EOt'++D1114DH^b^n!x!243C3G3GHX3Y3Y!Z!Z!ZtxD#DDH!%D::j$//O6::j$3O3O'11 	V$$$$$r&   N)rC   rD   rE   rF   r   rG   rH   rI   r   r   rJ   r*   r   r   r   r   rB   r'   r&   r$   r   r      s         6 	
3-SM3-)****4.   #c]}C=*++++ 12222SM!!!+,,,,
4S#X'
(((($sCx.))))	#H-....tK())))$% $% $% $% $%r&   r   )rJ   dataclassesr   typingr   r   r   r   r   modelscope.hub.utils.utilsr	   rI   r(   r*   r!   r   rN   r   r'   r&   r$   <module>r      s  
  ! ! ! ! ! ! 5 5 5 5 5 5 5 5 5 5 5 5 5 5 8 8 8 8 8 88Dc3h,@#A d=FY    < Y Y Y Y Y Y Y Y8 ! ! ! ! ! ! ! !
 & & & & & & & &. L% L% L% L% L% L% L% L%^ U% U% U% U% U% U% U% U% U% U%r&   