o
    W+ ij8  ã                   @   sÀ   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d	„ZeG d
d„ dƒƒZeG dd„ dƒƒZeG dd„ dƒƒZeG dd„ dƒƒZeG dd„ dƒƒZdS )é    N)Ú	dataclass)ÚAnyÚDictÚListÚLiteralÚOptional)Úconvert_timestampÚsiblings_dataÚreturnÚRepoSiblingc                 C   s   | sg S d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                 S   s®   g | ]S}t | d ¡p| d¡| d¡p| d¡| d¡p | d¡| d¡p)| d¡| d¡p2| d	¡t| d
¡p<| d¡ƒt| d¡pG| d¡| d¡pP| d¡dd‘qS )ÚPathÚpathÚSizeÚsizeZSha256Úsha256ÚTypeÚtypeÚRevisionÚrevisionZCommittedDateZcommittedDate)r   r   )Ú	rfilenamer   Úblob_idr   ÚshaÚlast_modifiedÚlfs)r   Úgetr   ÚBlobLfsInfo)Ú.0Zsibling© r   ú_/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/modelscope/hub/info.pyÚ
<listcomp>   s    õþùÿz#_parse_siblings.<locals>.<listcomp>r   )r	   r   r   r   Ú_parse_siblings   s
   ôr    c                   @   s–   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d„ Z	dS )ÚOrganizationInfoz*Organization information for a repository.ÚidÚnameÚ	full_nameÚdescriptionÚavatarÚgithub_addressr   ÚemailÚcreated_timeÚmodified_timec                 K   sÖ   |  dd ¡| _|  dd¡| _|  dd¡| _|  dd¡| _|  dd¡| _|  dd¡| _|  d|  d	d ¡¡| _|  d
|  dd¡¡| _|  d|  dd ¡¡}|rPt	|ƒnd | _
|  d|  dd ¡¡}|rft	|ƒ| _d S d | _d S )NÚIdÚNameÚ ZFullNameÚDescriptionZAvatarZGithubAddressr   r   ZEmailr(   Z
GmtCreatedr)   ZGmtModifiedr*   )Úpopr"   r#   r$   r%   r&   r'   r   r(   r   r)   r*   )ÚselfÚkwargsr)   r*   r   r   r   Ú__init__8   s   zOrganizationInfo.__init__N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚintÚ__annotations__ÚstrÚdatetimer2   r   r   r   r   r!   *   s   
 r!   c                   @   s.   e Zd ZU dZee ed< dZee ed< dS )r   Nr   r   )	r3   r4   r5   r   r   r7   r8   r   r9   r   r   r   r   r   G   s   
 r   c                   @   s|   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   )r3   r4   r5   r6   r9   r8   r   r   r7   r   r   r   r   r:   r   r   r   r   r   r   r   M   s   
 c                   @   sì  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$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                 K   s¼  |  dd ¡| _|  dd¡| _|  dd¡| _|  dd ¡| _|  dd ¡| _|  dd ¡| _|  dd ¡| _|  d	d¡| _|  d
d¡| _	|  dd ¡| _
|  dd ¡pQ|  dd ¡| _|  dd ¡}|r_t|ƒnd | _|  dd ¡}|rnt|ƒ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 ¡}|r4t |d!ƒr4|j!r4|j!d# }t |d$ƒr| "¡ nd | _#| j#r!| j# $d%¡nd | _%| j#r0t| j# $d&¡ƒnd | _&n	d | _#d | _%d | _&|  d'd¡| _'|  d(d ¡pP|  d)d ¡}t(|ƒ| _)| j* +|¡ d S )+Nr+   r,   r-   ÚChineseNameÚ
VisibilityZIsPublishedZIsOnlineÚAlreadyStarr.   ÚLicenseÚ	DownloadsÚStarsÚLikesZCreatedTimeÚLastUpdatedTimeZArchitecturesZ	ModelTypeZTasksÚReadMeContentÚOrganizationÚ	CreatedByZIsCertificationZApprovalModeZ	CardReadyZBackendSupportz{}Z
ModelInfosÚTagsZIsAccessibler   ZRelatedArxivIdZRelatedPaperÚcommitsÚCommitsr   Úto_dictr"   Úcommitted_dater<   rR   ÚSiblingsr   ),r/   r"   r#   r=   r>   r?   r@   rA   r%   rB   rC   rD   r   rE   rF   rG   rH   rI   rJ   r!   rK   rL   rM   rN   rO   rP   rQ   rS   rT   r   rU   rV   Úhasattrrd   rf   rW   r   r   r   r<   r    rR   Ú__dict__Úupdate©r0   r1   r)   rF   Zorg_datard   rW   rR   r   r   r   r2   À   sZ   
 
zModelInfo.__init__N)r3   r4   r5   r6   r   r7   r8   r9   Úboolr:   r   r   r   r!   r   r2   r   r   r   r   r;   e   sJ   
 (r;   c                   @   s,  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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#   r<   r=   )é   é   é   r>   rA   r%   rB   rC   rD   rE   rF   rJ   rK   rL   rS   rW   r   r   rR   c                 K   sþ  |  dd ¡| _|  dd¡| _|  d|  dd ¡p|  dd ¡¡| _|  dd¡| _|  dd ¡| _|  d	d ¡| _|  d
d¡| _|  dd ¡pF|  dd ¡| _|  dd¡| _	|  dd ¡| _
|  dd ¡}|rbt|ƒnd | _|  dd ¡}|rqt|ƒnd | _|  dd¡| _|  dd ¡}|rŠtdi |¤Žnd | _|  dd ¡| _|  dg ¡| _|  dd ¡p¦|  dd ¡}|rÝt|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 ¡}t|ƒ| _| j |¡ d S )Nr+   r,   r-   r<   ZOwnerÚ	NamespacerX   rY   rZ   r.   r^   r]   r[   r\   Z	GmtCreater_   r`   ra   rb   rc   rd   re   r   rf   r"   rg   rR   rh   r   )r/   r"   r#   r<   r=   r>   rA   r%   rD   rB   rC   r   rE   rF   rJ   r!   rK   rL   rS   ri   rd   rf   rW   r   r   r   r    rR   rj   rk   rl   r   r   r   r2   '  s>   "

zDatasetInfo.__init__N)r3   r4   r5   r6   r   r7   r8   r9   r   rm   r:   r!   r   r   r   r   r2   r   r   r   r   rn   õ   s.   
 rn   )r:   Údataclassesr   Útypingr   r   r   r   r   Zmodelscope.hub.utils.utilsr   r9   r    r!   r   r   r;   rn   r   r   r   r   Ú<module>   s    & 