+
    QV-jì1  ã                   ó<  € R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
 ^ RIt^ RIHt ^ RIHt ^RIHt ^RIHt ^R	IHtHtHtHtHtHt ^R
IHt ^RIHtHt ^RI H!t!H"t" ^RI#H$t$ ^RI%H&t& ]! ]'4      t( ! R R]PR                  4      t* ! R R4      t+R# )zDownload manager interface.N)Údatetime)Úpartial)ÚOptionalÚUnion)Ú	url_to_fs)Ú
thread_map)Úconfig)Útqdm)ÚArchiveIterableÚFilesIterableÚcached_pathÚis_relative_pathÚ,stack_multiprocessing_download_progress_barsÚurl_or_path_join)Úget_size_checksum_dict)Ú
get_loggerr	   )ÚNestedDataStructureÚ
map_nested)Útracked_str)ÚDownloadConfigc                   ó&   € ] tR t^2tRtRtRtRtRtR# )ÚDownloadModea  `Enum` for how to treat pre-existing downloads and data.

The default mode is `REUSE_DATASET_IF_EXISTS`, which will reuse both
raw downloads and the prepared dataset if they exist.

The generations modes:

|                                     | Downloads | Dataset |
|-------------------------------------|-----------|---------|
| `REUSE_DATASET_IF_EXISTS` (default) | Reuse     | Reuse   |
| `REUSE_CACHE_IF_EXISTS`             | Reuse     | Fresh   |
| `FORCE_REDOWNLOAD`                  | Fresh     | Fresh   |

Úreuse_dataset_if_existsÚreuse_cache_if_existsÚforce_redownload© N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚREUSE_DATASET_IF_EXISTSÚREUSE_CACHE_IF_EXISTSÚFORCE_REDOWNLOADÚ__static_attributes__r   ó    Ús/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/datasets/download/download_manager.pyr   r   2   s   † ñð 8ÐØ3ÐØ)Ôr%   r   c                   óØ   a € ] tR t^Gt o RtRV 3R lR llt]R 4       t]R 4       tV 3R lR lt	R	 t
V 3R
 lR ltV 3R lR ltV 3R lR ltV 3R lR ltR tR tR tR tR tRtV tR# )ÚDownloadManagerFNc          	      ór   <€ V ^8„  d   QhRS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          /# )é   Údataset_nameÚdata_dirÚdownload_configÚ	base_path)r   Ústrr   )ÚformatÚ__classdict__s   "€r&   Ú__annotate__ÚDownloadManager.__annotate__J   sD   ø€ ÷ !"ñ !"á™s•mð!"ñ ™3•-ð!"ñ "¡.Õ1ð	!"ñ
 ™C•=ñ!"r%   c                óâ   € Wn         W n        T;'       g     \        P                  P	                  R4      V n        / V n        WPn        T;'       g    \        4       V n	        / V n
        / V n        R# )a½  Download manager constructor.

Args:
    data_dir:
        can be used to specify a manual directory to get the files from.
    dataset_name (`str`):
        name of dataset this instance will be used for. If
        provided, downloads will contain which datasets they were used for.
    download_config (`DownloadConfig`):
        to specify the cache directory and other
        download options
    base_path (`str`):
        base path that is used when relative paths are used to
        download files. This can be a remote url.
    record_checksums (`bool`, defaults to `False`):
        Whether to record the checksums of the downloaded files. If None, the value is inferred from the builder.
