o
    -wi	                     @  sf   d Z ddlmZ ddlmZmZ ddlmZ ddl	m
Z
 er*ddlmZ ddlmZ G dd	 d	Zd
S )zArtifact manifest.    )annotations)TYPE_CHECKINGMapping)Api)HexMD5)ArtifactManifestEntry)StoragePolicyc                   @  s   e Zd ZU ded< e	d-d.d	d
Zed/ddZ	d-d0ddZd/ddZd1ddZ	d2ddZ
d3d4d d!Zd5d"d#Zd6d'd(Zd7d+d,ZdS )8ArtifactManifestz dict[str, ArtifactManifestEntry]entriesNmanifest_jsondictapiInternalApi | Nonereturnc                 C  sL   d|vrt d|d }|  D ]}| |kr!|j||d  S qt d)Nversionz4Invalid manifest format. Must contain version field.)r   zInvalid manifest version.)
ValueError__subclasses__r   from_manifest_json)clsr   r   r   sub r   b/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/wandb/sdk/artifacts/artifact_manifest.pyr      s   z#ArtifactManifest.from_manifest_jsonintc                 C     t NNotImplementedError)r   r   r   r   r      s   zArtifactManifest.versionstorage_policyr   *Mapping[str, ArtifactManifestEntry] | NoneNonec                 C  s"   || _ |rt|| _d S i | _d S r   )r   r   r
   )selfr   r
   r   r   r   __init__"   s   zArtifactManifest.__init__c                 C  s
   t | jS r   )lenr
   r    r   r   r   __len__*   s   
zArtifactManifest.__len__c                 C  r   r   r   r#   r   r   r   to_manifest_json-      z!ArtifactManifest.to_manifest_jsonr   c                 C  r   r   r   r#   r   r   r   digest0   r&   zArtifactManifest.digestFentryr   	overwriteboolc                 C  sB   |j }|s| j|}|r|j|jkrtd||| j|< d S )Nz Cannot add the same path twice: )pathr
   getr'   r   )r    r(   r)   r+   
prev_entryr   r   r   	add_entry3   s   zArtifactManifest.add_entryc                 C  s2   z| j |j= W d S  ty   td|j dw )NzCannot remove missing entry: '')r
   r+   LookupErrorFileNotFoundError)r    r(   r   r   r   remove_entry;   s
   zArtifactManifest.remove_entryr+   strArtifactManifestEntry | Nonec                 C  s   | j |S r   )r
   r,   )r    r+   r   r   r   get_entry_by_pathA   s   z"ArtifactManifest.get_entry_by_path	directorylist[ArtifactManifestEntry]c                   s    fddj D S )Nc                   s$   g | ]}|  d  rj| qS )/)
startswithr
   ).0	entry_keyr6   r    r   r   
<listcomp>E   s    z=ArtifactManifest.get_entries_in_directory.<locals>.<listcomp>)r
   )r    r6   r   r<   r   get_entries_in_directoryD   s   z)ArtifactManifest.get_entries_in_directoryr   )r   r   r   r   r   r	   )r   r   )r   r   r
   r   r   r   )r   r   )r   r   )F)r(   r   r)   r*   r   r   )r(   r   r   r   )r+   r3   r   r4   )r6   r3   r   r7   )__name__
__module____qualname____annotations__classmethodr   r   r!   r$   r%   r'   r.   r2   r5   r>   r   r   r   r   r	      s    
 




r	   N)__doc__
__future__r   typingr   r   wandb.sdk.internal.internal_apir   InternalApiwandb.sdk.lib.hashutilr   +wandb.sdk.artifacts.artifact_manifest_entryr   "wandb.sdk.artifacts.storage_policyr   r	   r   r   r   r   <module>   s    