Ú.N)Ú_dataset_nameÚ	_data_dirÚosÚpathÚabspathÚ
_base_pathÚ_recorded_sizes_checksumsÚrecord_checksumsr   r-   Údownloaded_pathsÚextracted_paths)Úselfr+   r,   r-   r.   r=   s   &&&&&&r&   Ú__init__ÚDownloadManager.__init__J   s\   € ð2 *ÔØ!ŒØ#×;Ð;¤r§w¡w§¡°sÓ';ˆŒàZ\ˆÔ&Ø 0ÔØ.×BÐB´.Ó2BˆÔØ "ˆÔØ!ˆÖr%   c                ó   € V P                   # ©N)r7   ©r@   s   &r&   Ú
manual_dirÚDownloadManager.manual_dirm   s   € à�~‰~Ðr%   c                óV   € \        R V P                  P                  4        4       4      # )z+Returns the total size of downloaded files.c              3   ó2   "  € T F  qR ,          x € K  	  R# 5i)Ú	num_bytesNr   )Ú.0Úchecksums_dicts   & r&   Ú	<genexpr>Ú2DownloadManager.downloaded_size.<locals>.<genexpr>t   s   é € ÐmÑEl°> +×.Ò.ÓElùs   ‚)Úsumr<   ÚvaluesrE   s   &r&   Údownloaded_sizeÚDownloadManager.downloaded_sizeq   s$   € ô ÑmÀT×EcÑEc×EjÑEjÔElÓmÓmÐmr%   c                ó&   <€ V ^8„  d   QhRS[ RS[ /# )r*   Úurl_or_urlsÚdownloaded_path_or_paths)r   )r0   r1   s   "€r&   r2   r3   v   s   ø€ ÷ ñ Ñ3Fð Ñbuñ r%   c           	     óî   € ^p\        \        \        VP                  4       VP                  4       4      4      VRR7       F1  w  rE\	        WPP
                  R7      V P                  \        V4      &   K3  	  R# )z)Record size/checksum of downloaded files.zComputing checksums)ÚdelayÚdesc)Úrecord_checksumN)Úhf_tqdmÚlistÚzipÚflattenr   r=   r<   r/   )r@   rT   rU   rW   Úurlr9   s   &&&   r&   Ú_record_sizes_checksumsÚ'DownloadManager._record_sizes_checksumsv   se   € àˆÜ Ü”�[×(Ñ(Ó*Ð,D×,LÑ,LÓ,NÓOÓPØØ&÷
‰IˆCô 8NØ×&;Ñ&;ô8ˆD×*Ñ*¬3¨s«8Ó4ó
r%   c                ó¨  € V P                   P                  4       pRVn        VP                  f   RVn        \	        V P
                  VR7      p\        P                  ! 4       p\        4       ;_uu_ 4        \        VVRVP                  RRRR7      pRRR4       \        P                  ! 4       V,
          p\        P                  RVP                  4       ^<,           R	24       \        V4      p\        X4      pV P                  P!                  \#        \%        VP'                  4       VP'                  4       4      4      4       \        P                  ! 4       pV P)                  W4       \        P                  ! 4       V,
          p\        P                  R
VP                  4       ^<,           R	24       VP*                  #   + '       g   i     EL7; i)a  Download given URL(s).

By default, only one process is used for download. Pass customized `download_config.num_proc` to change this behavior.

Args:
    url_or_urls (`str` or `list` or `dict`):
        URL or `list` or `dict` of URLs to download. Each URL is a `str`.

Returns:
    `str` or `list` or `dict`:
        The downloaded paths matching the given input `url_or_urls`.

Example:

```py
>>> downloaded_files = dl_manager.download('https://storage.googleapis.com/seldon-datasets/sentence_polarity_v1/rt-polaritydata.tar.gz')
```
FNzDownloading data©r-   TzDownloading data files)Ú	map_tupleÚnum_procrX   ÚbatchedÚ
batch_sizezDownloading took z minzChecksum Computation took éÿÿÿÿ)r-   ÚcopyÚextract_compressed_fileÚdownload_descr   Ú_download_batchedr   Únowr   r   rd   ÚloggerÚinfoÚtotal_secondsr   r>   ÚupdateÚdictr\   r]   r_   Údata)r@   rT   r-   Údownload_funcÚ
start_timerU   Údurations   &&     r&   ÚdownloadÚDownloadManager.downloadƒ   sl  € ð& ×.Ñ.×3Ñ3Ó5ˆØ27ˆÔ/Ø×(Ñ(Ò0Ø,>ˆOÔ)ä × 6Ñ 6ÈÔXˆä—\’\“^ˆ
Ü9×;Õ;Ü'1ØØØØ(×1Ñ1Ø-ØØô(Ð$÷ <ô —<’<“> JÕ.ˆÜ�‰Ð'¨×(>Ñ(>Ó(@ÀBÕ(FÐ'GÀtÐLÔMÜ)¨+Ó6ˆÜ#6Ð7OÓ#PÐ Ø×Ñ×$Ñ$¤T¬#¨k×.AÑ.AÓ.CÐE]×EeÑEeÓEgÓ*hÓ%iÔjä—\’\“^ˆ
Ø×$Ñ$ [ÔKÜ—<’<“> JÕ.ˆÜ�‰Ð0°×1GÑ1GÓ1IÈRÕ1OÐ0PÐPTÐUÔVà'×,Ñ,Ð,÷+ <×;Ð;ús   Á5G Ç G	c                óL   <€ V ^8„  d   QhRS[ S[,          RS[RS[ S[,          /# )r*   Úurl_or_filenamesr-   Úreturn)r[   r/   r   )r0   r1   s   "€r&   r2   r3   µ   s1   ø€ ÷ )ñ )á™s�)ð)ñ (ð)ñ 
‰c�ñ	)r%   c           
     ó>  € \        V4      ^8¼  EdV   VP                  4       pRVn        \        V P                  VR7      p\        V^ ,          4      p\        V4      '       d   \        V P                  V4      p\        V3/ VP                  B w  rT^ p VP                  V4      P                  R^ 4      pVR
8  d   \        P                  M^p\!        TTVP"                  ;'       g    RR\$        P&                  P                  R4      R8X  dL   \(        P*                  ! 4       P,                  '       d'   \(        P*                  ! 4       P,                  R,          MRV\.        R	7      # V Uu. uF  pV P	                  W‚R7      NK  	  up#   \         d     Lái ; iu upi )é   Trb   ÚsizeÚDownloadingÚfilesÚ8HF_DATASETS_STACK_MULTIPROCESSING_DOWNLOAD_PROGRESS_BARSÚ1N)rX   ÚunitÚpositionÚmax_workersÚ
tqdm_classi  @rg   )Úlenrh   Údisable_tqdmr   Ú_download_singler/   r   r   r;   r   Ústorage_optionsrn   ÚgetÚ	Exceptionr   Ú&HF_DATASETS_MULTITHREADING_MAX_WORKERSr   rj   r8   ÚenvironÚmultiprocessingÚcurrent_processÚ	_identityr	   )	r@   ry   r-   rs   r9   Úfsr}   r„   Úurl_or_filenames	   &&&      r&   rk   Ú!DownloadManager._download_batchedµ   s  € ô
 ÐÓ  BÕ&Ø-×2Ñ2Ó4ˆOØ+/ˆOÔ(Ü# D×$9Ñ$9È?Ô[ˆMô Ð'¨Õ*Ó+ˆDÜ ×%Ò%ä'¨¯©¸Ó>�Ü  ÑI¨×)HÑ)HÑI‰HˆBØˆDðØ—w‘w˜t“}×(Ñ(¨°Ó3�ð BFÈÔAR”×=Ò=ÐXYð ô ØØ Ø$×2Ñ2×CÐC°mØä—:‘:—>‘>Ð"\Ó]ÐadÔdÜ#×3Ò3Ó5×?×?Ð?ô )×8Ò8Ó:×DÑDÀRÖHð Ø'Üôð ñ (8óá'7�Oð ×%Ñ% oÐ%ÖWÙ'7ñð øô' ô Ùðüò&s   Â!F	 Å+FÆ	FÆFc                ó,   <€ V ^8„  d   QhRS[ RS[RS[ /# )r*   r’   r-   rz   )r/   r   )r0   r1   s   "€r&   r2   r3   à   s#   ø€ ÷ ñ ±ð Ánð ÑY\ñ r%   c                óº   € \        V4      p\        V4      '       d   \        V P                  V4      p\	        WR 7      p\        V4      pVP                  V4       V# )rb   )r/   r   r   r;   r   r   Ú
set_origin)r@   r’   r-   Úouts   &&& r&   rˆ   Ú DownloadManager._download_singleà   sL   € Ü˜oÓ.ˆÜ˜O×,Ò,ä.¨t¯©ÀÓPˆOÜ˜/ÔKˆÜ˜#ÓˆØ�‰�Ô'Øˆ
r%   c                óJ   <€ V ^8„  d   QhRS[ S[S[P                  3,          /# )r*   Úpath_or_buf)r   r/   ÚioÚBufferedReader)r0   r1   s   "€r&   r2   r3   ê   s$   ø€ ÷ =ñ =©©c±2×3DÑ3DÐ.DÕ(Eñ =r%   c                ó~   € \        VR4      '       d   \        P                  ! V4      # \        P                  ! V4      # )aã  Iterate over files within an archive.

Args:
    path_or_buf (`str` or `io.BufferedReader`):
        Archive path or archive binary file object.

Yields:
    `tuple[str, io.BufferedReader]`:
        2-tuple (path_within_archive, file_object).
        File object is opened in binary mode.

Example:

```py
>>> archive = dl_manager.download('https://storage.googleapis.com/seldon-datasets/sentence_polarity_v1/rt-polaritydata.tar.gz')
>>> files = dl_manager.iter_archive(archive)
```
Úread)Úhasattrr
   Úfrom_bufÚfrom_urlpath)r@   rš   s   &&r&   Úiter_archiveÚDownloadManager.iter_archiveê   s3   € ô( �; ×'Ò'Ü"×+Ò+¨KÓ8Ð8ä"×/Ò/°Ó<Ð<r%   c                óF   <€ V ^8„  d   QhRS[ S[S[S[,          3,          /# )r*   Úpaths)r   r/   r[   )r0   r1   s   "€r&   r2   r3     s!   ø€ ÷ 2ñ 2¡¡c©4±­9 nÕ 5ñ 2r%   c                ó.   € \         P                  ! V4      # )a8  Iterate over file paths.

Args:
    paths (`str` or `list` of `str`):
        Root paths.

Yields:
    `str`: File path.

Example:

```py
>>> files = dl_manager.download_and_extract('https://huggingface.co/datasets/AI-Lab-Makerere/beans/resolve/main/data/train.zip')
>>> files = dl_manager.iter_files(files)
```
)r   Úfrom_urlpaths)r@   r¥   s   &&r&   Ú
iter_filesÚDownloadManager.iter_files  s   € ô" ×*Ò*¨5Ó1Ð1r%   c           	     ó|  € V P                   P                  4       pRVn        \        V P                  VR7      p\        VVVP                  RR7      p\        V4      p\        V4      pV P                  P                  \        \        VP                  4       VP                  4       4      4      4       VP                  # )aÄ  Extract given path(s).

Args:
    path_or_paths (path or `list` or `dict`):
        Path of file to extract. Each path is a `str`.

Returns:
    extracted_path(s): `str`, The extracted paths matching the given input
    path_or_paths.

Example:

```py
>>> downloaded_files = dl_manager.download('https://storage.googleapis.com/seldon-datasets/sentence_polarity_v1/rt-polaritydata.tar.gz')
>>> extracted_files = dl_manager.extract(downloaded_files)
```
Trb   zExtracting data files)rd   rX   )r-   rh   ri   r   rˆ   r   rd   r   r?   rp   rq   r\   r]   rr   )r@   Úpath_or_pathsr-   Úextract_funcr?   s   &&   r&   ÚextractÚDownloadManager.extract  s¢   € ð$ ×.Ñ.×3Ñ3Ó5ˆØ26ˆÔ/Ü˜t×4Ñ4ÀoÔVˆÜ$ØØØ$×-Ñ-Ø(ô	
ˆô ,¨MÓ:ˆÜ-¨oÓ>ˆØ×Ñ×#Ñ#¤D¬¨]×-BÑ-BÓ-DÀo×F]ÑF]ÓF_Ó)`Ó$aÔbØ×#Ñ#Ð#r%   c                óB   € V P                  V P                  V4      4      # )ah  Download and extract given `url_or_urls`.

Is roughly equivalent to:

```
extracted_paths = dl_manager.extract(dl_manager.download(url_or_urls))
```

Args:
    url_or_urls (`str` or `list` or `dict`):
        URL or `list` or `dict` of URLs to download and extract. Each URL is a `str`.

Returns:
    extracted_path(s): `str`, extracted paths of given URL(s).
)r­   rv   )r@   rT   s   &&r&   Údownload_and_extractÚ$DownloadManager.download_and_extract6  s   € ð  �|‰|˜DŸM™M¨+Ó6Ó7Ð7r%   c                ó6   € V P                   P                  4       # rD   )r<   rh   rE   s   &r&   Úget_recorded_sizes_checksumsÚ,DownloadManager.get_recorded_sizes_checksumsH  s   € Ø×-Ñ-×2Ñ2Ó4Ð4r%   c                ó˜  € \        V P                  P                  4       4      \        V P                  P                  4       4      ,
          p\	        V P                  P                  4       4       FW  w  r#W19   g   K  \        P                  P                  V4      '       g   K4  \        P                  ! V4       V P                  V KY  	  R # rD   )
Úsetr?   rP   r>   r[   Úitemsr8   r9   ÚisfileÚremove)r@   Úpaths_to_deleteÚkeyr9   s   &   r&   Údelete_extracted_filesÚ&DownloadManager.delete_extracted_filesK  s…   € Ü˜d×2Ñ2×9Ñ9Ó;Ó<¼sÀ4×CXÑCX×C_ÑC_ÓCaÓ?bÕbˆÜ˜d×2Ñ2×8Ñ8Ó:Ö;‰IˆCØÖ&¬2¯7©7¯>©>¸$×+?Ô+?Ü—	’	˜$”Ø×(Ñ(¨Ò-ó <r%   c                ób   € V P                   P                  '       d   V P                  4        R # R # rD   )r-   Údelete_extractedr¼   rE   s   &r&   Úmanage_extracted_filesÚ&DownloadManager.manage_extracted_filesR  s%   € Ø×Ñ×0×0Ð0Ø×'Ñ'Ö)ñ 1r%   )r;   r7   r6   r<   r-   r>   r?   r=   )NNNNF)r   r   r   r   Úis_streamingrA   ÚpropertyrF   rQ   r_   rv   rk   rˆ   r¢   r¨   r­   r°   r³   r¼   rÀ   r$   Ú__classdictcell__)r1   s   @r&   r(   r(   G   s—   ø‡ € Ø€L÷!"ò !"ðF ñó ðð ñnó ðn÷ð ò0-÷d)ð )÷Vð ÷=ð =÷22ð 2ò&$ò@8ò$5ò.÷*ð *r%   r(   ),r    Úenumr›   rŽ   r8   r   Ú	functoolsr   Útypingr   r   ÚfsspecÚfsspec.corer   Útqdm.contrib.concurrentr   Ú r   Úutilsr	   rZ   Úutils.file_utilsr
   r   r   r   r   r   Úutils.info_utilsr   Úutils.loggingr   Úutils.py_utilsr   r   Úutils.trackr   r-   r   r   rm   ÚEnumr   r(   r   r%   r&   Ú<module>rÓ      sq   ðñ  "ã Û 	Û Û 	Ý Ý ß "ã Ý !Ý .å Ý #÷÷ õ 6ß ,ß <Ý %Ý +ñ 
�HÓ	€ô*�4—9‘9ô *÷*M*ó M*r%   